當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PlayerChatEvent::setMessage方法代碼示例

本文整理匯總了PHP中pocketmine\event\player\PlayerChatEvent::setMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP PlayerChatEvent::setMessage方法的具體用法?PHP PlayerChatEvent::setMessage怎麽用?PHP PlayerChatEvent::setMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\event\player\PlayerChatEvent的用法示例。


在下文中一共展示了PlayerChatEvent::setMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $this->badwords = new Config($this->getDataFolder() . "/Badwords/" . ".yml", Config::YAML);
     $msg = $event->getMessage();
     $badwords = $this->cfg->get("badwords");
     $neuersatz = str_ireplace($badwords, "****", $msg);
     $event->setMessage($neuersatz);
 }
開發者ID:Withertube,項目名稱:Quicksilver,代碼行數:8,代碼來源:ChatSafe.php

示例2: onChat

 /**
  * @priority high
  */
 public function onChat(PlayerChatEvent $ev)
 {
     $id = sprintf("%02x", $this->last_id);
     $this->last_chat[$this->last_id] = $ev->getPlayer()->getDisplayName() . ($hooked = ": {" . $id . "} " . $ev->getMessage());
     ++$this->last_id > 255 ? $this->last_id -= 256 : false;
     $ev->setMessage($hooked);
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:10,代碼來源:Main.php

示例3: onChat

 public function onChat(PlayerChatEvent $ev)
 {
     $p = $ev->getPlayer();
     $badwords = array("fuck", "pussy", "bitch", "nigga", "cunt", "whore", "asshole", "bitch nigga", "dick", "pene", "penis", "cock");
     $msg = explode(" ", $ev->getMessage());
     foreach ($msg as $word) {
         foreach ($badwords as $m) {
             if (strtolower($word) === $m) {
                 $ev->setCancelled();
                 $p->sendMessage("You can't say that youngster!");
             }
         }
     }
     foreach ($msg as $word) {
         $word = "op";
         $search = strpos($msg, $word);
         if ($search === false) {
             return false;
         } else {
             //  $ev->setCancelled();
             $ev->setMessage(str_replace("op", "noob"));
         }
     }
     /* muting chat if($this->isActive[$p->getName()]{
            $p->sendMessage($ev->getMessage(null));
            
        } */
 }
開發者ID:gitter-badger,項目名稱:ChatSystem,代碼行數:28,代碼來源:Main.php

示例4: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $msg = $event->getMessage();
     foreach ($this->rules as $rule) {
         $rule->process($msg);
     }
     $event->setMessage($msg);
 }
開發者ID:barnseyminesuk,項目名稱:Small-ZC-Plugins,代碼行數:8,代碼來源:Spacefiller.php

示例5: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $message = $event->getMessage();
     $flitered_message = str_ireplace($this->fliter, "***", $message);
     if ($flitered_message !== $message) {
         $event->setMessage($flitered_message);
     }
 }
開發者ID:ClearSkyTeam,項目名稱:Plugins,代碼行數:8,代碼來源:MainClass.php

示例6: onChat

 /**
  * @param PlayerChatEvent $event
  */
 public function onChat(PlayerChatEvent $event)
 {
     $msg = $event->getMessage();
     foreach ($this->plugin->getLastCharacter() as $c) {
         if ($msg[0] !== '/') {
             $msg[0] = strtoupper($msg[0]);
             if (strpos($msg, $c) == true && $msg[strpos($msg, $c) + 1] == ' ') {
                 $msg[strpos($msg, $c) + 2] = strtoupper($msg[strpos($msg, $c) + 2]);
             }
             $event->setMessage($msg);
         }
     }
 }
開發者ID:Vaivez66,項目名稱:FirstCapsPE,代碼行數:16,代碼來源:FirstCapsListener.php

示例7: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $hp = $event->getPlayer()->getHealth() - 0;
     $color = TextFormat::GREEN;
     if ($hp < 0) {
         $hp = 0;
     }
     if ($hp <= 5) {
         $color = TextFormat::RED;
     } else {
         if ($hp <= 10) {
             $color = TextFormat::YELLOW;
         }
     }
     $event->setMessage($color . "HP: " . $hp . TextFormat::WHITE . ">" . $event->getMessage());
 }
開發者ID:wsj7178,項目名稱:ShowHP,代碼行數:16,代碼來源:ShowHP.php

示例8: onTalk

 public function onTalk(PlayerChatEvent $ev)
 {
     if ($ev->getPlayer()->hasPermission("simplenospam.bypass")) {
         $ev->setCancelled(false);
         return true;
     }
     if (in_array($ev->getPlayer()->getName(), $this->talked)) {
         $config = $this->config->getAll();
         $ev->setCancelled();
         $ev->getPlayer()->sendMessage("[AntiSpam] Not allowed to talk again for " . $config['interval'] . " seconds");
     } else {
         if (!in_array($ev->getPlayer()->getName(), $this->talked)) {
             $bw = $this->config->getAll();
             $msg = explode(" ", $ev->getMessage());
             foreach ($msg as $word) {
                 foreach ($bw['Blocked words'] as $blw) {
                     if ($blw === strtolower($word)) {
                         if ($bw['replace words'] === "true") {
                             $ev->setMessage($bw['Replacement Message']);
                             $ev->getPlayer()->sendMessage("[AnitSpam] You are not allowed to say the word " . $blw);
                             return true;
                         } else {
                             $ev->setCancelled();
                             $ev->getPlayer()->sendMessage("[AnitSpam] You are not allowed to say the word " . $blw);
                             return true;
                         }
                     }
                 }
             }
             array_push($this->talked, $ev->getPlayer()->getName());
             $task = new allowtalk($this, $ev->getPlayer());
             $this->getServer()->getScheduler()->scheduleDelayedTask($task, 20 * $bw['interval']);
             return;
         }
     }
 }
開發者ID:xHFx,項目名稱:SimpleNoSpam,代碼行數:36,代碼來源:main.php

示例9: onPlayerChat

 /** 
  * @param PlayerChatEvent $event 
  */
 public function onPlayerChat(PlayerChatEvent $event)
 {
     if (!$this->getPlugin()->getConfig()->getNested("color.colorChat") !== true and !$event->getPlayer()->hasPermission("easymessages.action.color")) {
         $event->setMessage($this->getPlugin()->replaceSymbols($event->getMessage(), true));
     }
 }
開發者ID:pomee4,項目名稱:PocketMine-Plugins,代碼行數:9,代碼來源:EasyMessagesListener.php

示例10: onChat

 public function onChat(PlayerChatEvent $e)
 {
     if ($this->getClan($e->getPlayer()->getName()) != null) {
         $e->setMessage(TextFormat::GOLD . "[ " . $this->getClan($e->getPlayer()->getName()) . " ] " . TextFormat::WHITE . $e->getMessage());
     }
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:6,代碼來源:PocketClan.php

示例11: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     $cfg = $this->plugin->getConfig()->getAll();
     $prefix = "";
     if ($cfg["show-prefix"]) {
         $prefix = Main::PREFIX;
     }
     if (!ServerAuth::getAPI()->isPlayerRegistered($player->getName())) {
         if ($player->hasPermission("chatlogin.register")) {
             //Check if confirmation is required
             if ($cfg["password-confirm-required"]) {
                 if (!isset($this->plugin->confirm_users[strtolower($player->getName())])) {
                     $this->plugin->confirm_users[strtolower($player->getName())] = $event->getMessage();
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-confirm-message"]));
                 } else {
                     //Check passwords
                     if ($this->plugin->confirm_users[strtolower($player->getName())] == $event->getMessage()) {
                         unset($this->plugin->confirm_users[strtolower($player->getName())]);
                         $status = ServerAuth::getAPI()->registerPlayer($player, $event->getMessage());
                         if ($status == ServerAuth::SUCCESS) {
                             ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["register-success"]));
                         } elseif ($status == ServerAuth::ERR_USER_ALREADY_REGISTERED) {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["already-registered"]));
                         } elseif ($status == ServerAuth::ERR_PASSWORD_TOO_SHORT) {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-short"]));
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                         } elseif ($status == ServerAuth::ERR_PASSWORD_TOO_LONG) {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-long"]));
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                         } elseif ($status == ServerAuth::ERR_MAX_IP_REACHED) {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["max-ip-reached"]));
                         } elseif ($status == ServerAuth::CANCELLED) {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
                         } else {
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
                             $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                         }
                     } else {
                         unset($this->plugin->confirm_users[strtolower($player->getName())]);
                         $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-no-match"]));
                         $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                     }
                 }
             } else {
                 $status = ServerAuth::getAPI()->registerPlayer($player, $event->getMessage());
                 if ($status == ServerAuth::SUCCESS) {
                     ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["register-success"]));
                 } elseif ($status == ServerAuth::ERR_USER_ALREADY_REGISTERED) {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["already-registered"]));
                 } elseif ($status == ServerAuth::ERR_PASSWORD_TOO_SHORT) {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-short"]));
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                 } elseif ($status == ServerAuth::ERR_PASSWORD_TOO_LONG) {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-long"]));
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                 } elseif ($status == ServerAuth::ERR_MAX_IP_REACHED) {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["max-ip-reached"]));
                 } elseif ($status == ServerAuth::CANCELLED) {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
                 } else {
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
                     $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
                 }
             }
         } else {
             $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg['no-register-permissions']));
         }
         $event->setMessage("");
         $event->setCancelled(true);
     } elseif (!ServerAuth::getAPI()->isPlayerAuthenticated($player)) {
         if ($player->hasPermission("chatlogin.login")) {
             $status = ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
             if ($status == ServerAuth::SUCCESS) {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["login"]["login-success"]));
             } elseif ($status == ServerAuth::ERR_WRONG_PASSWORD) {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["wrong-password"]));
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["login-message"]));
             } elseif ($status == ServerAuth::ERR_USER_ALREADY_AUTHENTICATED) {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["login"]["already-login"]));
             } elseif ($status == ServerAuth::ERR_USER_NOT_REGISTERED) {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["user-not-registered"]));
             } elseif ($status == ServerAuth::CANCELLED) {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
             } else {
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
                 $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["login-message"]));
             }
         } else {
             $player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg['no-login-permissions']));
         }
         $event->setMessage("");
         $event->setCancelled(true);
     }
 }
開發者ID:legoboy0215,項目名稱:ChatLogin,代碼行數:97,代碼來源:EventListener.php

示例12: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $event->setFormat($this->replaceColor($event->getFormat()));
     $event->setMessage($this->replaceColor($event->getMessage()));
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:5,代碼來源:Colorful.php

示例13: onChat

 /**
  * @param PlayerChatEvent $e
  *
  * @priority LOW
  */
 public function onChat(PlayerChatEvent $e)
 {
     $p = $e->getPlayer();
     if ($this->inArena($p)) {
         $e->setMessage(str_replace(["%PLAYER", "%MESSAGE"], [$p->getDisplayName(), $e->getMessage()], SurvivalGames::$cfg["chat_format"]));
         $e->setRecipients($this->getPlayers());
     } else {
         $e->setRecipients(array_diff($this->getPlayers(), $e->getRecipients()));
     }
 }
開發者ID:ChiefArtz,項目名稱:SurvivalGames,代碼行數:15,代碼來源:Arena.php

示例14: onChatEvent

 public function onChatEvent(PlayerChatEvent $event)
 {
     $message = $event->getMessage();
     $event->setMessage($this->config["identify-capital-alphabet"] ? str_replace($this->config["messages"], $this->mosaicList, $message) : str_ireplace($this->config["messages"], $this->mosaicList, $message));
 }
開發者ID:LEET-Realms,項目名稱:ChatFilter,代碼行數:5,代碼來源:ChatFilter.php

示例15: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $Player = $event->getPlayer();
     $Level = $Player->getLevel();
     $Message = $event->getMessage();
     if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
         return;
     }
     if ($Team = $this->plugin->game->getTeamByPlayer($Player)) {
         $event->setFormat("BedWars: <" . $this->plugin->teamColor($Team->name) . "%s" . TextFormat::RESET . ">: %s");
         $prefix = mb_strtolower($this->plugin->getMessage("bedwars.sayall.prefix"));
         if (mb_substr(mb_strtolower($Message), 0, mb_strlen($prefix)) == $prefix) {
             $event->setMessage(mb_substr($Message, mb_strlen($prefix)));
             return;
         }
         $Players = $Level->getPlayers();
         foreach ($this->plugin->game->Teams as $Team2) {
             if ($Team->name != $Team2->name) {
                 foreach ($Team2->Players as $Player2) {
                     foreach ($Players as $i => $Player3) {
                         if ($Player2->getName() == $Player3->getName()) {
                             array_splice($Players, $i, 1);
                         }
                     }
                 }
             }
         }
         $event->setRecipients($Players);
     }
 }
開發者ID:MateiGamingYTB,項目名稱:BedWarsPE,代碼行數:30,代碼來源:EventListener.php


注:本文中的pocketmine\event\player\PlayerChatEvent::setMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。