コード例 #1
0
ファイル: CmdSelMgr.php プロジェクト: xHFx/pocketmine-plugins
 /**
  * @priority HIGHEST
  */
 public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
 {
     if ($ev instanceof PlayerCommandPreprocessEvent_sub) {
         return;
     }
     $line = $ev->getMessage();
     if (substr($line, 0, 1) !== "/") {
         return;
     }
     if (!$ev->getPlayer()->hasPermission("gb.module.cmdsel")) {
         return;
     }
     $res = $this->processCmd(substr($line, 1), $ev->getPlayer());
     if ($res === false) {
         return;
     }
     $ev->setCancelled();
     foreach ($res as $c) {
         $this->owner->getServer()->getPluginManager()->callEvent($ne = new PlayerCommandPreprocessEvent_sub($ev->getSender(), "/" . $c));
         if ($ne->isCancelled()) {
             continue;
         }
         if (substr($ne->getMessage(), 0, 1) !== "/") {
             continue;
         }
         $this->owner->getServer()->dispatchCommand($ne->getSender(), substr($ne->getMessage(), 1));
     }
 }