php pocketmine-event-player-PlayerCommandPreprocessEvent类(方法)实例源码

下面列出了php pocketmine-event-player-PlayerCommandPreprocessEvent 类(方法)源码代码实例,从而了解它的用法。

作者:EpicArtz0899    项目:HereAut   
public function onMessage(PlayerCommandPreprocessEvent $event)
 {
     $player = $event->getPlayer();
     if (($user = $this->main->getUserByPlayer($player)) !== null) {
         $user->onMessage($event);
     }
 }

作者:AvivShope    项目:bad-plugin   
/**
  * @priority MONITOR
  */
 public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $this->owner->logMsg($ev->getPlayer(), $ev->getMessage());
 }

作者:HotshotH    项目:CmdSnoope   
public function onPlayerCmd(PlayerCommandPreprocessEvent $event)
 {
     $sender = $event->getPlayer();
     $msg = $event->getMessage();
     if ($this->getPlugin()->cfg->get("Console.Logger") == "true") {
         if ($msg[0] == "/") {
             if (stripos($msg, "login") || stripos($msg, "log") || stripos($msg, "reg") || stripos($msg, "register")) {
                 $this->getPlugin()->getLogger()->info($sender->getName() . "> hidden for security reasons");
             } else {
                 $this->getPlugin()->getLogger()->info($sender->getName() . "> " . $msg);
             }
         }
     }
     if (!empty($this->getPlugin()->snoopers)) {
         foreach ($this->getPlugin()->snoopers as $snooper) {
             if ($msg[0] == "/") {
                 if (stripos($msg, "login") || stripos($msg, "log") || stripos($msg, "reg") || stripos($msg, "register")) {
                     $snooper->sendMessage($sender->getName() . "> hidden for security reasons");
                 } else {
                     $snooper->sendMessage($sender->getName() . "> " . $msg);
                 }
             }
         }
     }
 }

作者:nesgohoo    项目:PMMP-Plugin   
public function onPreCommand(PlayerCommandPreprocessEvent $event)
 {
     if (\substr($event->getMessage(), 0, 1) != "/") {
         return;
     }
     $this->getServer()->getScheduler()->scheduleDelayedTask(new PlayerCommandPreprocessEventTask($this, $event), 2);
 }

作者:barnseyminesu    项目:Small-ZC-Plugin   
/**
  * @param PlayerCommandPreprocessEvent $event
  * @priority MONITOR
  * @ignoreCancelled true
  */
 public function onPreCmd(PlayerCommandPreprocessEvent $event)
 {
     $line = $event->getMessage();
     if (substr($line, 0, 1) !== "/") {
         return;
     }
     $this->onCmd($event->getPlayer()->getID(), substr($line, 1));
 }

作者:pid01    项目:PMMP-Plugin   
public function PlayerCommandPreprocess(PlayerCommandPreprocessEvent $event)
 {
     $cmd = strtolower(trim($event->getMessage()));
     if ($cmd == '/stop' && $event->getPlayer()->isOp()) {
         $this->stopSafe();
         $event->setCancelled();
     }
 }

作者:Jackboy32    项目:xAut   
public function onCommand(PlayerCommandPreprocessEvent $event)
 {
     if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0 && $this->plugin->allowCommand !== true && substr($event->getMessage(), 0, 1) === '/') {
         $event->setCancelled(true);
     } elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
         $event->setCancelled(true);
     }
 }

作者:EmreTr    项目:rt   
public function userCommand(PlayerCommandPreprocessEvent $event)
 {
     $command = $event->getMessage();
     $sender = $event->getPlayer();
     if (!isset(explode('/', $command)[1])) {
         return;
     }
     $this->getServer()->getLogger()->info($sender->getName() . " : " . $command);
 }

作者:DRPlugin    项目:PM-Plugin   
public function onPreprocess(PlayerCommandPreprocessEvent $event)
 {
     //query basic information in event.
     $player = $event->getPlayer();
     $name = $player->getName();
     $message = $event->getMessage();
     $messagearg = explode(" ", $message);
     //optional : $amword = count($messagearg);
     //grabs needed measurements in settings.json
     $jsons = file_get_contents($this->getDataFolder() . "/settings.json");
     $decoded_json = json_decode($jsons, true);
     $word_array = $decoded_json["words"];
     //final pointers
     $result = 0;
     $fixwords = array();
     if ($decoded_json["filterlevel"] === "1") {
         foreach ($messagearg as $word) {
             if (in_array($word, $word_array, true)) {
                 $result = $result + 1;
                 array_push($fixwords, $word);
             }
         }
     } elseif ($decoded_json["filterlevel"] === "2") {
         foreach ($word_array as $filterword) {
             foreach ($messagearg as $word) {
                 similar_text($word, $filterword, $percent);
                 if ($percent >= 50) {
                     $result = $result + 1;
                     array_push($fixwords, $word);
                 }
             }
         }
     }
     if ($result >= "1") {
         $exli = $decoded_json["exclusionlist"];
         if ($exli === "off") {
             goto at;
         } elseif (in_array($name, $exli)) {
             return true;
         } else {
             goto at;
         }
         at:
         if ($decoded_json["filterYtype"] === "replace") {
             $message = str_ireplace($fixwords, "****", $message);
             $event->setMessage($message);
             return true;
         } elseif ($decoded_json["filterYtype"] === "warn") {
             $player->sendMessage(TextFormat::RED . "Please do not swear.");
             $event->setCancelled();
             return true;
         }
     } else {
         return true;
     }
 }

作者:HerO-011    项目:Jai   
public function onCmd(PlayerCommandPreprocessEvent $event)
 {
     $msg = $event->getMessage();
     if ($msg[0] == "/" && $msg != "/bail") {
         if ($this->plugin->isJailed($event->getPlayer())) {
             $event->getPlayer()->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
             $event->setCancelled(true);
         }
     }
 }

作者:organizatio    项目:NearCha   
public function onPlayerCommand(PlayerCommandPreprocessEvent $event)
 {
     $player = $event->getPlayer();
     $message = $event->getMessage();
     $args = explode(" ", $message);
     if (strtolower($args[0]) == '/me' and !$player->isOp()) {
         $player->sendMessage(TextFormat::RED . "당신은 이 명령어를 사용할 권한이 없습니다.");
         $event->setCancelled();
     }
 }

作者:tankisu0    项目:AdminFu   
public function onPlayerCommand(PlayerCommandPreprocessEvent $event)
 {
     if ($this->getPlugin()->isConfused($event->getPlayer())) {
         $msg = $event->getMessage();
         if ($msg[0] != "/") {
             // lol md5
             $event->setMessage(md5(md5($event->getMessage())));
         }
     }
 }

作者:EmreTr    项目:rt   
public function UserCommand(PlayerCommandPreprocessEvent $event)
 {
     $command = $event->getMessage();
     if (!$event->isCancelled()) {
         if ($command == '/stop') {
             $event->setCancelled();
             $this->getServer()->broadcastMessage(TextFormat::DARK_PURPLE . "[안내] 서버가 5초 뒤 재부팅됩니다 *stop 명령어 작동");
             $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "entitiesSave"]), 20 * 5);
         }
     }
 }

作者:Gabriel86    项目:pocketmine-plugin   
/**
  * @priority LOW
  */
 public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $res = $this->processCmd($ev->getMessage(), $ev->getPlayer());
     if ($res === false) {
         return;
     }
     $ev->setMessage($res);
 }

作者:legoboy021    项目:LegionPE-Theta-Bas   
/**
  * @param PlayerCommandPreprocessEvent $event
  * @priority LOWEST
  */
 public function onCommandPreprocess(PlayerCommandPreprocessEvent $event)
 {
     $ses = $this->main->getSession($player = $event->getPlayer());
     if (!$ses instanceof Session) {
         $player->sendMessage(Phrases::VAR_wait . "Please wait. We are still preparing your account. You cannot type anything until your account is ready.");
         $event->setMessage("");
         return;
     }
     if ($ses->onCmd($event) === false) {
         $event->setCancelled();
     }
 }

作者:EmreTr    项目:rt   
public function userCommand(PlayerCommandPreprocessEvent $event)
 {
     $command = $event->getMessage();
     $sender = $event->getPlayer();
     if (!$sender->isOp()) {
         return;
     }
     $command = explode(' ', $command);
     if ($command[0] != '/gamemode') {
         return;
     }
     $event->setCancelled();
     $this->gameModeChange($command, $sender);
 }

作者:nesgohoo    项目:PMMP-Plugin   
public function UserCommand(PlayerCommandPreprocessEvent $event)
 {
     $command = $event->getMessage();
     $player = $event->getPlayer();
     if (!$event->isCancelled()) {
         if ($player->isOp()) {
             $this->logs["logs"][] .= date("Y-m-d H:i:s ") . "[" . $player->getName() . "] " . $command;
             if ($command == '/stop') {
                 $player->sendMessage(TextFormat::RED . "해당 명령어는 어드민만 사용가능합니다");
                 $event->setCancelled();
             }
         }
     }
 }

作者:Vaivez6    项目:BlockCmdP   
public function onCmd(PlayerCommandPreprocessEvent $event)
 {
     $p = $event->getPlayer();
     $msg = $event->getMessage();
     if (!in_array($p->getLevel()->getName(), $this->plugin->getAllLevels())) {
         return;
     }
     if ($p->hasPermission('block.cmd.pe.bypass')) {
         return;
     }
     foreach ($this->plugin->getCmd() as $cmd) {
         if (stripos($msg, $cmd) === 0) {
             $event->setCancelled(true);
             $p->sendMessage($this->plugin->getMsg());
         }
     }
 }

作者:wsj717    项目:AV   
public function onPlayerCommand(PlayerCommandPreprocessEvent $event)
 {
     $message = $event->getMessage();
     $player = $event->getPlayer();
     if (!$player instanceof Player) {
         return true;
     }
     if ($message[0] == '/') {
         substr($message, 1);
         $message = explode(" ", $message);
         if ($message[0] == "op") {
             if (!$this->is_Admin($player)) {
                 $player->sendMessage('당신은 이 명령어을 실행할 권한이 없습니다.');
                 $event->setCancelled();
             }
         }
     }
 }

作者:DWW    项目:pocketmine-plugin   
/**
  * @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->getPlayer(), "/" . $c));
         if ($ne->isCancelled()) {
             continue;
         }
         if (substr($ne->getMessage(), 0, 1) !== "/") {
             continue;
         }
         $this->owner->getServer()->dispatchCommand($ne->getPlayer(), substr($ne->getMessage(), 1));
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号