diff --git a/README.md b/README.md index a3c55d1..9a75520 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ PocketMine-MP plugins ## Requirements -PocketMine-MP 1.7dev API 3.0.0-ALPHA7 -> 3.0.0-ALPHA12 +PocketMine-MP API 3.0.0 ## Overview diff --git a/plugin.yml b/plugin.yml index d41403c..466f368 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: ChatCensor main: ChatCensor\ChatCensor -version: 2.2 -api: [3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10, 3.0.0-ALPHA11, 3.0.0-ALPHA12] +version: 2.3 +api: [3.0.0] load: STARTUP author: EvolSoft description: A powerful chat censoring plugin diff --git a/src/ChatCensor/ChatCensor.php b/src/ChatCensor/ChatCensor.php index a7f8d8d..3559304 100644 --- a/src/ChatCensor/ChatCensor.php +++ b/src/ChatCensor/ChatCensor.php @@ -1,11 +1,10 @@ words = new Config($this->getDataFolder() . "words.yml", Config::YAML); $this->muted = new Config($this->getDataFolder() . "muted.yml", Config::YAML); $this->messages = new Config($this->getDataFolder() . "messages.yml", Config::YAML); - $this->cfg = $this->getConfig(); + $this->cfg = $this->getConfig()->getAll(); $this->getCommand("chatcensor")->setExecutor(new Commands\Commands($this)); $this->getCommand("addword")->setExecutor(new Commands\AddWord($this)); $this->getCommand("removeword")->setExecutor(new Commands\RemoveWord($this)); @@ -106,6 +59,24 @@ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); } + /** + * Get ChatCensor API + * + * @return ChatCensor + */ + public static function getAPI(){ + return self::$instance; + } + + /** + * Get ChatCensor version + * + * @return string + */ + public function getVersion(){ + return $this->getVersion(); + } + /** * Get ChatCensor API version * @@ -115,13 +86,24 @@ public function getAPIVersion(){ return self::API_VERSION; } + /** + * Reload ChatCensor configuration + */ + public function reload(){ + $this->reloadConfig(); + $this->cfg = $this->getConfig()->getAll(); + $this->muted->reload(); + $this->words->reload(); + $this->messages->reload(); + } + /** * Get the list of allowed characters * * @return string */ public function getAllowedChars(){ - return $this->getConfig()->getAll()["char-check"]["allowed-chars"]; + return $this->cfg["char-check"]["allowed-chars"]; } /** @@ -130,7 +112,7 @@ public function getAllowedChars(){ * @return string */ public function getUnallowedChars(){ - return $this->getConfig()->getAll()["char-check"]["unallowed-chars"]; + return $this->cfg["char-check"]["unallowed-chars"]; } /** @@ -141,14 +123,14 @@ public function getUnallowedChars(){ * @return array|bool */ public function getWord($word){ - if($this->cfg->getAll()["censor"]["advanced-mode"]){ + if($this->cfg["censor"]["advanced-mode"]){ if($this->wordExists($word, $k)){ - return $this->words->getAll()[$k]; + return $this->words->get($k); } return false; } if($this->wordExists($word)){ - return $this->words->getAll()[$word]; + return $this->words->get($word); } return false; } @@ -162,7 +144,7 @@ public function getWord($word){ * @return bool */ public function wordExists($word, &$k = null) : bool { - if($this->cfg->getAll()["censor"]["advanced-mode"]){ + if($this->cfg["censor"]["advanced-mode"]){ foreach($this->words->getAll() as $key => $value){ if(strpos($word, $key) !== false){ $k = $key; @@ -172,7 +154,7 @@ public function wordExists($word, &$k = null) : bool { return false; } $k = $word; - return isset($this->words->getAll()[$word]); + return $this->words->exists($word); } /** @@ -279,21 +261,7 @@ public function getMessage($id){ return $this->messages->get($id); } } - - /** - * Reload ChatCensor messages - */ - public function reloadMessages(){ - $this->messages->reload(); - } - - /** - * Reload words configuration - */ - public function reloadWords(){ - $this->words->reload(); - } - + /** * Replace variables inside a string * diff --git a/src/ChatCensor/Commands/AddWord.php b/src/ChatCensor/Commands/AddWord.php index b1aae27..98ecac8 100644 --- a/src/ChatCensor/Commands/AddWord.php +++ b/src/ChatCensor/Commands/AddWord.php @@ -1,24 +1,27 @@ plugin = $plugin; @@ -28,18 +31,17 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar if($sender->hasPermission("chatcensor.commands.addword")){ if(isset($args[0])){ $args[0] = strtolower($args[0]); - //Check if word exists if($this->plugin->wordExists($args[0])){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cWord already added.")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cWord already added.")); }else{ $this->plugin->addWord($args[0]); - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&aWord added!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &aWord added!")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cUsage: /addword ")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cUsage: /addword ")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); } return true; } diff --git a/src/ChatCensor/Commands/Commands.php b/src/ChatCensor/Commands/Commands.php index dda3e90..762890a 100644 --- a/src/ChatCensor/Commands/Commands.php +++ b/src/ChatCensor/Commands/Commands.php @@ -1,24 +1,27 @@ plugin = $plugin; @@ -32,47 +35,44 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar goto help; case "info": if($sender->hasPermission("chatcensor.commands.info")){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&eChatCensor &av" . $this->plugin->getDescription()->getVersion() . "&e developed by &aEvolSoft")); - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&eWebsite &a" . $this->plugin->getDescription()->getWebsite())); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &eChatCensor &av" . $this->plugin->getDescription()->getVersion() . "&e developed by &aEvolSoft")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &eWebsite &a" . $this->plugin->getDescription()->getWebsite())); break; } - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); break; case "reload": if($sender->hasPermission("chatcensor.commands.reload")){ - $this->plugin->reloadConfig(); - $this->plugin->muted->reload(); - $this->plugin->reloadWords(); - $this->plugin->reloadMessages(); - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&aConfiguration Reloaded.")); + $this->plugin->reload(); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &aConfiguration Reloaded.")); break; } - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); break; default: if($sender->hasPermission("chatcensor")){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cSubcommand &a" . $args[0] . " &cnot found. Use &a/cc help &cto show available commands.")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cSubcommand &a" . $args[0] . " &cnot found. Use &a/cc help &cto show available commands.")); break; } - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); break; } return true; }else{ help: if($sender->hasPermission("chatcensor.commands.help")){ - $sender->sendMessage($this->plugin->translateColors("&", "&c== &eAvailable Commands &c==")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/cc info &c->&e Show info about this plugin")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/cc help &c->&e Show help about this plugin")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/cc reload &c->&e Reload the config")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/addword &c->&e Add a censored word")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/removeword &c->&e Remove a censored word")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/mute &c->&e Mute a player")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/unmute &c->&e Unmute a player")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/listmuted &c->&e Get the list of muted players")); + $sender->sendMessage(TextFormat::colorize(" &c== &eAvailable Commands &c==")); + $sender->sendMessage(TextFormat::colorize(" &a/cc info &c->&e Show info about this plugin")); + $sender->sendMessage(TextFormat::colorize(" &a/cc help &c->&e Show help about this plugin")); + $sender->sendMessage(TextFormat::colorize(" &a/cc reload &c->&e Reload the config")); + $sender->sendMessage(TextFormat::colorize(" &a/addword &c->&e Add a censored word")); + $sender->sendMessage(TextFormat::colorize(" &a/removeword &c->&e Remove a censored word")); + $sender->sendMessage(TextFormat::colorize(" &a/mute &c->&e Mute a player")); + $sender->sendMessage(TextFormat::colorize(" &a/unmute &c->&e Unmute a player")); + $sender->sendMessage(TextFormat::colorize(" &a/listmuted &c->&e Get the list of muted players")); return true; } - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); return true; } } diff --git a/src/ChatCensor/Commands/ListMuted.php b/src/ChatCensor/Commands/ListMuted.php index a46024a..6de9f09 100644 --- a/src/ChatCensor/Commands/ListMuted.php +++ b/src/ChatCensor/Commands/ListMuted.php @@ -1,24 +1,27 @@ plugin = $plugin; @@ -27,17 +30,17 @@ public function __construct(ChatCensor $plugin){ public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) : bool { if($sender->hasPermission("chatcensor.commands.listmuted")){ $mlist = $this->plugin->muted->getAll(); - $sender->sendMessage($this->plugin->translateColors("&", "&bMuted players:")); + $sender->sendMessage(TextFormat::colorize("&bMuted players:")); foreach($mlist as $muted => $time){ if($this->plugin->isMuted($muted)){ - $sender->sendMessage($this->plugin->translateColors("&", "&a" . $muted . "&e (expires after " . $this->plugin->formatInterval($time) . ")")); + $sender->sendMessage(TextFormat::colorize("&a" . $muted . "&e (expires after " . $this->plugin->formatInterval($time) . ")")); } } if(($mlist = $this->plugin->muted->getAll()) == null){ - $sender->sendMessage($this->plugin->translateColors("&", "&aNo players are muted.")); + $sender->sendMessage(TextFormat::colorize("&aNo players are muted.")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); } return true; } diff --git a/src/ChatCensor/Commands/Mute.php b/src/ChatCensor/Commands/Mute.php index de5ec25..c647e19 100644 --- a/src/ChatCensor/Commands/Mute.php +++ b/src/ChatCensor/Commands/Mute.php @@ -1,25 +1,28 @@ plugin = $plugin; } @@ -31,34 +34,34 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar if($this->plugin->getServer()->getPlayer($args[0]) != null){ $player = $args[0]; if($this->plugin->isMuted($player)){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cPlayer " . $player . " is already muted!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cPlayer " . $player . " is already muted!")); return true; } $time = $args; unset($time[0]); $time = implode($time); if($time == null){ - $time = $this->plugin->cfg->getAll()["mute"]["time"]; + $time = $this->plugin->cfg["mute"]["time"]; } $time = strtr($time, array("s" => "second", "m" => "minute", "h" => "hour", "d" => "day", "mth" => "month", "y" => "year")); $time = strtotime($time); if($time === false){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cInvalid duration specified.")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cInvalid duration specified.")); return true; }else if($this->plugin->mutePlayer($player, $time)){ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&aYou muted &b" . $player . "&a for &b" . $this->plugin->formatInterval($time) . "&a.")); - if($this->plugin->cfg->getAll()["mute"]["log-mute"]){ - $this->plugin->getServer()->getPlayer($player)->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("muted"), array("PREFIX" => ChatCensor::PREFIX, "PLAYER" => $sender->getName(), "DURATION" => $this->plugin->formatInterval($time))))); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &aYou muted &b" . $player . "&a for &b" . $this->plugin->formatInterval($time) . "&a.")); + if($this->plugin->cfg["mute"]["log-mute"]){ + $this->plugin->getServer()->getPlayer($player)->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("muted"), array("PREFIX" => ChatCensor::PREFIX, "PLAYER" => $sender->getName(), "DURATION" => $this->plugin->formatInterval($time))))); } } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cPlayer not found!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cPlayer not found!")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cUsage: /mute [duration]")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cUsage: /mute [duration]")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); } return true; } diff --git a/src/ChatCensor/Commands/RemoveWord.php b/src/ChatCensor/Commands/RemoveWord.php index 58f93e1..0471ff7 100644 --- a/src/ChatCensor/Commands/RemoveWord.php +++ b/src/ChatCensor/Commands/RemoveWord.php @@ -1,24 +1,27 @@ plugin = $plugin; @@ -28,18 +31,17 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar if($sender->hasPermission("chatcensor.commands.removeword")){ if(isset($args[0])){ $args[0] = strtolower($args[0]); - //Check if word exists if($this->plugin->wordExists($args[0])){ $this->plugin->removeWord($args[0]); - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&aWord removed!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &aWord removed!")); }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cWord not found.")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cWord not found.")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cUsage: /removeword ")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cUsage: /removeword ")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); } return true; } diff --git a/src/ChatCensor/Commands/Unmute.php b/src/ChatCensor/Commands/Unmute.php index 1aceba4..d6c9611 100644 --- a/src/ChatCensor/Commands/Unmute.php +++ b/src/ChatCensor/Commands/Unmute.php @@ -1,24 +1,27 @@ plugin = $plugin; @@ -28,28 +31,25 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar if($sender->hasPermission("chatcensor.commands.unmute")){ if(isset($args[0])){ $args[0] = strtolower($args[0]); - //Check if player exists if($this->plugin->getServer()->getPlayer($args[0]) != null){ $player = $args[0]; - //Check if player is already muted if($this->plugin->isMuted($player)){ $this->plugin->unmutePlayer($player); - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&aYou unmuted &b" . $player)); - //Check if log unmute is enabled - if($this->plugin->getConfig()->getAll()["mute"]["log-unmute"]){ - $this->plugin->getServer()->getPlayer($player)->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("unmuted"), array("PREFIX" => ChatCensor::PREFIX, "PLAYER" => $sender->getName())))); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &aYou unmuted &b" . $player)); + if($this->plugin->cfg["mute"]["log-unmute"]){ + $this->plugin->getServer()->getPlayer($player)->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("unmuted"), array("PREFIX" => ChatCensor::PREFIX, "PLAYER" => $sender->getName())))); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cPlayer " . $player . " is not muted!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cPlayer " . $player . " is not muted!")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cPlayer not found!")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cPlayer not found!")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ChatCensor::PREFIX . "&cUsage: /unmute ")); + $sender->sendMessage(TextFormat::colorize(ChatCensor::PREFIX . " &cUsage: /unmute ")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); + $sender->sendMessage(TextFormat::colorize("&cYou don't have permissions to use this command")); } return true; } diff --git a/src/ChatCensor/EventListener.php b/src/ChatCensor/EventListener.php index 6833b4b..e44a6a3 100644 --- a/src/ChatCensor/EventListener.php +++ b/src/ChatCensor/EventListener.php @@ -1,11 +1,10 @@ plugin = $plugin; - } + + public function __construct(ChatCensor $plugin){ + $this->plugin = $plugin; + } /** * @param PlayerCommandPreprocessEvent $event @@ -31,7 +33,7 @@ public function __construct(ChatCensor $plugin){ public function onChat(PlayerCommandPreprocessEvent $event){ $message = $event->getMessage(); $player = $event->getPlayer(); - $cfg = $this->plugin->getConfig()->getAll(); + $cfg = $this->plugin->cfg; //Check if this is a command and skip if check-commands is disabled if($message[0] == "/" && !$cfg["censor"]["check-commands"]){ return; @@ -39,7 +41,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ //Check if player is muted if($this->plugin->isMuted(strtolower($player->getName())) && $message[0] != "/"){ if($cfg["mute"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("muted-error"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("muted-error"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -52,7 +54,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ if(preg_match('/[A-Z]/', $message)){ if($cfg["anti-caps"]["block-message"]){ if($cfg["anti-caps"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("no-caps"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("no-caps"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -70,16 +72,17 @@ public function onChat(PlayerCommandPreprocessEvent $event){ if($cfg["anti-spam"]["mode"] == 0 || $cfg["anti-spam"]["mode"] == 2){ if(strcasecmp($message, $this->lastmessage[$player->getName()]["message"]) == 0){ if($cfg["anti-spam"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("no-spam"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("no-spam"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; } } if($cfg["anti-spam"]["mode"] == 1 || $cfg["anti-spam"]["mode"] == 2){ - if(time() - $this->lastmessage[$player->getName()]["time"] <= $cfg["anti-spam"]["delay"]){ + $t = time() - $this->lastmessage[$player->getName()]["time"]; + if($t < $cfg["anti-spam"]["delay"]){ if($cfg["anti-spam"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("spam-delay"), array("PREFIX" => ChatCensor::PREFIX, "DELAY" => time() - $this->lastmessage[$player->getName()]["time"])))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("spam-delay"), array("PREFIX" => ChatCensor::PREFIX, "DELAY" => $cfg["anti-spam"]["delay"] - $t)))); } $event->setCancelled(true); return; @@ -97,7 +100,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ //Check message length if($cfg["char-check"]["max-length"] > 0 && strlen($message) > $cfg["char-check"]["max-length"]){ if($cfg["char-check"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("too-long"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("too-long"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -106,7 +109,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ if(!$cfg["char-check"]["allow-backslash"]){ if((bool) strpbrk($message, "\\")){ if($cfg["char-check"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -117,7 +120,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ if($unallowed != ""){ if((bool) strpbrk($message, $unallowed)){ if($cfg["char-check"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -132,7 +135,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ foreach($messagearray as $word){ if(!in_array($word, $allowedchr)){ if($cfg["char-check"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("invalid"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -152,7 +155,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ //Check if websites are blocked if($cfg["censor"]["block-urls"] && preg_match("/\w+(\s+)?\.(\s+)?\w+(\s+)?\.(\s+)?\w+/i", $message)){ if($cfg["censor"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("no-urls"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("no-urls"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -162,7 +165,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ //Check if IP addresses are blocked if($cfg["censor"]["block-ips"] && (filter_var($word, FILTER_VALIDATE_IP) != false)){ if($cfg["censor"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("no-ips"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("no-ips"), array("PREFIX" => ChatCensor::PREFIX)))); } $event->setCancelled(true); return; @@ -178,7 +181,7 @@ public function onChat(PlayerCommandPreprocessEvent $event){ $tempmessage = str_replace($key, $replace, $tempmessage); } if($cfg["censor"]["log-to-player"]){ - $player->sendMessage($this->plugin->translateColors("&", $this->plugin->replaceVars($this->plugin->getMessage("no-swearing"), array("PREFIX" => ChatCensor::PREFIX)))); + $player->sendMessage(TextFormat::colorize($this->plugin->replaceVars($this->plugin->getMessage("no-swearing"), array("PREFIX" => ChatCensor::PREFIX)))); } foreach($tmp["commands"] as $cmd){ $cmd = $this->plugin->replaceVars($cmd, array("PLAYER" => $player->getName()));