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


PHP PlayerChatEvent::getMessage方法代碼示例

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


在下文中一共展示了PlayerChatEvent::getMessage方法的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

 public function onChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     $message = "<{$player->getName()}> : {$event->getMessage()}";
     if ($this->config["show-chat"] == false) {
         $event->setCancelled();
     }
     $pos = new Position($player->getX(), $player->getY() + 3, $player->getZ(), $player->getLevel());
     TAGSystem::getInstance()->addInstanceTag($pos, $message, $this->config["show-time"] * 20);
 }
開發者ID:wsj7178,項目名稱:WordBallon,代碼行數:10,代碼來源:WordBallon.php

示例3: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "as") {
         return false;
     }
     if (count($args) < 2) {
         $sender->sendMessage(mc::_("Must specified a player and a command"));
         return false;
     }
     $player = $this->owner->getServer()->getPlayer($n = array_shift($args));
     if (!$player) {
         $sender->sendMessage(mc::_("Player %1% not found", $n));
         return true;
     }
     if ($args[0] == 'chat' || $args[0] == 'say') {
         array_shift($args);
         $chat = implode(" ", $args);
         $this->owner->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, $chat));
         if (!$ev->isCancelled()) {
             if (MPMU::apiVersion("1.12.0")) {
                 $s = $this->owner->getServer();
                 $s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
             } else {
                 $this->owner->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
             }
         }
     } else {
         $cmdline = implode(' ', $args);
         $sender->sendMessage(mc::_("Running command as %1%", $n));
         $this->owner->getServer()->dispatchCommand($player, $cmdline);
     }
     return true;
 }
開發者ID:0-DevMatthew-0,項目名稱:pocketmine-plugins,代碼行數:33,代碼來源:CmdAs.php

示例4: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $message = $event->getMessage();
     if ($this->plugin->status === "enabled" and $this->plugin->loginmanager[$event->getPlayer()->getId()] !== 1) {
         if ($this->plugin->provider === "yml") {
             if ($this->plugin->loginmanager[$event->getPlayer()->getId()] === 0) {
                 $event->getPlayer()->sendMessage("Thanks! Please re-type your wanted password in chat.");
                 $this->plugin->loginmanager[$event->getPlayer()->getId()] = $message;
             } elseif ($this->plugin->loginmanager[$event->getPlayer()->getId()] === $message) {
                 $this->proccessPassword($message, 0, $event->getPlayer());
                 $event->getPlayer()->sendMessage("You are now registered.");
                 unset($this->plugin->proccessmanager[$event->getPlayer()->getId()]);
             }
         } elseif ($this->owner->provider === "mysql") {
             $event->getPlayer()->sendMessage("> Connecting to MySQL server..Please wait.");
             //Manage login/register for provider.
         }
     } else {
         $ecr = $this->proccessPassword($event->getMessage(), 1);
         if ($myuser->get("password") === $ecr) {
             $event->getPlayer()->sendMessage("You are now logged in.");
             $name = $event->getPlayer()->getName();
             $p->sendTip("Welcome, {$name} to the server!");
         } else {
             $event->getPlayer()->sendMessage("Login failed.");
         }
     }
 }
開發者ID:ChiefArtz,項目名稱:xAuth,代碼行數:28,代碼來源:LoginAndRegister.php

示例5: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $this->plugin->event = $event;
     $extensions = $this->getAllExtensions();
     foreach ($extensions as $get) {
         if ($this->plugin->getServer()->getPluginManager()->getPlugin($get) && method_exists($this->plugin->getServer()->getPluginManager()->getPlugin($get), "onRegisterPrefix")) {
             $this->plugin->getServer()->getPluginManager()->getPlugin($get)->onRegisterPrefix();
         }
     }
     // ===========
     //	Format
     // ===========
     $this->plugin->replaceTag("{WORLD}", $event->getPlayer()->getLevel()->getName());
     //Level Tag
     $this->plugin->replaceTag("{PLAYER}", $event->getPlayer()->getName());
     //Player Tag
     $this->plugin->replaceTag("{PREFIX}", $this->plugin->getConfig()->get("prefix"));
     //Prefix Tag
     $this->plugin->replaceTag("{SUFFIX}", $this->plugin->getConfig()->get("suffix"));
     //Suffix Tag
     $this->plugin->replaceTag("{MESSAGE}", $event->getMessage());
     //Message Tag
     //Custom tags
     $tags = new Config($this->plugin->getDataFolder() . "tags.yml", Config::YAML);
     foreach ($tags->getAll() as $tag => $value) {
         $this->plugin->replaceTag("{" . strtoupper($tag) . "}", $value);
     }
     $event->setFormat($this->getFormattedMessage($this->plugin->getConfig()->get("chat-format")));
     // ===========
     //	Player Mute
     // ===========
     $mhut = $event->getRecipients();
     for ($lol = 0; $i < count($mhut); $lol++) {
         if (isset($this->leave[$mhut[$lol]->getName()])) {
             unset($mhut[$lol]);
         }
     }
     $event->setRecipients($mhut);
     $allowChat = $this->plugin->getConfig()->get("disablechat");
     if ($allowChat) {
         $event->setCancelled(true);
         return;
     }
     if (!$allowChat || $allowChat == null) {
         $player = $event->getPlayer();
         $perm = "chatmute";
         if ($player->isPermissionSet($perm)) {
             $event->setCancelled(true);
             return;
         }
         $format = $this->getFormattedMessage($player, $event->getMessage());
         $config_node = $this->plugin->getConfig()->get("enable-formatter");
         if (isset($config_node) and $config_node === true) {
             $event->setFormat($format);
         }
         return;
     }
 }
開發者ID:AndreyNazarchuk,項目名稱:Collection-Plugins-PocketMine-Prax,代碼行數:58,代碼來源:EventListener.php

示例6: factionChat

 public function factionChat(PlayerChatEvent $PCE)
 {
     $faction = $this->plugin->getSession($PCE->getPlayer())->getFaction();
     if ($faction == null) {
         $PCE->setFormat($PCE->getPlayer()->getName() . ": " . $PCE->getMessage());
     } else {
         $PCE->setFormat("[" . $faction->getName() . "] " . $PCE->getPlayer()->getName() . ": " . $PCE->getMessage());
     }
     return true;
     $player = strtolower($PCE->getPlayer()->getName());
 }
開發者ID:GamerXzavier,項目名稱:Party-remake,代碼行數:11,代碼來源:FactionListener.php

示例7: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $event->setCancelled();
     $player = $event->getPlayer();
     $sub = $this->playerSubs[$player->getID()];
     $sub->onChatEvent($event->getMessage());
 }
開發者ID:barnseyminesuk,項目名稱:Small-ZC-Plugins,代碼行數:7,代碼來源:SessionControl.php

示例8: onChat

 /**
  * @param PlayerChatEvent $e
  */
 public function onChat(PlayerChatEvent $e)
 {
     $msg = $e->getMessage();
     $this->p = $e->getPlayer();
     $this->ev = $e;
     $this->checkMessage($e->getPlayer());
 }
開發者ID:xBeastModeXD,項目名稱:AntiSpammer-1,代碼行數:10,代碼來源:AntiSpammer.php

示例9: 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

示例10: execute

 /**
  * @param CommandSender $sender
  * @param string $alias
  * @param array $args
  * @return bool
  */
 public function execute(CommandSender $sender, $alias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (count($args) < 1) {
         $this->sendUsage($sender, $alias);
         return false;
     }
     if (!($player = $this->getAPI()->getPlayer(array_shift($args)))) {
         $sender->sendMessage(TextFormat::RED . "[Error] Player not found");
         return false;
     } elseif ($player->hasPermission("essentials.sudo.exempt")) {
         $sender->sendMessage(TextFormat::RED . "[Error] " . $player->getName() . " cannot be sudo'ed");
         return false;
     }
     $v = implode(" ", $args);
     if (substr($v, 0, 2) === "c:") {
         $sender->sendMessage(TextFormat::GREEN . "Sending message as " . $player->getDisplayName());
         $this->getAPI()->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, substr($v, 2)));
         if (!$ev->isCancelled()) {
             $this->getAPI()->getServer()->broadcastMessage(\sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
         }
     } else {
         $sender->sendMessage(TextFormat::AQUA . "Command ran as " . $player->getDisplayName());
         $this->getAPI()->getServer()->dispatchCommand($player, $v);
     }
     return true;
 }
開發者ID:PrimusLV,項目名稱:EssentialsPE,代碼行數:35,代碼來源:Sudo.php

示例11: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $cfg = $this->getConfig()->getAll();
     $p = $event->getPlayer();
     $prefix = $cfg["prefix"];
     $type = $cfg["type"];
     $m = $cfg["message"];
     $m = str_replace("{player}", $p->getName(), $m);
     $msg = $event->getMessage();
     $domain = $this->getDomain();
     foreach ($domain as $d) {
         if (preg_match("/^{$d}/i", $msg) || stripos($msg, $d) == true) {
             switch ($type) {
                 case "block":
                     $p->sendMessage(TF::YELLOW . $prefix . TF::RED . " " . $m);
                     $event->setCancelled(true);
                     break;
                 case "broadcast":
                     $this->getServer()->broadcastMessage(TF::YELLOW . $prefix . TF::RED . " " . $m);
                     $event->setCancelled(true);
                     break;
             }
         }
     }
 }
開發者ID:DWWf,項目名稱:Small-PocketMine-Plugins,代碼行數:25,代碼來源:NoAdvertising.php

示例12: onChat

 public function onChat(PlayerChatEvent $event)
 {
     if ($event->getPlayer() instanceof DummyPlayer) {
         $event->setCancelled();
         $this->processMessage($event->getMessage());
     }
 }
開發者ID:n15001,項目名稱:Chatty,代碼行數:7,代碼來源:NetworkInterlocker.php

示例13: 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

示例14: onPlayerChat

 /**
  * @param PlayerChatEvent $event
  * @priority HIGH
  */
 public function onPlayerChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     $message = $event->getMessage();
     $levelName = $this->plugin->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null;
     $chatFormat = $this->plugin->getChatFormat($player, $message, $levelName);
     $event->setFormat($chatFormat);
 }
開發者ID:mad-hon,項目名稱:PureChat,代碼行數:12,代碼來源:PCListener.php

示例15: factionChat

 public function factionChat(PlayerChatEvent $PCE)
 {
     $player = strtolower($PCE->getPlayer()->getName());
     //MOTD Check
     //TODO Use arrays instead of database for faster chatting?
     if ($this->plugin->motdWaiting($player)) {
         if (time() - $this->plugin->getMOTDTime($player) > 90) {
             $PCE->getPlayer()->sendMessage($this->plugin->formatMessage("Timed out. Please use /f motd again."));
             $this->plugin->db->query("DELETE FROM motdrcv WHERE player='{$player}';");
             $PCE->setCancelled(true);
             return true;
         } else {
             $motd = $PCE->getMessage();
             $faction = $this->plugin->getPlayerFaction($player);
             $this->plugin->setMOTD($faction, $player, $motd);
             $PCE->setCancelled(true);
             $PCE->getPlayer()->sendMessage($this->plugin->formatMessage("Successfully updated faction message of the day!", true));
         }
         return true;
     }
     //Member
     if ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isMember($PCE->getPlayer()->getName())) {
         $message = $PCE->getMessage();
         $player = $PCE->getPlayer()->getName();
         $faction = $this->plugin->getPlayerFaction($player);
         $PCE->setFormat("[{$faction}] {$player}: {$message}");
         return true;
     } elseif ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isOfficer($PCE->getPlayer()->getName())) {
         $message = $PCE->getMessage();
         $player = $PCE->getPlayer()->getName();
         $faction = $this->plugin->getPlayerFaction($player);
         $PCE->setFormat("*[{$faction}] {$player}: {$message}");
         return true;
     } elseif ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isLeader($PCE->getPlayer()->getName())) {
         $message = $PCE->getMessage();
         $player = $PCE->getPlayer()->getName();
         $faction = $this->plugin->getPlayerFaction($player);
         $PCE->setFormat("**[{$faction}] {$player}: {$message}");
         return true;
         //Not in faction
     } else {
         $message = $PCE->getMessage();
         $player = $PCE->getPlayer()->getName();
         $PCE->setFormat("{$player}: {$message}");
     }
 }
開發者ID:CaptainDuck,項目名稱:EnderFactions,代碼行數:46,代碼來源:FactionListener.php


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