コード例 #1
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $this->plugin->broadcastTip(Utils::getRandom($this->plugin->getConfig()->getNested("tip.autoMessages")));
 }
コード例 #2
0
 /**
  * @param CommandSender $sender
  * @param string $label
  * @param string[] $args
  * @return bool
  */
 public function execute(CommandSender $sender, $label, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (isset($args[0])) {
         switch (strtolower($args[0])) {
             case "help":
                 $this->sendCommandHelp($sender);
                 return true;
             case "m":
             case "message":
                 if (isset($args[1])) {
                     $message = Utils::replaceSymbols(implode(" ", array_slice($args, 2)));
                     if (strtolower($args[1]) === "@all") {
                         $sender->getServer()->broadcastMessage($message);
                         $sender->sendMessage(TextFormat::GREEN . "Sent message to @all.");
                     } elseif ($player = $sender->getServer()->getPlayer($args[1])) {
                         $player->sendMessage($message);
                         $sender->sendMessage(TextFormat::GREEN . "Sent message to " . $player->getName() . ".");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Failed to send message due to invalid recipient(s).");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a recipient.");
                 }
                 return true;
             case "motd":
                 if (isset($args[1])) {
                     $motd = Utils::replaceSymbols(implode(" ", array_slice($args, 1)));
                     $sender->getServer()->getNetwork()->setName($motd);
                     $sender->sendMessage(TextFormat::GREEN . "Set server motd to: " . TextFormat::RESET . $motd . ".");
                 } else {
                     $sender->sendMessage(TextFormat::GREEN . "Current server motd: " . TextFormat::RESET . $sender->getServer()->getNetwork()->getName());
                 }
                 return true;
             case "p":
             case "popup":
                 if (isset($args[1])) {
                     $popup = Utils::replaceSymbols(implode(" ", array_slice($args, 2)));
                     if (strtolower($args[1]) === "@all") {
                         $this->plugin->broadcastPopup($popup);
                         $sender->sendMessage(TextFormat::GREEN . "Sent popup to @all.");
                     } elseif ($player = $sender->getServer()->getPlayer($args[1])) {
                         $player->sendPopup($popup);
                         $sender->sendMessage(TextFormat::GREEN . "Sent popup to " . $player->getName() . ".");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Failed to send message due to invalid recipient(s).");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a recipient.");
                 }
                 return true;
             case "t":
             case "tip":
                 if (isset($args[1])) {
                     $tip = Utils::replaceSymbols(implode(" ", array_slice($args, 2)));
                     if (strtolower($args[1]) === "@all") {
                         $this->plugin->broadcastTip($tip);
                         $sender->sendMessage(TextFormat::GREEN . "Sent tip to @all.");
                     } elseif ($player = $sender->getServer()->getPlayer($args[1])) {
                         $player->sendTip($tip);
                         $sender->sendMessage(TextFormat::GREEN . "Sent tip to " . $player->getName() . ".");
                     } else {
                         $sender->sendMessage(TextFormat::RED . "Failed to send message due to invalid recipient(s).");
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . "Please specify a recipient.");
                 }
                 return true;
             default:
                 $sender->sendMessage("Usage: /easymessages <sub-command> [parameters]");
                 return false;
         }
     } else {
         $this->sendCommandHelp($sender);
         return false;
     }
 }
コード例 #3
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $this->plugin->getServer()->getNetwork()->setName(str_replace(["{SERVER_DEFAULT_LEVEL}", "{SERVER_MAX_PLAYER_COUNT}", "{SERVER_PLAYER_COUNT}", "{SERVER_NAME}", "{SERVER_PORT}", "{SERVER_TPS}"], [$this->plugin->getServer()->getDefaultLevel()->getName(), $this->plugin->getServer()->getMaxPlayers(), count($this->plugin->getServer()->getOnlinePlayers()), $this->plugin->getServer()->getServerName(), $this->plugin->getServer()->getPort(), $this->plugin->getServer()->getTicksPerSecond()], $this->plugin->getConfig()->getNested("motd.dynamicMotd")));
 }
コード例 #4
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $this->plugin->broadcastTip($this->plugin->getConfig()->getNested("tip.blinkingMessage"));
 }
コード例 #5
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $popup = $this->plugin->getScrollingPopup();
     $this->plugin->broadcastPopup($popup);
     $this->plugin->setScrollingPopup(Utils::next($popup));
 }
コード例 #6
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $this->plugin->getServer()->broadcastMessage(Utils::getRandom($this->plugin->getConfig()->getNested("message.messages")));
 }
コード例 #7
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $this->plugin->broadcastPopup($this->plugin->getConfig()->getNested("popup.infiniteMessage"));
 }
コード例 #8
0
 /** 
  * @param PlayerChatEvent $event
  * @priority MONITOR
  */
 public function onPlayerChat(PlayerChatEvent $event)
 {
     if (!$this->plugin->getConfig()->getNested("color.colorChat") and !$event->getPlayer()->hasPermission("easymessages.action.color")) {
         $event->setMessage(Utils::replaceSymbols($event->getMessage(), true));
     }
 }
コード例 #9
0
 /**
  * @param int $currentTick
  */
 public function onRun($currentTick)
 {
     $tip = $this->plugin->getScrollingTip();
     $this->plugin->broadcastTip($tip);
     $this->plugin->setScrollingTip(Utils::next($tip));
 }