diff --git a/README.md b/README.md index 8070c5a..6cf8abc 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 9d1a58c..5feca01 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Broadcaster main: Broadcaster\Broadcaster -version: 1.4 -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: 1.5 +api: [3.0.0] load: STARTUP author: EvolSoft description: Advanced Broadcasting plugin diff --git a/src/Broadcaster/Broadcaster.php b/src/Broadcaster/Broadcaster.php index 2ca6a43..b765d77 100644 --- a/src/Broadcaster/Broadcaster.php +++ b/src/Broadcaster/Broadcaster.php @@ -1,16 +1,14 @@ cfg["message-broadcast"]["enabled"]){ $mtime = intval($this->cfg["message-broadcast"]["time"]) * 20; - $this->mtask = $this->getServer()->getScheduler()->scheduleRepeatingTask(new Tasks\MessageTask($this), $mtime); + $this->mtask = $this->getScheduler()->scheduleRepeatingTask(new Tasks\MessageTask($this), $mtime); } if($this->cfg["popup-broadcast"]["enabled"]){ $ptime = intval($this->cfg["popup-broadcast"]["time"]) * 20; - $this->ptask = $this->getServer()->getScheduler()->scheduleRepeatingTask(new Tasks\PopupTask($this), $ptime); + $this->ptask = $this->getScheduler()->scheduleRepeatingTask(new Tasks\PopupTask($this), $ptime); } if($this->cfg["title-broadcast"]["enabled"]){ $ttime = intval($this->cfg["title-broadcast"]["time"]) * 20; - $this->ttask = $this->getServer()->getScheduler()->scheduleRepeatingTask(new Tasks\TitleTask($this), $ttime); + $this->ttask = $this->getScheduler()->scheduleRepeatingTask(new Tasks\TitleTask($this), $ttime); } } @@ -228,11 +191,11 @@ public function broadcast(int $type, $sender, $message, Player $recipient = null default: case self::TYPE_MESSAGE: if($recipient){ - $recipient->sendMessage($this->translateColors("&", $msg)); + $recipient->sendMessage(TextFormat::colorize($msg)); return; } foreach($this->getServer()->getOnlinePlayers() as $player){ - $player->sendMessage($this->translateColors("&", str_replace("{PLAYER}", $player->getName(), $msg))); + $player->sendMessage(TextFormat::colorize(str_replace("{PLAYER}", $player->getName(), $msg))); } return; case self::TYPE_POPUP: @@ -241,13 +204,13 @@ public function broadcast(int $type, $sender, $message, Player $recipient = null case self::TYPE_TITLE: if($recipient){ $msg = explode("{SUBTITLE}", $msg); - $recipient->addTitle($this->translateColors("&", $msg[0]), isset($msg[1]) ? $this->translateColors("&", $msg[1]) : ""); + $recipient->addTitle(TextFormat::colorize($msg[0]), isset($msg[1]) ? TextFormat::colorize($msg[1]) : ""); return; } foreach($this->getServer()->getOnlinePlayers() as $player){ $out = str_replace("{PLAYER}", $player->getName(), $msg); $out = explode("{SUBTITLE}", $out); - $player->addTitle($this->translateColors("&", $out[0]), isset($out[1]) ? $this->translateColors("&", $out[1]) : ""); + $player->addTitle(TextFormat::colorize($out[0]), isset($out[1]) ? TextFormat::colorize($out[1]) : ""); } return; } diff --git a/src/Broadcaster/Commands/Commands.php b/src/Broadcaster/Commands/Commands.php index a472c76..10fe758 100644 --- a/src/Broadcaster/Commands/Commands.php +++ b/src/Broadcaster/Commands/Commands.php @@ -1,11 +1,10 @@ hasPermission("broadcaster.info")){ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&2Broadcaster &9v" . $this->plugin->getDescription()->getVersion() . "&2 developed by &9EvolSoft")); - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&2Website &9" . $this->plugin->getDescription()->getWebsite())); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&2Broadcaster &9v" . $this->plugin->getDescription()->getVersion() . "&2 developed by &9EvolSoft")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&2Website &9" . $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 "help": goto help; case "reload": if($sender->hasPermission("broadcaster.reload")){ $this->plugin->reload(); - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&aConfiguration reloaded")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::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("broadcaster")){ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cSubcommand &9" . $args[0] . "&c not found. Use &9/bc &cto show available commands")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cSubcommand &9" . $args[0] . "&c not found. Use &9/bc &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; } help: if($sender->hasPermission("broadcaster")){ - $sender->sendMessage($this->plugin->translateColors("&", "&2- &9Available Commands &2-")); - $sender->sendMessage($this->plugin->translateColors("&", "&9/bc info &2- &9Show info about this plugin")); - $sender->sendMessage($this->plugin->translateColors("&", "&9/bc reload &2- &9Reload the config")); - $sender->sendMessage($this->plugin->translateColors("&", "&9/sendmessage &2- &9Send message to the specified player (* for all players)")); - $sender->sendMessage($this->plugin->translateColors("&", "&9/sendpopup &2- &9Send popup to the specified player (* for all players)")); - $sender->sendMessage($this->plugin->translateColors("&", "&9/sendtitle &2- &9Send title to the specified player (* for all players)")); + $sender->sendMessage(TextFormat::colorize("&2- &9Available Commands &2-")); + $sender->sendMessage(TextFormat::colorize("&9/bc info &2- &9Show info about this plugin")); + $sender->sendMessage(TextFormat::colorize("&9/bc reload &2- &9Reload the config")); + $sender->sendMessage(TextFormat::colorize("&9/sendmessage &2- &9Send message to the specified player (* for all players)")); + $sender->sendMessage(TextFormat::colorize("&9/sendpopup &2- &9Send popup to the specified player (* for all players)")); + $sender->sendMessage(TextFormat::colorize("&9/sendtitle &2- &9Send title to the specified player (* for all players)")); }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/Broadcaster/Commands/SendMessage.php b/src/Broadcaster/Commands/SendMessage.php index 97ffa00..1e654ce 100644 --- a/src/Broadcaster/Commands/SendMessage.php +++ b/src/Broadcaster/Commands/SendMessage.php @@ -1,11 +1,10 @@ plugin->getServer()->getPlayerExact($args[0]))){ $this->plugin->broadcast(Broadcaster::TYPE_MESSAGE, $sender->getName(), $this->plugin->getMessagefromArray($args), $player); }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cPlayer not found")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cPlayer not found")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cUsage: /sm ")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cUsage: /sm ")); } }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/Broadcaster/Commands/SendPopup.php b/src/Broadcaster/Commands/SendPopup.php index 0ae8340..ed4ec29 100644 --- a/src/Broadcaster/Commands/SendPopup.php +++ b/src/Broadcaster/Commands/SendPopup.php @@ -1,11 +1,10 @@ plugin->getServer()->getPlayerExact($args[0]))){ $this->plugin->broadcast(Broadcaster::TYPE_POPUP, $sender->getName(), $this->plugin->getMessagefromArray($args), $player); }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cPlayer not found")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cPlayer not found")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cUsage: /sp ")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cUsage: /sp ")); } }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/Broadcaster/Commands/SendTitle.php b/src/Broadcaster/Commands/SendTitle.php index dcef6b5..7cf2344 100644 --- a/src/Broadcaster/Commands/SendTitle.php +++ b/src/Broadcaster/Commands/SendTitle.php @@ -1,11 +1,10 @@ plugin->getServer()->getPlayerExact($args[0]))){ $this->plugin->broadcast(Broadcaster::TYPE_TITLE, $sender->getName(), $this->plugin->getMessagefromArray($args), $player); }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cPlayer not found")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cPlayer not found")); } }else{ - $sender->sendMessage($this->plugin->translateColors("&", Broadcaster::PREFIX . "&cUsage: /st ")); + $sender->sendMessage(TextFormat::colorize(Broadcaster::PREFIX . "&cUsage: /st ")); } }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/Broadcaster/Tasks/MessageTask.php b/src/Broadcaster/Tasks/MessageTask.php index 3d9c005..ae65978 100644 --- a/src/Broadcaster/Tasks/MessageTask.php +++ b/src/Broadcaster/Tasks/MessageTask.php @@ -1,36 +1,38 @@ plugin = $plugin; $this->i = 0; } public function onRun(int $currentTick){ - $plugin = $this->getOwner(); - $messages = $plugin->cfg["message-broadcast"]["messages"]; + $messages = $this->plugin->cfg["message-broadcast"]["messages"]; back: if($this->i < count($messages)){ - $plugin->getServer()->broadcastMessage($plugin->translateColors("&", $plugin->formatMessage($messages[$this->i]))); + $this->plugin->getServer()->broadcastMessage(TextFormat::colorize($this->plugin->formatMessage($messages[$this->i]))); $this->i++; }else{ $this->i = 0; diff --git a/src/Broadcaster/Tasks/PopupDurationTask.php b/src/Broadcaster/Tasks/PopupDurationTask.php index 8ebf17b..2c24df7 100644 --- a/src/Broadcaster/Tasks/PopupDurationTask.php +++ b/src/Broadcaster/Tasks/PopupDurationTask.php @@ -1,22 +1,25 @@ plugin = $plugin; $this->message = $message; $this->player = $player; $this->duration = $duration; } public function onRun(int $tick){ - $plugin = $this->getOwner(); for($i = 0; $i < $this->duration * 10; $i++){ if($this->player){ - $this->player->sendPopup($plugin->translateColors("&", $this->message)); + $this->player->sendPopup(TextFormat::colorize($this->message)); }else{ - $plugin->getServer()->broadcastPopup($plugin->translateColors("&", $this->message)); + $this->plugin->getServer()->broadcastPopup(TextFormat::colorize($this->message)); } } - $plugin->getServer()->getScheduler()->cancelTask($this->getTaskId()); + $this->getHandler()->cancel(); } } \ No newline at end of file diff --git a/src/Broadcaster/Tasks/PopupTask.php b/src/Broadcaster/Tasks/PopupTask.php index e5fa329..394891b 100644 --- a/src/Broadcaster/Tasks/PopupTask.php +++ b/src/Broadcaster/Tasks/PopupTask.php @@ -1,36 +1,37 @@ plugin = $plugin; $this->i = 0; } public function onRun(int $currentTick){ - $plugin = $this->getOwner(); - $messages = $plugin->cfg["popup-broadcast"]["messages"]; + $messages = $this->plugin->cfg["popup-broadcast"]["messages"]; back: if($this->i < count($messages)){ - $plugin->getServer()->getScheduler()->scheduleTask(new PopupDurationTask($plugin, $plugin->formatMessage($messages[$this->i]), null, $plugin->cfg["popup-broadcast"]["duration"])); + $this->plugin->getScheduler()->scheduleTask(new PopupDurationTask($this->plugin, $this->plugin->formatMessage($messages[$this->i]), null, $this->plugin->cfg["popup-broadcast"]["duration"])); $this->i++; }else{ $this->i = 0; diff --git a/src/Broadcaster/Tasks/TitleTask.php b/src/Broadcaster/Tasks/TitleTask.php index 951d76d..c037d57 100644 --- a/src/Broadcaster/Tasks/TitleTask.php +++ b/src/Broadcaster/Tasks/TitleTask.php @@ -1,37 +1,39 @@ plugin = $plugin; $this->i = 0; } public function onRun(int $currentTick){ - $plugin = $this->getOwner(); - $messages = $plugin->cfg["title-broadcast"]["messages"]; + $messages = $this->plugin->cfg["title-broadcast"]["messages"]; back: if($this->i < count($messages)){ $msg = explode("{SUBTITLE}", $messages[$this->i]); - $plugin->getServer()->broadcastTitle($plugin->translateColors("&", $plugin->formatMessage($msg[0])), isset($msg[1]) ? $plugin->translateColors("&", $plugin->formatMessage($msg[1])) : ""); + $this->plugin->getServer()->broadcastTitle(TextFormat::colorize($this->plugin->formatMessage($msg[0])), isset($msg[1]) ? TextFormat::colorize($this->plugin->formatMessage($msg[1])) : ""); $this->i++; }else{ $this->i = 0;