Example #1
0
 /**
  * On loading the plugin
  * @return type
  */
 public function onLoad()
 {
     $this->getLogger()->info("Loading ...");
     Config::init("HealingSpot\\Config.json");
     $this->getServer()->getCommandMap()->register("hs", new MainCommand("hs"));
     Subcommands::register("item", new ItemSubcommand());
     $this->getLogger()->info("is now loaded");
 }
Example #2
0
 /**
  * To execute a subcommand
  * @param type $name 
  * @param type $sender 
  * @param type $args 
  * @return type
  */
 public static function execute($name, $sender, $args)
 {
     $subcommand = self::get($name);
     if (!is_null($subcommand)) {
         if ($subcommand->onlyConsole() && $sender instanceof Player) {
             $sender->sendMessage("Only console can execute this command");
             return true;
         } else {
             if ($subcommand->onlyPlayer() && !$sender instanceof Player) {
                 $sender->sendMessage("Only player can execute this command");
                 return true;
             }
         }
         if (count($args) <= $subcommand->maxArgs() && count($args) >= $subcommand->minArgs()) {
             $subcommand->execute($name, $sender, $args);
         } else {
             $sender->sendMessage("/" . Config::getMainCommand() . " " . $subcommand->usage());
         }
         return true;
     } else {
         return false;
     }
 }