当前位置: 首页>>代码示例>>PHP>>正文


PHP PlayerChatEvent::setFormat方法代码示例

本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::setFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::setFormat方法的具体用法?PHP PlayerChatEvent::setFormat怎么用?PHP PlayerChatEvent::setFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\player\PlayerChatEvent的用法示例。


在下文中一共展示了PlayerChatEvent::setFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

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

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

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

示例5: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $player = $event->getPlayer();
     $format = $this->plugin->getFormattedMessage($player, $event->getMessage());
     $config_node = $this->plugin->getConfiguration()->isFormatterEnabled();
     if (isset($config_node) and $config_node === true) {
         $event->setFormat($format);
     }
 }
开发者ID:BoysElCrack,项目名称:xPermissions,代码行数:9,代码来源:xListener.php

示例6: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $this->config = ccMain::getInstance()->getCfg();
     $allowChat = $this->config->get("disablechat");
     // $this->log ( "allowChat ".$allowChat);
     if ($allowChat) {
         $event->setCancelled(true);
         return;
     }
     if (!$allowChat || $allowChat == null) {
         $player = $event->getPlayer();
         $perm = "chatmute";
         // $this->log ( "permission ".$player->isPermissionSet ( $perm ));
         if ($player->isPermissionSet($perm)) {
             $event->setCancelled(true);
             return;
         }
         if ($this->config->get("per-world-chat") == true) {
             $format = $this->getFormattedMessage($player, $event->getMessage());
             $config_node = $this->config->get("enable-formatter");
             if (isset($config_node) and $config_node === true) {
                 foreach ($player->getServer()->getOnlinePlayers() as $players) {
                     if ($players->getLevel()->getName() == $player->getLevel()->getName()) {
                         $players->sendMessage($format);
                     }
                 }
                 $player->getServer()->getLogger()->info($format);
                 $event->setCancelled(true);
                 return;
             }
         }
         $format = $this->getFormattedMessage($player, $event->getMessage());
         $config_node = $this->config->get("enable-formatter");
         if (isset($config_node) and $config_node === true) {
             $event->setFormat($format);
         }
         return;
     }
 }
开发者ID:AndreyNazarchuk,项目名称:Collection-Plugins-PocketMine-Prax,代码行数:39,代码来源:ccListener.php

示例7: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $nearPoint = null;
     $nearRange = null;
     $player = $event->getPlayer();
     foreach ($this->NydusCanal_List["warp"] as $index => $data) {
         $wx = $this->NydusCanal_List["warp"][$index]['x'];
         $wy = $this->NydusCanal_List["warp"][$index]['y'];
         $wz = $this->NydusCanal_List["warp"][$index]['z'];
         $diff = abs($player->x - $wx);
         $diff += abs($player->y - $wy);
         $diff += abs($player->z - $wz);
         if ($nearPoint == null) {
             $nearPoint = $index;
             $nearRange = $diff;
         }
         if ($nearRange > $diff) {
             $nearPoint = $index;
             $nearRange = $diff;
         }
     }
     if ($nearPoint == null) {
         return;
     }
     $event->setFormat(TextFormat::GOLD . "[ " . $nearPoint . " ] " . $event->getFormat());
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:26,代码来源:NydusCanal.php

示例8: onChat

 public function onChat(PlayerChatEvent $event)
 {
     if ($this->plugin->prefs->get("chat_format") == true) {
         $event->setFormat("[k:" . $this->plugin->points->get($event->getPlayer()->getName())["kills"] . "] [d:" . $this->plugin->points->get($event->getPlayer()->getName())["deaths"] . "] " . $event->getPlayer()->getName() . ": " . $event->getMessage());
     }
 }
开发者ID:Skull3x,项目名称:WonderCore,代码行数:6,代码来源:EventHandler.php

示例9: onChat

 public function onChat(PlayerChatEvent $event)
 {
     $user = $event->getPlayer->getName();
     if ($this->config->get('chat-format') == true) {
         $event->setFormat("[" . $this->points->get($user[2]) . "]<" . $user . ">: " . $event->getMessage());
     }
 }
开发者ID:EmreTr1,项目名称:SkyWarsForPE,代码行数:7,代码来源:Main.php

示例10: onPlayerChat

 public function onPlayerChat(PlayerChatEvent $event)
 {
     $s = $this->cfg->get("symbol");
     $player = $event->getPlayer();
     $hp = $player->getHealth();
     $format = $event->getFormat();
     if ($hp == 20) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 19) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . $s . $s . "§7" . $s . "§f]", $format);
     }
     if ($hp == 18) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . $s . $s . "§8" . $s . "§f]", $format);
     }
     if ($hp == 17) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . $s . "§7" . $s . "§8" . $s . "§f]", $format);
     }
     if ($hp == 16) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . $s . "§8" . $s . $s . "§f]", $format);
     }
     if ($hp == 15) {
         $format = str_replace("{HEALTHY}", "§f[§2" . $s . $s . $s . $s . $s . $s . $s . "§7" . $s . "§8" . $s . $s . "§f]", $format);
     }
     if ($hp == 14) {
         $format = str_replace("{HEALTHY}", "§f[§a" . $s . $s . $s . $s . $s . $s . $s . "§8" . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 13) {
         $format = str_replace("{HEALTHY}", "§f[§a" . $s . $s . $s . $s . $s . $s . "§7" . $s . "§8" . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 12) {
         $format = str_replace("{HEALTHY}", "§f[§a" . $s . $s . $s . $s . $s . $s . "§8" . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 11) {
         $format = str_replace("{HEALTHY}", "§f[§a" . $s . $s . $s . $s . $s . "§7" . $s . "§8" . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 10) {
         $format = str_replace("{HEALTHY}", "§f[§a" . $s . $s . $s . $s . $s . "§8" . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 9) {
         $format = str_replace("{HEALTHY}", "§f[§e" . $s . $s . $s . $s . "§7" . $s . "§8" . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 8) {
         $format = str_replace("{HEALTHY}", "§f[§e" . $s . $s . $s . $s . "§8" . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 7) {
         $format = str_replace("{HEALTHY}", "§f[§6" . $s . $s . $s . "§7" . $s . "§8" . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 6) {
         $format = str_replace("{HEALTHY}", "§f[§6" . $s . $s . $s . "§8" . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 5) {
         $format = str_replace("{HEALTHY}", "§f[§6" . $s . $s . "§7" . $s . "§8" . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 4) {
         $format = str_replace("{HEALTHY}", "§f[§c" . $s . $s . "§8" . $s . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 3) {
         $format = str_replace("{HEALTHY}", "§f[§c" . $s . "§7" . $s . "§8" . $s . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 2) {
         $format = str_replace("{HEALTHY}", "§f[§4" . $s . "§8" . $s . $s . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 1) {
         $format = str_replace("{HEALTHY}", "§f[§8" . $s . $s . $s . $s . $s . $s . $s . $s . $s . $s . "§f]", $format);
     }
     if ($hp == 0) {
         $format = str_replace("{HEALTHY}", "§f[§4DEATH§f]", $format);
     }
     $event->setFormat($format);
 }
开发者ID:alex2534alex,项目名称:PocketMinePlugins,代码行数:71,代码来源:healthy.php

示例11: onChat

 public function onChat(PlayerChatEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $player = $ev->getPlayer();
     if (!$this->cfg["settings"]["chat"]) {
         $ev->setCancelled();
         $player->sendMessage(TextFormat::RED . "[YouChat] Chat has been disabled!");
         return;
     }
     $n = trim(strtolower($player->getName()));
     $prefix = $this->cfg["settings"]["prefix"];
     if (isset($this->players[$n])) {
         if ($this->players[$n]["prefix"]) {
             $prefix = $this->players[$n]["prefix"];
         }
         if ($this->players[$n]["mute"]) {
             $ev->setCancelled();
             $player->sendMessage(TextFormat::RED . "[YouChat] You have been muted from chat!");
             return;
         }
         if ($this->players[$n]["pause"]) {
             $ev->setCancelled();
             $player->sendMessage(TextFormat::RED . "[YouChat] You have paused chat!");
             return;
         }
     }
     $recvr = [];
     foreach ($ev->getRecipients() as $to) {
         $m = strtolower($to->getName());
         if (isset($this->players[$m])) {
             if ($this->players[$m]["pause"]) {
                 continue;
             }
         }
         $recvr[] = $to;
     }
     $ev->setRecipients($recvr);
     $vars = ["{YouChat}" => $this->getDescription()->getFullName(), "{player}" => $player->getName(), "{displayname}" => "{%0}", "{nick}" => $player->getDisplayName(), "{world}" => $player->getLevel()->getName(), "{message}" => "{%1}", "{prefix}" => $prefix, "{BLACK}" => TextFormat::BLACK, "{DARK_BLUE}" => TextFormat::DARK_BLUE, "{DARK_GREEN}" => TextFormat::DARK_GREEN, "{DARK_AQUA}" => TextFormat::DARK_AQUA, "{DARK_RED}" => TextFormat::DARK_RED, "{DARK_PURPLE}" => TextFormat::DARK_PURPLE, "{GOLD}" => TextFormat::GOLD, "{GRAY}" => TextFormat::GRAY, "{DARK_GRAY}" => TextFormat::DARK_GRAY, "{BLUE}" => TextFormat::BLUE, "{GREEN}" => TextFormat::GREEN, "{AQUA}" => TextFormat::AQUA, "{RED}" => TextFormat::RED, "{LIGHT_PURPLE}" => TextFormat::LIGHT_PURPLE, "{YELLOW}" => TextFormat::YELLOW, "{WHITE}" => TextFormat::WHITE, "{OBFUSCATED}" => TextFormat::OBFUSCATED, "{BOLD}" => TextFormat::BOLD, "{STRIKETHROUGH}" => TextFormat::STRIKETHROUGH, "{UNDERLINE}" => TextFormat::UNDERLINE, "{ITALIC}" => TextFormat::ITALIC, "{RESET}" => TextFormat::RESET];
     if (($kr = $this->getServer()->getPluginManager()->getPlugin("KillRate")) !== null) {
         $vars["{kills}"] = $kr->getScore($player, "player");
         $vars["{points}"] = $kr->getScore($player, "points");
     }
     $ev->setFormat(strtr($this->cfg["settings"]["chat-format"], $vars));
 }
开发者ID:applqpak,项目名称:plugin-remakes,代码行数:46,代码来源:Main.php

示例12: onVipChat

 public function onVipChat(PlayerChatEvent $event)
 {
     if ($this->isVip($event->getPlayer()->getName()) === false) {
         return;
     }
     $event->setFormat($this->colorFormat . $event->getFormat());
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:7,代码来源:VIPPlus.php

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

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

示例15: factionChat

 public function factionChat(PlayerChatEvent $PCE)
 {
     if (!$this->plugin->getServer()->getPluginManager()->getPlugin("CustomChat") == false) {
         return true;
     }
     if (!$this->plugin->getServer()->getPluginManager()->getPlugin("PureChat") == false) {
         return true;
     }
     //This will be chat for players who are "Members" of a faction
     if ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isMember($PCE->getPlayer()->getName())) {
         $m = $PCE->getMessage();
         $p = $PCE->getPlayer()->getName();
         $lowerp = strtolower($p);
         $stmt = $this->plugin->db->query("SELECT * FROM master WHERE player='{$p}';");
         $result = $stmt->fetchArray(SQLITE3_ASSOC);
         $f = $result["faction"];
         $PCE->setFormat("[+{$f}] {$p}: {$m}");
         //MOTD RECEIVER
         $p = strtolower($p);
         $stmt = $this->plugin->db->query("SELECT * FROM motdrcv WHERE player='{$p}';");
         $result = $stmt->fetchArray(SQLITE3_ASSOC);
         if (!empty($result)) {
             if (time() - $result["timestamp"] > 30) {
                 $PCE->getPlayer()->sendMessage("[FactionsPro] Timed out. Please use /f motd again.");
                 $this->plugin->db->query("DELETE FROM motdrcv WHERE player='{$p}';");
                 $PCE->setCancelled(true);
                 return true;
             } else {
                 $motd = $PCE->getMessage();
                 $faction = $this->plugin->getPlayerFaction($p);
                 $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO motd (faction, message) VALUES (:faction, :message);");
                 $stmt->bindValue(":faction", $faction);
                 $stmt->bindValue(":message", $motd);
                 $result = $stmt->execute();
                 $PCE->setCancelled(true);
                 $this->plugin->db->query("DELETE FROM motdrcv WHERE player='{$p}';");
                 $PCE->getPlayer()->sendMessage("[FactionsPro] Successfully updated faction message of the day!");
             }
         }
         return true;
     }
     //This will be the chat for players that are "Officers"
     if ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isOfficer($PCE->getPlayer()->getName())) {
         $m = $PCE->getMessage();
         $p = $PCE->getPlayer()->getName();
         $lowerp = strtolower($p);
         $stmt = $this->plugin->db->query("SELECT * FROM master WHERE player='{$p}';");
         $result = $stmt->fetchArray(SQLITE3_ASSOC);
         $f = $result["faction"];
         $PCE->setFormat("[*{$f}] {$p}: {$m}");
         return true;
     } elseif ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isLeader($PCE->getPlayer()->getName())) {
         $m = $PCE->getMessage();
         $p = $PCE->getPlayer()->getName();
         $lowerp = strtolower($p);
         $stmt = $this->plugin->db->query("SELECT * FROM master WHERE player='{$p}';");
         $result = $stmt->fetchArray(SQLITE3_ASSOC);
         $f = $result["faction"];
         $PCE->setFormat("[**{$f}] {$p}: {$m}");
         return true;
     } else {
         $m = $PCE->getMessage();
         $p = $PCE->getPlayer()->getName();
         $PCE->setFormat("{$p}: {$m}");
     }
 }
开发者ID:Tolo0,项目名称:FactionsPro,代码行数:66,代码来源:FactionListener.php


注:本文中的pocketmine\event\player\PlayerChatEvent::setFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。