getCommand() публичный Метод

public getCommand ( ) : string
Результат string
 public function onConsoleCmd(ServerCommandEvent $event)
 {
     if (isset($this->currentLine)) {
         $event->setCommand($this->currentLine . $event->getCommand());
         unset($this->currentLine);
     }
     $msg = $event->getCommand();
     if (preg_match('/^(.*)\\\\([a-z])$/', $msg, $match)) {
         $char = $match[2];
         switch ($char) {
             case self::CHAR_NORMAL:
                 $event->setCommand($match[1]);
                 break;
             case self::CHAR_RTRIM:
                 $event->setCommand(rtrim($match[1]));
                 break;
             case self::CHAR_CANCEL:
                 $event->setCancelled();
                 break;
             case self::CHAR_PUSH:
                 $event->setCancelled();
                 $this->simulateInput($match[1]);
                 break;
         }
     }
 }
Пример #2
0
 public function onServerCommandEvent(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     /*if($command(){0} == "/") $event->setCommand(str_replace("/", "", $event->getCommand()));*/
     if ($command[0] == "/") {
         $event->setCommand(substr($event->getCommand(), 1));
     }
 }
Пример #3
0
 public function onConsole(ServerCommandEvent $event)
 {
     if (!$event->getSender() instanceof CommandSender) {
         throw new ServerException("CommandSender is not valid");
     }
     if (!$event->getSender() instanceof Player) {
         $event->setCancelled();
     }
     if (!$this->getServer()->getCommandMap()->dispatch($event->getSender(), $event->getCommand())) {
         $this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . $this->configData["default-prefix"] . " " . $event->getCommand());
     }
 }
Пример #4
0
 /**
  * @param ServerCommandEvent $event
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onConsoleCmd(ServerCommandEvent $event)
 {
     if ($event instanceof ServerCommandEvent_sub) {
         return;
     }
     /** @var string|array $cmd */
     $cmd = $event->getCommand();
     if (DEBUGGING) {
         echo "Processing console command {$cmd}... ";
     }
     if ($this->proceedCommand($event->getSender(), $cmd)) {
         if (DEBUGGING) {
             echo "Parsed command recursively: ";
             var_dump($cmd);
             echo PHP_EOL;
         }
         $event->setCancelled();
         if (count($cmd) > 0) {
             foreach ($cmd as $c) {
                 $this->getServer()->getPluginManager()->callEvent($ev = new ServerCommandEvent_sub($event->getSender(), $c));
                 if (!$ev->isCancelled()) {
                     $this->getServer()->dispatchCommand($ev->getSender(), $ev->getCommand());
                 }
             }
         }
     } else {
         $event->setCommand($cmd);
         if (DEBUGGING) {
             echo "Command processed and changed to:\n{$cmd}\n";
         }
     }
 }
Пример #5
0
 /**
  * @param ServerCommandEvent $event
  */
 public function onServerCommand(ServerCommandEvent $event)
 {
     $command = $this->getAPI()->colorMessage($event->getCommand());
     if ($command === false) {
         $event->setCancelled(true);
     }
     $event->setCommand($command);
 }
Пример #6
0
 public function ServerCommand(ServerCommandEvent $event)
 {
     $br = strtolower(trim($event->getCommand()));
     if ($br == 'stop') {
         $event->setCancelled();
         $this->stopSafe();
     }
 }
Пример #7
0
 public function ServerCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $player = $event->getSender();
     if (strtolower($command) !== "thaad") {
         return;
     }
     $event->setCancelled();
     $this->getServer()->getScheduler()->scheduleAsyncTask(new THAAD_async($this->getDataFolder()));
 }
Пример #8
0
 public function serverCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $sender = $event->getSender();
     $command = explode(' ', $command);
     if ($command[0] != 'gamemode') {
         return;
     }
     $event->setCancelled();
     $this->gameModeChange($command, $sender);
 }
Пример #9
0
 public function ServerCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     if ($event->isCancelled()) {
         return false;
     }
     if ($command == 'stop') {
         $event->setCancelled();
         $this->getServer()->broadcastMessage(TextFormat::DARK_PURPLE . "[안내] 서버가 5초 뒤 재부팅됩니다 *stop 명령어 작동");
         $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "entitiesSave"]), 20 * 5);
     }
 }
Пример #10
0
 public function checkConsole()
 {
     Timings::$serverCommandTimer->startTiming();
     if (($line = $this->console->getLine()) !== null) {
         $this->pluginManager->callEvent($ev = new ServerCommandEvent($this->consoleSender, $line));
         if (!$ev->isCancelled()) {
             $this->dispatchCommand($ev->getSender(), $ev->getCommand());
         }
     }
     Timings::$serverCommandTimer->stopTiming();
 }
Пример #11
0
 /**
  * @priority HIGHEST
  */
 public function onConsoleCmd(ServerCommandEvent $ev)
 {
     if ($ev instanceof ServerCommandEvent_sub) {
         return;
     }
     $res = $this->processCmd($ev->getCommand(), $ev->getSender());
     if ($res === false) {
         return;
     }
     $ev->setCancelled();
     foreach ($res as $c) {
         $this->owner->getServer()->getPluginManager()->callEvent($ne = new ServerCommandEvent_sub($ev->getSender(), $c));
         if ($ne->isCancelled()) {
             continue;
         }
         $this->owner->getServer()->dispatchCommand($ne->getSender(), $ne->getCommand());
     }
 }
Пример #12
0
 /**
  * @param ServerCommandEvent $event
  */
 public function onServerCommandProcess(ServerCommandEvent $event)
 {
     $command = strtolower(substr($event->getCommand(), 0, 8));
     if ($command === "save-all") {
         $this->onCommandProcess($event->getSender());
     }
 }
 /**
  * Get a default set of servers.
  *
  * @param ServerCommandEvent $event        	
  *
  */
 public function serverCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $sender = $event->getSender();
     if ($this->plugin->getConfig()->get("usecustompacket", false) != true) {
         return;
     }
     // Select the server mode
     if ($this->plugin->getConfig()->get("servermode", null) == null) {
         switch (strtolower($command)) {
             case "master":
                 $this->plugin->getConfig()->set("servermode", $command);
                 $this->plugin->message($sender, $this->plugin->get("master-mode-selected"));
                 $this->plugin->message($sender, $this->plugin->get("please-choose-passcode"));
                 break;
             case "slave":
                 $this->plugin->getConfig()->set("servermode", $command);
                 $this->plugin->message($sender, $this->plugin->get("slave-mode-selected"));
                 $this->plugin->message($sender, $this->plugin->get("please-choose-passcode"));
                 break;
             default:
                 $this->plugin->message($sender, $this->plugin->get("please-choose-mode"));
                 break;
         }
         $event->setCancelled();
         return;
     }
     // Communication security password entered
     if ($this->plugin->getConfig()->get("passcode", null) == null) {
         if (mb_strlen($command, "UTF-8") < 8) {
             $this->plugin->message($sender, $this->plugin->get("too-short-passcode"));
             $this->plugin->message($sender, $this->plugin->get("please-choose-passcode"));
             $event->setCancelled();
             return;
         }
         $this->plugin->getConfig()->set("passcode", $command);
         $this->plugin->message($sender, $this->plugin->get("passcode-selected"));
         if ($this->plugin->getConfig()->get("servermode", null) == "slave") {
             $this->plugin->message($sender, $this->plugin->get("please-type-master-ip"));
         } else {
             if ($this->plugin->getConfig()->get("servermode", null) == "master") {
                 $this->plugin->message($sender, $this->plugin->get("all-setup-complete"));
             }
         }
         $event->setCancelled();
         return;
     }
     if ($this->plugin->getConfig()->get("servermode", null) == "slave") {
         // If the slave mode
         if ($this->plugin->getConfig()->get("masterip", null) == null) {
             // Enter the master server IP
             $ip = explode(".", $command);
             if (!isset($ip[3]) or !is_numeric($ip[0]) or !is_numeric($ip[1]) or !is_numeric($ip[2]) or !is_numeric($ip[3])) {
                 $this->plugin->message($sender, $this->plugin->get("wrong-ip"));
                 $this->plugin->message($sender, $this->plugin->get("please-type-master-ip"));
                 $event->setCancelled();
                 return;
             }
             $this->plugin->getConfig()->set("masterip", $command);
             $this->plugin->message($sender, $this->plugin->get("master-ip-selected"));
             $this->plugin->message($sender, $this->plugin->get("please-type-master-port"));
             $event->setCancelled();
             return;
         }
         if ($this->plugin->getConfig()->get("masterport", null) == null) {
             // Enter the master server ports
             if (!is_numeric($command) or $command <= 30 or $command >= 65535) {
                 $this->plugin->message($sender, $this->plugin->get("wrong-port"));
                 $this->plugin->message($sender, $this->plugin->get("please-type-master-port"));
                 $event->setCancelled();
                 return;
             }
             $this->plugin->getConfig()->set("masterport", $command);
             $this->plugin->message($sender, $this->plugin->get("master-port-selected"));
             $this->plugin->message($sender, $this->plugin->get("all-setup-complete"));
             $event->setCancelled();
             return;
         }
     }
 }
Пример #14
0
 public function ServerCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $sender = $event->getSender();
     if (!$this->enable) {
         return;
     }
     if ($this->locked != 'false') {
         $rtime = 60 - abs($this->locked - time());
         echo "" . "[LaunchCode] " . "" . "콘솔 잠겨있습니다. (" . $rtime . "초 남음)" . "\n";
         $event->setCancelled();
         return;
     }
     if ($sender instanceof Player) {
         return;
     }
     if ($this->logining == true) {
         $event->setCancelled();
         if ($this->ACCESS($command)) {
             $this->login = true;
         }
         $this->logining = false;
         return;
     }
     if (abs(date('i') - $this->ctime) >= 10 and $this->ctime != null and $this->login == true) {
         echo "" . "[LaunchCode] " . "" . "자동 로그아웃 되었습니다. (5M TIME OUT)\n";
         $this->login = false;
         $event->setCancelled();
     }
     $this->ctime = date('i');
     if ($command == 'login' and $this->login == false) {
         $event->setCancelled();
         $rand1 = rand(0, 4);
         $rand2 = rand(0, 4);
         $number = $rand1 + 1;
         $alphabet = chr(ord('A') + $rand2);
         $rand_face = rand(0, 1);
         if ($rand_face) {
             $this->passkey = $this->security_keys[$rand1][$rand2][0];
         } else {
             $this->passkey = $this->security_keys[$rand1][$rand2][1];
         }
         if ($rand_face) {
             $rand_face = "앞";
         } else {
             $rand_face = "뒷";
         }
         echo "" . "[LaunchCode] " . "" . "보안코드 [" . $number . $alphabet . "]번 " . "" . $rand_face . " 두자리" . "" . "를 입력하세요. : " . "";
         $this->logining = true;
         return;
     }
     if ($this->login == false) {
         $event->setCancelled();
         echo "" . "[LaunchCode] " . "" . "권한이 없습니다. (ACCESS DENIED).\n";
         if (++$this->cancelcount >= 5) {
             $this->locked = time();
             echo "" . "[LaunchCode] " . "" . "콘솔 잠금처리되었습니다. (CONSOLE LOCKED)\n";
             $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "unlock"], [$event]), 20 * 60);
         } else {
             echo "" . "[LaunchCode] " . "" . $this->cancelcount . "회실패. (5회시 잠금처리됩니다.) (LOCK WARNING).\n";
         }
         return;
     }
     if ($command == 'logout') {
         if ($this->login == true) {
             $this->login = false;
             $event->setCancelled();
             echo "" . "[LaunchCode] " . "" . "정상적으로 로그아웃 되었습니다.\n";
             echo "" . "[LaunchCode] " . "" . "콘솔보호가 작동됩니다. (AUTHENTICATION REQUIRED)\n";
         }
     }
 }
Пример #15
0
 public function onServerCommand(ServerCommandEvent $event)
 {
     $this->log($event->getCommand(), $event->getSender());
 }
 /**
  * @priority MONITOR
  */
 public function onConsoleCmd(ServerCommandEvent $ev)
 {
     $this->logEvent(self::CONSOLE, $ev->getCommand());
 }
Пример #17
0
 public function onServerCommand(ServerCommandEvent $event)
 {
     $event->setCommand($this->alias($event->getCommand()));
     $m = $this->specialCommand($event);
     if ($m !== false) {
         $event->setCommand($m);
     }
 }
Пример #18
0
 /**
  * @param ServerCommandEvent $event
  * @priority MONITOR
  * @ignoreCancelled true
  */
 public function onConsoleCmd(ServerCommandEvent $event)
 {
     $this->onCmd("pocketmine\\command\\ConsoleCommandSender", $event->getCommand());
 }
Пример #19
0
 /**
  * @priority MONITOR
  */
 public function onConsoleCmd(ServerCommandEvent $ev)
 {
     $this->owner->logMsg($ev->getSender(), $ev->getCommand());
 }
Пример #20
0
 /**
  * @priority LOWEST
  */
 public function onConsoleCmd(ServerCommandEvent $ev)
 {
     $res = $this->processCmd($ev->getCommand(), $ev->getSender());
     if ($res === false) {
         return;
     }
     $ev->setCommand($res);
 }
Пример #21
0
 /**
  * Manage the configuration of the load balancer
  *
  * @param ServerCommandEvent $event        	
  */
 public function serverCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $sender = $event->getSender();
     if (!isset($this->db["mode"])) {
         // Select the server mode
         switch (strtolower($command)) {
             case "master":
                 // master
                 $this->db["mode"] = $command;
                 $this->message($sender, $this->get("master-mode-selected"));
                 $this->message($sender, $this->get("please-choose-passcode"));
                 break;
             case "slave":
                 // slave
                 $this->db["mode"] = $command;
                 $this->message($sender, $this->get("slave-mode-selected"));
                 $this->message($sender, $this->get("please-choose-passcode"));
                 break;
             default:
                 $this->message($sender, $this->get("please-choose-mode"));
                 break;
         }
         $event->setCancelled();
         return;
     }
     if (!isset($this->db["passcode"])) {
         // Communication security password entered
         if (mb_strlen($command, "UTF-8") < 8) {
             $this->message($sender, $this->get("too-short-passcode"));
             $this->message($sender, $this->get("please-choose-passcode"));
             $event->setCancelled();
             return;
         }
         $this->db["passcode"] = $command;
         $this->message($sender, $this->get("passcode-selected"));
         if ($this->db["mode"] == "slave") {
             $this->message($sender, $this->get("please-type-master-ip"));
         } else {
             $this->message($sender, $this->get("all-setup-complete"));
             $this->callback = $this->getServer()->getScheduler()->scheduleRepeatingTask(new LoadBalancerTask($this), 20);
         }
         $event->setCancelled();
         return;
     }
     if ($this->db["mode"] == "slave") {
         // If the slave mode
         if (!isset($this->db["masterList"])) {
             // Enter the master server IP
             $address = explode(":", $command);
             $ip = explode(".", $address[0]);
             if (!isset($ip[3]) or !is_numeric($ip[0]) or !is_numeric($ip[1]) or !is_numeric($ip[2]) or !is_numeric($ip[3])) {
                 $this->message($sender, $this->get("wrong-ip"));
                 $this->message($sender, $this->get("please-type-master-ip"));
                 $event->setCancelled();
                 return;
             }
             if (!is_numeric($address[1]) or $address[1] <= 30 or $address[1] >= 65535) {
                 $this->message($sender, $this->get("wrong-port"));
                 $this->message($sender, $this->get("please-type-master-ip"));
                 $event->setCancelled();
                 return;
             }
             $this->db["masterList"] = [$command];
             $this->message($sender, $this->get("master-server-added"));
             $this->message($sender, $this->get("all-setup-complete"));
             $this->callback = $this->getServer()->getScheduler()->scheduleRepeatingTask(new LoadBalancerTask($this), 20);
             $event->setCancelled();
             return;
         }
     }
 }
Пример #22
0
 public function onServerCommand(ServerCommandEvent $event)
 {
     $event->setCommand($this->alias($event->getCommand()));
     if ($m = $this->eazyCommand($event)) {
         $event->setCommand($m);
     } else {
         $event->setCancelled();
     }
 }
Пример #23
0
 /**
  * @priority HIGHEST
  */
 public function onServerCommandProcess(ServerCommandEvent $event)
 {
     if (!$event->isCancelled() && stripos("save-all", $command = $event->getCommand()) === 0) {
         $this->checkSaveAll($event->getSender());
     }
 }
Пример #24
0
 public function serverCommand(ServerCommandEvent $event)
 {
     $command = $event->getCommand();
     $sender = $event->getSender();
     if (!isset($this->db["mode"])) {
         // 서버모드 선택
         switch (strtolower($command)) {
             case "master":
                 // master
                 $this->db["mode"] = $command;
                 $this->message($sender, $this->get("master-mode-selected"));
                 $this->message($sender, $this->get("please-choose-passcode"));
                 break;
             case "slave":
                 // slave
                 $this->db["mode"] = $command;
                 $this->message($sender, $this->get("slave-mode-selected"));
                 $this->message($sender, $this->get("please-choose-passcode"));
                 break;
             default:
                 $this->message($sender, $this->get("please-choose-mode"));
                 break;
         }
         $event->setCancelled();
         return;
     }
     if (!isset($this->db["passcode"])) {
         // 통신보안 암호 입력
         if (mb_strlen($command, "UTF-8") < 8) {
             $this->message($sender, $this->get("too-short-passcode"));
             $this->message($sender, $this->get("please-choose-passcode"));
             $event->setCancelled();
             return;
         }
         $this->db["passcode"] = $command;
         $this->message($sender, $this->get("passcode-selected"));
         $this->message($sender, $this->get("please-choose-port"));
         $event->setCancelled();
         return;
     }
     if (!isset($this->db["port"])) {
         // 서버 은행 포트 설정
         if (!is_numeric($command) or $command <= 30 or $command >= 65535) {
             $this->message($sender, $this->get("wrong-port"));
             $event->setCancelled();
             return;
         }
         $this->db["port"] = $command;
         $this->message($sender, $this->get("port-selected"));
         if ($this->db["mode"] == "slave") {
             $this->message($sender, $this->get("please-type-master-ip"));
         } else {
             $this->message($sender, $this->get("all-setup-complete"));
         }
         $event->setCancelled();
         return;
     }
     if ($this->db["mode"] == "slave") {
         // 슬레이브 모드일 경우
         if (!isset($this->db["master-ip"])) {
             // 마스터서버 아이피 입력
             $ip = explode(".", $command);
             if (!isset($ip[3]) or !is_numeric($ip[0]) or !is_numeric($ip[1]) or !is_numeric($ip[2]) or !is_numeric($ip[3])) {
                 $this->message($sender, $this->get("wrong-ip"));
                 $this->message($sender, $this->get("please-type-master-ip"));
                 $event->setCancelled();
                 return;
             }
             $this->db["master-ip"] = $command;
             $this->message($sender, $this->get("master-ip-selected"));
             $this->message($sender, $this->get("please-type-master-port"));
             $event->setCancelled();
             return;
         }
         if (!isset($this->db["master-port"])) {
             // 마스터서버 포트 입력
             if (!is_numeric($command) or $command <= 30 or $command >= 65535) {
                 $this->message($sender, $this->get("wrong-port"));
                 $this->message($sender, $this->get("please-type-master-port"));
                 $event->setCancelled();
                 return;
             }
             $this->db["master-port"] = $command;
             $this->message($sender, $this->get("master-port-selected"));
             $this->message($sender, $this->get("all-setup-complete"));
             $event->setCancelled();
             return;
         }
     }
 }