diff --git a/README.md b/README.md index 5d67256..5d47386 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 21c83f7..ebdf177 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: ServerChannels main: ServerChannels\ServerChannels -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 channelling plugin for PocketMine-MP diff --git a/src/ServerChannels/Commands/Commands.php b/src/ServerChannels/Commands/Commands.php index df3bea0..892105a 100644 --- a/src/ServerChannels/Commands/Commands.php +++ b/src/ServerChannels/Commands/Commands.php @@ -14,12 +14,13 @@ use pocketmine\command\Command; use pocketmine\command\CommandExecutor; use pocketmine\command\CommandSender; +use pocketmine\command\PluginCommand; use pocketmine\Player; -use pocketmine\plugin\PluginBase; +use pocketmine\utils\TextFormat; use ServerChannels\ServerChannels; -class Commands extends PluginBase implements CommandExecutor { +class Commands extends PluginCommand implements CommandExecutor { /** @var ServerChannels */ private $plugin; @@ -37,23 +38,23 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar if($sender->hasPermission("serverchannels.commands.create")){ if(isset($args[1])){ $this->plugin->createChannel($args[1]); - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&aChannel &b" . strtolower($args[1]) . "&a created!")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&aChannel &b" . strtolower($args[1]) . "&a created!")); }else{ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cUsage: /sch create ")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cUsage: /sch create ")); } 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 "help": goto help; case "info": if($sender->hasPermission("serverchannels.commands.info")){ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&eServerChannels &bv" . $this->plugin->getVersion() . "&e developed by &bEvolSoft")); - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&eWebsite &b" . $this->plugin->getDescription()->getWebsite())); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&eServerChannels &bv" . $this->plugin->getVersion() . "&e developed by &bEvolSoft")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&eWebsite &b" . $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 "join": if($sender instanceof Player){ @@ -63,35 +64,35 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar $cmessage = null; switch($this->plugin->joinChannel($sender, $args[1], isset($args[2]) ? $args[2] : null, $cmessage)){ case ServerChannels::SUCCESS: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&aYou joined &b" . strtolower($args[1]) . "&a channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&aYou joined &b" . strtolower($args[1]) . "&a channel")); break; case ServerChannels::ERR_WRONG_PASS: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cWrong password")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cWrong password")); break; case ServerChannels::ERR_NOT_WHITELISTED: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cYou are not whitelisted on this channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cYou are not whitelisted on this channel")); break; case ServerChannels::ERR_CHANNEL_NOT_FOUND: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cChannel not found")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cChannel not found")); break; case ServerChannels::CANCELLED: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . $cmessage)); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . $cmessage)); break; default: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cAn error has occurred while joining the channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cAn error has occurred while joining the channel")); break; } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cYou don't have permissions to join in this channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cYou don't have permissions to join in this channel")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cUsage: /sch join [password]")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cUsage: /sch join [password]")); } }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")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cYou can only perform this command as a player")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cYou can only perform this command as a player")); } break; case "leave": @@ -101,67 +102,67 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar $cmessage = null; switch($this->plugin->leaveChannel($sender, $cmessage)){ case ServerChannels::SUCCESS: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&aYou left &b" . $channel . "&a channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&aYou left &b" . $channel . "&a channel")); break; case ServerChannels::ERR_NO_CHANNEL: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cYou haven't joined on a channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cYou haven't joined on a channel")); break; case ServerChannels::CANCELLED: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . $cmessage)); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . $cmessage)); break; default: - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cAn error has occurred while leaving the channel")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cAn error has occurred while leaving the channel")); break; } }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")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cYou can only perform this command as a player")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cYou can only perform this command as a player")); } break; case "list": if($sender->hasPermission("serverchannels.commands.list")){ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&b>> &aAvailable Channels &b<<")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&b>> &aAvailable Channels &b<<")); foreach($this->plugin->getAllChannels() as $k => $v){ if($sender->hasPermission(strtolower("serverchannels.channels." . $k))){ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&b- &a" . $k)); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&b- &a" . $k)); } } 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("serverchannels.commands.reload")){ $this->plugin->reload(); - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&aConfiguration reloaded")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::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("serverchannels")){ - $sender->sendMessage($this->plugin->translateColors("&", ServerChannels::PREFIX . "&cSubcommand &a" . $args[0] . "&c not found. Use &a/sch help&c to show available commands")); + $sender->sendMessage(TextFormat::colorize(ServerChannels::PREFIX . "&cSubcommand &a" . $args[0] . "&c not found. Use &a/sch help&c to 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; } }else{ help: if($sender->hasPermission("serverchannels.commands.help")){ - $sender->sendMessage($this->plugin->translateColors("&", "&b>> &aAvailable Commands &b<<")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch info &b>>&e Show info about this plugin")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch help &b>>&e Show help about this plugin")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch reload &b>>&e Reload the config")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch create &b>>&e Create new channel")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch list &b>>&e Show the list of all channels")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch join &b>>&e Join a channel")); - $sender->sendMessage($this->plugin->translateColors("&", "&a/sch leave &b>>&e Leave the current channel")); + $sender->sendMessage(TextFormat::colorize("&b>> &aAvailable Commands &b<<")); + $sender->sendMessage(TextFormat::colorize("&a/sch info &b>>&e Show info about this plugin")); + $sender->sendMessage(TextFormat::colorize("&a/sch help &b>>&e Show help about this plugin")); + $sender->sendMessage(TextFormat::colorize("&a/sch reload &b>>&e Reload the config")); + $sender->sendMessage(TextFormat::colorize("&a/sch create &b>>&e Create new channel")); + $sender->sendMessage(TextFormat::colorize("&a/sch list &b>>&e Show the list of all channels")); + $sender->sendMessage(TextFormat::colorize("&a/sch join &b>>&e Join a channel")); + $sender->sendMessage(TextFormat::colorize("&a/sch leave &b>>&e Leave the current channel")); }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/ServerChannels/EventListener.php b/src/ServerChannels/EventListener.php index 936de4d..654587d 100644 --- a/src/ServerChannels/EventListener.php +++ b/src/ServerChannels/EventListener.php @@ -1,11 +1,10 @@ getAllChannels() as $k => $v){ $permission = new Permission("serverchannels.channels." . strtolower($k), "ServerChannels " . $k . " channel permission."); - Server::getInstance()->getPluginManager()->addPermission($permission); + $this->getServer()->getPluginManager()->addPermission($permission); } } @@ -544,7 +508,7 @@ public function sendChannelMessage(Player $player, $channel, $message, &$cmessag $cmessage = $scevent->getCancelledMessage(); return self::CANCELLED; } - $message = $this->translateColors("&", $this->formatChannelMessage($channel, $player, $scevent->getMessage())); + $message = TextFormat::colorize($this->formatChannelMessage($channel, $player, $scevent->getMessage())); if($this->isChannelHidden($channel)){ foreach($this->getChannelPlayers($channel) as $cp){ $cp->sendMessage($message); @@ -555,7 +519,7 @@ public function sendChannelMessage(Player $player, $channel, $message, &$cmessag } } if($this->getLogOnConsole()){ - Server::getInstance()->getLogger()->info($message); + $this->getServer()->getLogger()->info($message); } } return self::SUCCESS;