Skip to content

Commit

Permalink
Updated to PocketMine-MP API 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavius12 committed Jul 6, 2018
1 parent 76ab2d8 commit ab09bef
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 138 deletions.
2 changes: 1 addition & 1 deletion CustomAlerts/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CustomAlerts
main: CustomAlerts\CustomAlerts
version: 1.9
version: 2.0
api: [3.0.0]
load: STARTUP
author: EvolSoft
Expand Down
34 changes: 16 additions & 18 deletions CustomAlerts/src/CustomAlerts/Commands/Commands.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand All @@ -15,8 +14,7 @@
use pocketmine\command\PluginCommand;
use pocketmine\command\CommandExecutor;
use pocketmine\command\CommandSender;
use pocketmine\plugin\PluginBase;
use pocketmine\plugin\Plugin;
use pocketmine\utils\TextFormat;

use CustomAlerts\CustomAlerts;

Expand All @@ -34,39 +32,39 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar
goto help;
case "info":
if($sender->hasPermission("customalerts.info")){
$sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aCustomAlerts &dv" . $this->plugin->getDescription()->getVersion() . "&a developed by &dEvolSoft"));
$sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aWebsite &d" . $this->plugin->getDescription()->getWebsite()));
$sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&aCustomAlerts &dv" . $this->plugin->getDescription()->getVersion() . "&a developed by &dEvolSoft"));
$sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&aWebsite &d" . $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("customalerts.reload")){
$this->plugin->reloadConfig();
$this->plugin->cfg = $this->plugin->getConfig()->getAll();
$sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aConfiguration Reloaded."));
$sender->sendMessage(TextFormat::colorize(CustomAlerts::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("customalerts")){
$sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&cSubcommand &a" . $args[0] . " &cnot found. Use &a/calerts help &cto show available commands"));
$sender->sendMessage(TextFormat::colorize(CustomAlerts::PREFIX . "&cSubcommand &a" . $args[0] . " &cnot found. Use &a/calerts 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;
}
help:
if($sender->hasPermission("customalerts.help")){
$sender->sendMessage($this->plugin->translateColors("&", "&b-- &aAvailable Commands &b--"));
$sender->sendMessage($this->plugin->translateColors("&", "&d/calerts help &b-&a Show help about this plugin"));
$sender->sendMessage($this->plugin->translateColors("&", "&d/calerts info &b-&a Show info about this plugin"));
$sender->sendMessage($this->plugin->translateColors("&", "&d/calerts reload &b-&a Reload the config"));
$sender->sendMessage(TextFormat::colorize("&b-- &aAvailable Commands &b--"));
$sender->sendMessage(TextFormat::colorize("&d/calerts help &b-&a Show help about this plugin"));
$sender->sendMessage(TextFormat::colorize("&d/calerts info &b-&a Show info about this plugin"));
$sender->sendMessage(TextFormat::colorize("&d/calerts reload &b-&a Reload the config"));
}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;
}
Expand Down
79 changes: 21 additions & 58 deletions CustomAlerts/src/CustomAlerts/CustomAlerts.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:01 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

namespace CustomAlerts;

use pocketmine\entity\Living;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDeathEvent;
use pocketmine\level\Level;
use pocketmine\Player;

use pocketmine\Player;
use pocketmine\entity\Living;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\level\Level;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat;
use pocketmine\scheduler\Task;

use CustomAlerts\Commands\Commands;
use CustomAlerts\Events\CustomAlertsMotdUpdateEvent;

class CustomAlerts extends PluginBase {
Expand All @@ -36,41 +34,6 @@ class CustomAlerts extends PluginBase {
/** @var CustomAlerts $instance */
private static $instance = null;

/**
* Translate Minecraft colors
*
* @param string $symbol
* @param string $message
*
* @return string
*/
public function translateColors($symbol, $message){
$message = str_replace($symbol . "0", TextFormat::BLACK, $message);
$message = str_replace($symbol . "1", TextFormat::DARK_BLUE, $message);
$message = str_replace($symbol . "2", TextFormat::DARK_GREEN, $message);
$message = str_replace($symbol . "3", TextFormat::DARK_AQUA, $message);
$message = str_replace($symbol . "4", TextFormat::DARK_RED, $message);
$message = str_replace($symbol . "5", TextFormat::DARK_PURPLE, $message);
$message = str_replace($symbol . "6", TextFormat::GOLD, $message);
$message = str_replace($symbol . "7", TextFormat::GRAY, $message);
$message = str_replace($symbol . "8", TextFormat::DARK_GRAY, $message);
$message = str_replace($symbol . "9", TextFormat::BLUE, $message);
$message = str_replace($symbol . "a", TextFormat::GREEN, $message);
$message = str_replace($symbol . "b", TextFormat::AQUA, $message);
$message = str_replace($symbol . "c", TextFormat::RED, $message);
$message = str_replace($symbol . "d", TextFormat::LIGHT_PURPLE, $message);
$message = str_replace($symbol . "e", TextFormat::YELLOW, $message);
$message = str_replace($symbol . "f", TextFormat::WHITE, $message);

$message = str_replace($symbol . "k", TextFormat::OBFUSCATED, $message);
$message = str_replace($symbol . "l", TextFormat::BOLD, $message);
$message = str_replace($symbol . "m", TextFormat::STRIKETHROUGH, $message);
$message = str_replace($symbol . "n", TextFormat::UNDERLINE, $message);
$message = str_replace($symbol . "o", TextFormat::ITALIC, $message);
$message = str_replace($symbol . "r", TextFormat::RESET, $message);
return $message;
}

public function onLoad(){
if(!self::$instance instanceof CustomAlerts){
self::$instance = $this;
Expand All @@ -81,7 +44,7 @@ public function onEnable(){
@mkdir($this->getDataFolder());
$this->saveDefaultConfig();
$this->cfg = $this->getConfig()->getAll();
$this->getCommand("customalerts")->setExecutor(new Commands\Commands($this));
$this->getCommand("customalerts")->setExecutor(new Commands($this));
$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
$this->getScheduler()->scheduleRepeatingTask(new MotdTask($this), 20);
}
Expand Down Expand Up @@ -145,7 +108,7 @@ public function isMotdCustom() : bool {
* @return string
*/
public function getMotdMessage(){
return $this->translateColors("&", $this->replaceVars($this->cfg["Motd"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["Motd"]["message"], array(
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
"TIME" => date($this->cfg["datetime-format"]))));
Expand Down Expand Up @@ -179,7 +142,7 @@ public function isOutdatedClientMessageCustom() : bool {
* @return string
*/
public function getOutdatedClientMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["OutdatedClient"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["OutdatedClient"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand All @@ -203,7 +166,7 @@ public function isOutdatedServerMessageCustom() : bool {
* @return string
*/
public function getOutdatedServerMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["OutdatedServer"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["OutdatedServer"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand All @@ -227,7 +190,7 @@ public function isWhitelistMessageCustom() : bool {
* @return string
*/
public function getWhitelistMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["WhitelistedServer"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["WhitelistedServer"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand All @@ -252,7 +215,7 @@ public function isFullServerMessageCustom() : bool {
* @return string
*/
public function getFullServerMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["FullServer"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["FullServer"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand All @@ -276,7 +239,7 @@ public function isFirstJoinMessageEnabled() : bool {
* @return string
*/
public function getFirstJoinMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["FirstJoin"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["FirstJoin"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand Down Expand Up @@ -309,7 +272,7 @@ public function isJoinMessageHidden() : bool {
* @return string
*/
public function getJoinMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["Join"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["Join"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand Down Expand Up @@ -342,7 +305,7 @@ public function isQuitMessageHidden(){
* @return string
*/
public function getQuitMessage(Player $player){
return $this->translateColors("&", $this->replaceVars($this->cfg["Quit"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["Quit"]["message"], array(
"PLAYER" => $player->getName(),
"MAXPLAYERS" => $this->getServer()->getMaxPlayers(),
"TOTALPLAYERS" => count($this->getServer()->getOnlinePlayers()),
Expand All @@ -368,7 +331,7 @@ public function isWorldChangeMessageEnabled(){
* @return string
*/
public function getWorldChangeMessage(Player $player, Level $origin, Level $target){
return $this->translateColors("&", $this->replaceVars($this->cfg["WorldChange"]["message"], array(
return TextFormat::colorize($this->replaceVars($this->cfg["WorldChange"]["message"], array(
"ORIGIN" => $origin->getName(),
"TARGET" => $target->getName(),
"PLAYER" => $player->getName(),
Expand Down Expand Up @@ -545,6 +508,6 @@ public function getDeathMessage(Player $player, EntityDamageEvent $cause = null)
break;
}
}
return $this->translateColors("&", $this->replaceVars($message, $array));
return TextFormat::colorize($this->replaceVars($message, $array));
}
}
7 changes: 3 additions & 4 deletions CustomAlerts/src/CustomAlerts/EventListener.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 27/04/2018 02:29 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
7 changes: 3 additions & 4 deletions CustomAlerts/src/CustomAlerts/Events/CustomAlertsEvent.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand All @@ -14,9 +13,6 @@
class CustomAlertsMotdUpdateEvent extends CustomAlertsEvent {

public static $handlerList = null;

/** @var string $pocketminemotd The default PocketMine motd message */
private $pocketminemessage;

public function __construct(){}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* CustomAlerts (v1.9) by EvolSoft
* Developer: EvolSoft (Flavius12)
* CustomAlerts v2.0 by EvolSoft
* Developer: Flavius12
* Website: https://www.evolsoft.tk
* Date: 13/01/2018 02:02 PM (UTC)
* Copyright & License: (C) 2014-2018 EvolSoft
* Copyright (C) 2014-2018 EvolSoft
* Licensed under MIT (https://github.com/EvolSoft/CustomAlerts/blob/master/LICENSE)
*/

Expand Down
Loading

0 comments on commit ab09bef

Please sign in to comment.