/**
  * @param Plugin      $plugin
  * @param Permissible $permissible
  *
  * @throws PluginException
  */
 public function __construct(Plugin $plugin, Permissible $permissible)
 {
     if (!$plugin->isEnabled()) {
         throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
     }
     $this->permissible = $permissible;
     $this->plugin = $plugin;
 }
Esempio n. 2
0
 private function describeToSender(Plugin $plugin, CommandSender $sender)
 {
     $desc = $plugin->getDescription();
     $sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());
     if ($desc->getDescription() != \null) {
         $sender->sendMessage($desc->getDescription());
     }
     if ($desc->getWebsite() != \null) {
         $sender->sendMessage("Website: " . $desc->getWebsite());
     }
     if (\count($authors = $desc->getAuthors()) > 0) {
         if (\count($authors) === 1) {
             $sender->sendMessage("Author: " . \implode(", ", $authors));
         } else {
             $sender->sendMessage("Authors: " . \implode(", ", $authors));
         }
     }
 }
Esempio n. 3
0
 /**
  * //TODO: tick scheduled attachments
  *
  * @param Plugin $plugin
  * @param string $name
  * @param bool   $value
  *
  * @return PermissionAttachment
  *
  * @throws PluginException
  */
 public function addAttachment(Plugin $plugin, $name = null, $value = null)
 {
     if ($plugin === null) {
         throw new PluginException("Plugin cannot be null");
     } elseif (!$plugin->isEnabled()) {
         throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
     }
     $result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this);
     $this->attachments[spl_object_hash($result)] = $result;
     if ($name !== null and $value !== null) {
         $result->setPermission($name, $value);
     }
     $this->recalculatePermissions();
     return $result;
 }
Esempio n. 4
0
 /**
  * @param string        $event Class name that extends Event
  * @param Listener      $listener
  * @param int           $priority
  * @param EventExecutor $executor
  * @param Plugin        $plugin
  * @param bool          $ignoreCancelled
  *
  * @throws PluginException
  */
 public function registerEvent($event, Listener $listener, $priority, EventExecutor $executor, Plugin $plugin, $ignoreCancelled = false)
 {
     if (!is_subclass_of($event, Event::class)) {
         throw new PluginException($event . " is not an Event");
     }
     $class = new \ReflectionClass($event);
     if ($class->isAbstract()) {
         throw new PluginException($event . " is an abstract Event");
     }
     if ($class->getProperty("handlerList")->getDeclaringClass()->getName() !== $event) {
         throw new PluginException($event . " does not have a handler list");
     }
     if (!$plugin->isEnabled()) {
         throw new PluginException("Plugin attempted to register " . $event . " while not enabled");
     }
     $timings = new TimingsHandler("Plugin: " . $plugin->getDescription()->getFullName() . " Event: " . get_class($listener) . "::" . ($executor instanceof MethodEventExecutor ? $executor->getMethod() : "???") . "(" . (new \ReflectionClass($event))->getShortName() . ")", self::$pluginParentTimer);
     $this->getEventListeners($event)->register(new RegisteredListener($listener, $executor, $priority, $plugin, $ignoreCancelled, $timings));
 }
Esempio n. 5
0
 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         $this->server->getLogger()->info($this->server->getLanguage()->translateString("BukkitPE.plugin.disable", [$plugin->getDescription()->getFullName()]));
         $this->server->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
Esempio n. 6
0
 /**
  * @param Plugin $context
  */
 public function __construct(Plugin $context)
 {
     $prefix = $context->getDescription()->getPrefix();
     $this->pluginName = $prefix != null ? "[{$prefix}] " : "[" . $context->getDescription()->getName() . "] ";
 }