当前位置: 首页>>代码示例>>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;未经允许,请勿转载。