From f935d0bf8281d9a890abbb65a9ef1c742741070f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?= Date: Wed, 13 Aug 2014 22:13:38 -0500 Subject: [PATCH] Tons of changes! Beta 1, here we go! --- .gitignore | 8 +- plugin.yml | 372 ++++++++++-------- resources/config.yml | 8 + src/EssentialsPE/Commands/AFK.php | 76 ++++ src/EssentialsPE/Commands/Broadcast.php | 5 +- src/EssentialsPE/Commands/Burn.php | 2 +- src/EssentialsPE/Commands/ClearInventory.php | 4 +- src/EssentialsPE/Commands/Compass.php | 2 +- src/EssentialsPE/Commands/Essentials.php | 5 +- src/EssentialsPE/Commands/Extinguish.php | 4 +- src/EssentialsPE/Commands/GetPos.php | 4 +- src/EssentialsPE/Commands/God.php | 4 +- src/EssentialsPE/Commands/Heal.php | 4 +- src/EssentialsPE/Commands/Item.php | 2 +- src/EssentialsPE/Commands/Jump.php | 2 +- src/EssentialsPE/Commands/KickAll.php | 5 +- src/EssentialsPE/Commands/More.php | 15 +- src/EssentialsPE/Commands/Mute.php | 4 +- src/EssentialsPE/Commands/Nick.php | 4 +- .../Commands/PowerTool/PowerTool.php | 66 +++- .../Commands/PowerTool/PowerToolToggle.php | 2 +- src/EssentialsPE/Commands/PvP.php | 2 +- src/EssentialsPE/Commands/RealName.php | 2 +- src/EssentialsPE/Commands/Repair.php | 69 +++- src/EssentialsPE/Commands/Seen.php | 7 +- src/EssentialsPE/Commands/SetSpawn.php | 5 +- src/EssentialsPE/Commands/TempBan.php | 4 +- src/EssentialsPE/Commands/Top.php | 2 +- src/EssentialsPE/Commands/Unlimited.php | 65 +++ src/EssentialsPE/Commands/Vanish.php | 2 +- .../Commands/Warps/RemoveWarp.php | 2 +- src/EssentialsPE/Commands/Warps/SetWarp.php | 2 +- src/EssentialsPE/Commands/Warps/Warp.php | 2 +- src/EssentialsPE/Events/EventHandler.php | 75 +++- .../Events/PlayerAFKModeChangeEvent.php | 70 ++++ .../Events/PlayerGodModeChangeEvent.php | 70 ++++ .../Events/PlayerNickChangeEvent.php | 4 +- .../Events/PlayerUnlimitedModeChangeEvent.php | 72 ++++ src/EssentialsPE/Events/PlayerVanishEvent.php | 2 + src/EssentialsPE/Loader.php | 285 +++++++++++--- 40 files changed, 1039 insertions(+), 301 deletions(-) create mode 100644 resources/config.yml create mode 100644 src/EssentialsPE/Commands/AFK.php create mode 100644 src/EssentialsPE/Commands/Unlimited.php create mode 100644 src/EssentialsPE/Events/PlayerAFKModeChangeEvent.php create mode 100644 src/EssentialsPE/Events/PlayerGodModeChangeEvent.php create mode 100644 src/EssentialsPE/Events/PlayerUnlimitedModeChangeEvent.php diff --git a/.gitignore b/.gitignore index b62549d3..29c85c16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -.idea/* -Nicks.yml \ No newline at end of file +./idea/* +Nicks.yml +.idea/codeStyleSettings.xml +.idea/dictionaries/Jorge_González.xml +*.xml +.idea/EssentialsPE.iml \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 09db55cd..d682677f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: EssentialsPE main: EssentialsPE\Loader version: 1.0.0 -api: 1.0.0 +api: 1.2.0 author: LegendOfMCPE Team website: https://github.com/LegendOfMCPE/EssentialsPE @@ -16,178 +16,214 @@ permissions: essentials.colorchat: default: op description: "Allow to chat using colors!" - essentials.command: + essentials.afk: + default: true + description: "Toggle the AFK status" + children: + essentials.afk.use: + default: true + description: "Change your own AFK status" + essentials.afk.other: + default: op + description: "Change other's AFK status" + #essentials.afk.auto: + # default: op + # description: "Players with this permission will be set to AFK after a period of inaction + #essentials.afk.kickexempt: + # default: op + # description: "Exempt the user from being auto kicked for AFK + essentials.broadcast: default: op - description: "Allow to access any EssentialsPE command" + description: "Broadcast a message" children: - essentials.command.broadcast: + essentials.broadcast.use: default: op description: "Broadcast a message" - children: - essentials.command.broadcast.use: - default: op - description: "Broadcast a message" - essentials.command.broadcast.permselect: - default: op - description: "Broadcast a message to players that have a certain permission" - essentials.command.burn: - default: op - description: "Set a player on fire" - essentials.command.clearinventory: - default: op - description: "Clear a player inventory" - children: - essentials.command.clearinventory.use: - default: op - description: "Clear your inventory" - essentials.command.clearinventory.other: - defult: op - description: "Clear other's inventory" - essentialc.command.compass: + essentials.burn: + default: op + description: "Set a player on fire" + essentials.clearinventory: + default: op + description: "Clear a player inventory" + children: + essentials.clearinventory.use: + default: op + description: "Clear your inventory" + essentials.clearinventory.other: + defult: op + description: "Clear other's inventory" + essentialc.command.compass: + default: true + description: "Display your current bearing direction" + essentials.essentials: + default: op + description: "See the current Essentials version" + essentials.extinguish: + default: op + description: "Extinguish a player" + children: + essentials.extinguish.use: + default: op + description: "Extinguish yourslef" + essentials.extinguish.other: + default: op + description: "Extinguish other players" + essentials.getpos: + default: op + description: "Get any player's position" + children: + essentials.getpos.use: default: true - description: "Display your current bearing direction" - essentials.command.essentials: - default: op - description: "See the current Essentials version" - essentials.command.extinguish: - default: op - description: "Extinguish a player" - children: - essentials.command.extinguish.use: - default: op - description: "Extinguish yourslef" - essentials.command.extinguish.other: - default: op - description: "Extinguish other players" - essentials.command.getpos: - default: op - description: "Get any player's position" - children: - essentials.command.getpos.use: - default: true - description: "Get your current position" - essentials.command.getpos.other: - default: op - description: "Get other player's position" - essentials.command.god: - default: op - description: "Prevent a player to take any damage" - children: - essentials.command.god.use: - default: op - decription: "Prevent you to take damage" - essentials.command.god.other: - default: op - decription: "Prevent other player to take damage" - essentials.command.heal: - default: op - description: "Heal yourself or other players" - children: - essentials.command.heal.use: - default: op - description: "Heal yourself" - essentials.command.heal.other: - default: op - description: "Heal other players" - essentials.command.home: - default: op - description: "Teleports you to your or another player's home" - children: - essentials.command.home.use: - default: true - description: "Teleports you to your home" - essentials.command.home.other: - default: op - description: "Teleports you to another player's home" - essentials.command.sethome: + description: "Get your current position" + essentials.getpos.other: + default: op + description: "Get other player's position" + essentials.god: + default: op + description: "Prevent a player to take any damage" + children: + essentials.god.use: + default: op + decription: "Prevent you to take damage" + essentials.god.other: + default: op + decription: "Prevent other player to take damage" + essentials.god.other: + default: op + decription: "Let you attack other players while in god mode" + essentials.heal: + default: op + description: "Heal yourself or other players" + children: + essentials.heal.use: + default: op + description: "Heal yourself" + essentials.heal.other: + default: op + description: "Heal other players" + essentials.home: + default: op + description: "Teleports you to your or another player's home" + children: + essentials.home.use: + default: true + description: "Teleports you to your home" + essentials.home.other: + default: op + description: "Teleports you to another player's home" + essentials.sethome: + default: true + description: "Sets your home" + children: + essentials.sethome.use: default: true description: "Sets your home" - children: - essentials.command.sethome.use: - default: true - description: "Sets your home" - essentials.command.item: - default: op - description: "Gives yourself an item" - essentials.command.jump: - default: op - description: "Teleport you to the block you're looking at" - essentials.command.kickall: - default: op - description: "Kick all the online players except the sender" - essentials.command.more: - default: op - description: "Get a stack of the item you're holding" - essentials.command.mute: - default: op - description: "Mute a player from the chat" - chldren: - essentials.command.mute.use: - default: op - description: "Let you mute a player" - essentials.command.mute.exempt: - default: op - description: "Prevent a player from being muted" - essentials.command.nick: - default: op - description: "Change your or others name" - children: - essentials.command.nick.use: - default: op - description: "Change your name" - essentials.command.nick.other: - default: op - desctiption: "Change others name" - essentials.command.powertool: - default: op - description: "Allow to toggle and use PowerTool" - essentials.command.powertooltoggle: - default: op - description: "Allow to disable PowerTool from all the items (of a player)" - essentials.command.pvp: + essentials.item: + default: op + description: "Gives yourself an item" + essentials.jump: + default: op + description: "Teleport you to the block you're looking at" + essentials.kickall: + default: op + description: "Kick all the online players except the sender" + essentials.more: + default: op + description: "Get a stack of the item you're holding" + children: + essentials.more.use: + default: op + description: "Let you get a stack of the item you hold" + essentials.more.oversizedstacks: + default: op + description: "Allow to get oversized stacks of the item you hold" + essentials.mute: + default: op + description: "Mute a player from the chat" + chldren: + essentials.mute.use: + default: op + description: "Let you mute a player" + essentials.mute.exempt: + default: op + description: "Prevent a player from being muted" + essentials.nick: + default: op + description: "Change your or others name" + children: + essentials.nick.use: + default: op + description: "Change your name" + essentials.nick.other: + default: op + description: "Change others name" + essentials.powertool: + default: op + description: "Allow to toggle and use PowerTool" + essentials.powertooltoggle: + default: op + description: "Allow to disable PowerTool from all the items (of a player)" + essentials.pvp: + default: true + description: "Toggle PvP on/off" + essentials.realname: + default: op + description: "See a player's realname" + essentials.repair: + default: op + description: "Repair the item you're holding" + children: + essentials.repair.all: + default: op + description: "Let you repair all the damaged tools/armors on your inventory" + essentials.repair.armor: + default: op + description: "Let your repair the equiped armor while using /repair all" + essentials.seen: + default: op + description: "Check player's last online time" + essentials.setspawn: + default: op + description: "Change your server's general spawn" + essentials.tempban: + default: op + description: "Temporary bans a player" + essentials.top: + default: op + description: "Teleport to the highest block above you" + essentials.unlimited: + default: op + description: "Allow the player to place unlimited blocks" + children: + essentials.unlimited.use: + default: op + description: "Allow to enable unlimited placing of blocks for the sender" + essentials.unlimited.other: + default: op + description: "Allow to enable unlimited placing of blocks to other players" + essentials.vanish: + default: op + description: "Hide yourself or another player" + children: + essentials.vanish.use: + default: op + description: "Hide yourself from other players" + essentials.vanish.other: + default: op + description: "Hide other players" + essentials.warp: + default: op + description: "Warp managment permissions" + children: + essentials.warp.use: default: true - description: "Toggle PvP on/off" - essentials.command.realname: - default: op - description: "See a player's realname" - essentials.command.repair: - default: op - description: "Repair the item you're holding" - essentials.command.seen: - default: op - description: "Check player's last online time" - essentials.command.setspawn: - default: op - description: "Change your server's general spawn" - essentials.command.tempban: - default: op - description: "Temporary bans a player" - essentials.command.top: - default: op - description: "Teleport to the highest block above you" - essentials.command.vanish: - default: op - description: "Hide yourself or another player" - children: - essentials.command.vanish.use: - default: op - description: "Hide yourself from other players" - essentials.command.vanish.other: - default: op - description: "Hide other players" - essentials.command.warp: - default: op - description: "Warp managment permissions" - children: - essentials.command.warp.use: - default: true - description: "Teleport to a warp!" - essentials.command.warp.other: - default: op - description: "Teleport other players to a warp" - essentials.command.warp.remove: - default: op - description: "Close a warp" - essentials.command.warp.set: - default: op - description: "Open a warp" + description: "Teleport to a warp!" + essentials.warp.other: + default: op + description: "Teleport other players to a warp" + essentials.warp.remove: + default: op + description: "Close a warp" + essentials.warp.set: + default: op + description: "Open a warp" diff --git a/resources/config.yml b/resources/config.yml new file mode 100644 index 00000000..3e217a7f --- /dev/null +++ b/resources/config.yml @@ -0,0 +1,8 @@ +#EssentialsPE configuration +#This configuration flie let you modify how EssentialsPE work with some features + +#This option let you disable player damage when they're AFK +safe-afk: true + +#This option let you limit the block distance for players to teleport using "/jump" +#jump-distance: 1000 \ No newline at end of file diff --git a/src/EssentialsPE/Commands/AFK.php b/src/EssentialsPE/Commands/AFK.php new file mode 100644 index 00000000..c327ffb7 --- /dev/null +++ b/src/EssentialsPE/Commands/AFK.php @@ -0,0 +1,76 @@ +setPermission("essentials.afk.use"); + } + + public function execute(CommandSender $sender, $alias, array $args){ + if(!$this->testPermission($sender)){ + return false; + } + if(count($args) > 1){ + if(!$sender instanceof Player){ + $sender->sendMessage(TextFormat::RED . "Usage: /afk "); + }else{ + $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); + } + return false; + } + switch(count($args)){ + case 0: + if(!$sender instanceof Player){ + $sender->sendMessage(TextFormat::RED . "Usage: /afk "); + return false; + } + $this->getAPI()->switchAFKMode($sender); + if(!$this->getAPI()->isAFK($sender)){ + $sender->sendMessage(TextFormat::YELLOW . "You're no longer AFK"); + $this->broadcastAFKStatus($sender, "is no longer AFK"); + }else{ + $sender->sendMessage(TextFormat::YELLOW . "You're now AFK"); + $this->broadcastAFKStatus($sender, "is now AFK"); + } + return true; + break; + case 1: + if(!$sender->hasPermission("essentials.afk.other")){ + $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); + return false; + } + $player = $this->getAPI()->getPlayer($args[0]); + if(!$player instanceof Player){ + $sender->sendMessage(TextFormat::RED . "[Error] Player not found"); + return false; + } + $this->getAPI()->switchAFKMode($player); + if(!$this->getAPI()->isAFK($player)){ + $player->sendMessage(TextFormat::YELLOW . "You're no longer AFK"); + $this->broadcastAFKStatus($player, "is no longer AFK"); + }else{ + $player->sendMessage(TextFormat::YELLOW . "You're now AFK"); + $this->broadcastAFKStatus($player, "is now AFK"); + } + return true; + break; + } + return true; + } + + private function broadcastAFKStatus(Player $player, $message){ + foreach($player->getServer()->getOnlinePlayers() as $p){ + if($p !== $player){ + $p->sendMessage(TextFormat::YELLOW . $player->getDisplayName() . " " . $message); + $player->getServer()->getLogger()->info(TextFormat::GREEN . $player->getDisplayName() . " " . $message); + } + } + } +} \ No newline at end of file diff --git a/src/EssentialsPE/Commands/Broadcast.php b/src/EssentialsPE/Commands/Broadcast.php index cc676a75..506ecacd 100644 --- a/src/EssentialsPE/Commands/Broadcast.php +++ b/src/EssentialsPE/Commands/Broadcast.php @@ -4,13 +4,12 @@ use EssentialsPE\BaseCommand; use EssentialsPE\Loader; use pocketmine\command\CommandSender; -use pocketmine\Server; use pocketmine\utils\TextFormat; class Broadcast extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "broadcast", "Broadcast a message.", "/broadcast ", ["bcast"]); - $this->setPermission("essentials.command.broadcast.use"); + $this->setPermission("essentials.broadcast.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -20,7 +19,7 @@ public function execute(CommandSender $sender, $alias, array $args){ if(count($args) == 0){ $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); }else{ - Server::getInstance()->broadcastMessage(TextFormat::LIGHT_PURPLE . "[Broadcast] " . TextFormat::RESET . implode(" ", $args)); + $sender->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . "[Broadcast] " . TextFormat::RESET . implode(" ", $args)); } return true; } diff --git a/src/EssentialsPE/Commands/Burn.php b/src/EssentialsPE/Commands/Burn.php index cb303117..203cdfa3 100644 --- a/src/EssentialsPE/Commands/Burn.php +++ b/src/EssentialsPE/Commands/Burn.php @@ -9,7 +9,7 @@ class Burn extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "burn", "Set a player on fire", "/burn "); - $this->setPermission("essentials.command.burn"); + $this->setPermission("essentials.burn"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/ClearInventory.php b/src/EssentialsPE/Commands/ClearInventory.php index 1c00473c..fd390196 100644 --- a/src/EssentialsPE/Commands/ClearInventory.php +++ b/src/EssentialsPE/Commands/ClearInventory.php @@ -10,7 +10,7 @@ class ClearInventory extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "clearinventory", "Clear your/other's inventory", "/clearinventory [player]", ["ci", "clean", "clearinvent"]); - $this->setPermission("essentials.command.clearinventory.use"); + $this->setPermission("essentials.clearinventory.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){ } break; case 1: - if(!$sender->hasPermission("essentials.command.clearinventory.other")){ + if(!$sender->hasPermission("essentials.clearinventory.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); return false; }else{ diff --git a/src/EssentialsPE/Commands/Compass.php b/src/EssentialsPE/Commands/Compass.php index 0cf6e4aa..801c4367 100644 --- a/src/EssentialsPE/Commands/Compass.php +++ b/src/EssentialsPE/Commands/Compass.php @@ -10,7 +10,7 @@ class Compass extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "compass", "Display your current bearing direction", "/compass", ["direction"]); - $this->setPermission("essentials.command.compass"); + $this->setPermission("essentials.compass"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/Essentials.php b/src/EssentialsPE/Commands/Essentials.php index f2b142d6..0d44d227 100644 --- a/src/EssentialsPE/Commands/Essentials.php +++ b/src/EssentialsPE/Commands/Essentials.php @@ -4,20 +4,19 @@ use EssentialsPE\BaseCommand; use EssentialsPE\Loader; use pocketmine\command\CommandSender; -use pocketmine\Server; use pocketmine\utils\TextFormat; class Essentials extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "essentials", "Get current Essentials version", "/essentials", ["ess"]); - $this->setPermission("essentials.command.essentials"); + $this->setPermission("essentials.essentials"); } public function execute(CommandSender $sender, $alias, array $args){ if(!$this->testPermission($sender)){ return false; } - $sender->sendMessage(TextFormat::YELLOW . "You're using " . TextFormat::AQUA . "EssentialsPE " . TextFormat::GREEN . "v" . Server::getInstance()->getPluginManager()->getPlugin("EssentialsPE")->getDescription()->getVersion()); + $sender->sendMessage(TextFormat::YELLOW . "You're using " . TextFormat::AQUA . "EssentialsPE " . TextFormat::GREEN . "v" . $sender->getServer()->getPluginManager()->getPlugin("EssentialsPE")->getDescription()->getVersion()); return true; } } diff --git a/src/EssentialsPE/Commands/Extinguish.php b/src/EssentialsPE/Commands/Extinguish.php index 61242791..f958cb8f 100644 --- a/src/EssentialsPE/Commands/Extinguish.php +++ b/src/EssentialsPE/Commands/Extinguish.php @@ -10,7 +10,7 @@ class Extinguish extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "extinguish", "Extinguish a player", "/extinguish [player]", ["ext"]); - $this->setPermission("essentials.command.extinguish.use"); + $this->setPermission("essentials.extinguish.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){ } break; case 1: - if(!$sender->hasPermission("essentials.command.extinguish.other")){ + if(!$sender->hasPermission("essentials.extinguish.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); }else{ $player = $this->getAPI()->getPlayer($args[0]); diff --git a/src/EssentialsPE/Commands/GetPos.php b/src/EssentialsPE/Commands/GetPos.php index 1bb8c46d..9b6b68d7 100644 --- a/src/EssentialsPE/Commands/GetPos.php +++ b/src/EssentialsPE/Commands/GetPos.php @@ -10,7 +10,7 @@ class GetPos extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "getpos", "Get your/other's position", "/getpos [player]", ["coords", "position", "whereami", "getlocation", "getloc"]); - $this->setPermission("essentials.command.getpos.use"); + $this->setPermission("essentials.getpos.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){ } break; case 1: - if(!$sender->hasPermission("essentials.command.getpos.other")){ + if(!$sender->hasPermission("essentials.getpos.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); }else{ $player = $this->getAPI()->getPlayer($args[0]); diff --git a/src/EssentialsPE/Commands/God.php b/src/EssentialsPE/Commands/God.php index 24a666d6..5bb9a6ee 100644 --- a/src/EssentialsPE/Commands/God.php +++ b/src/EssentialsPE/Commands/God.php @@ -10,7 +10,7 @@ class God extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "god", "Prevent you to take any damage", "/god [player]", ["godmode", "tgm"]); - $this->setPermission("essentials.command.god.use"); + $this->setPermission("essentials.god.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -40,7 +40,7 @@ public function execute(CommandSender $sender, $alias, array $args){ return true; break; case 1: - if(!$sender->hasPermission("essentials.command.god.other")){ + if(!$sender->hasPermission("essentials.god.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); return false; } diff --git a/src/EssentialsPE/Commands/Heal.php b/src/EssentialsPE/Commands/Heal.php index 5520330e..bb9a367e 100644 --- a/src/EssentialsPE/Commands/Heal.php +++ b/src/EssentialsPE/Commands/Heal.php @@ -10,7 +10,7 @@ class Heal extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "heal", "Heal yourself or other player", "/heal [player]"); - $this->setPermission("essentials.command.heal.use"); + $this->setPermission("essentials.heal.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){ } break; case 1: - if(!$sender->hasPermission("essentials.command.heal.other")){ + if(!$sender->hasPermission("essentials.heal.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); }else{ $player = $this->getAPI()->getPlayer($args[0]); diff --git a/src/EssentialsPE/Commands/Item.php b/src/EssentialsPE/Commands/Item.php index 1b1c2fcc..d263bd72 100644 --- a/src/EssentialsPE/Commands/Item.php +++ b/src/EssentialsPE/Commands/Item.php @@ -10,7 +10,7 @@ class Item extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "item", "Gives yourself an item", "/item [amount]", ["i"]); - $this->setPermission("essentials.command.item"); + $this->setPermission("essentials.item"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/Jump.php b/src/EssentialsPE/Commands/Jump.php index 247a1bdb..41a3dc06 100644 --- a/src/EssentialsPE/Commands/Jump.php +++ b/src/EssentialsPE/Commands/Jump.php @@ -12,7 +12,7 @@ class Jump extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "jump", "Teleport you to the block you're looking at", "/jump", ["j", "jumpto"]); - $this->setPermission("essentials.command.jump"); + $this->setPermission("essentials.jump"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/KickAll.php b/src/EssentialsPE/Commands/KickAll.php index 262d5139..023ebada 100644 --- a/src/EssentialsPE/Commands/KickAll.php +++ b/src/EssentialsPE/Commands/KickAll.php @@ -4,13 +4,12 @@ use EssentialsPE\BaseCommand; use EssentialsPE\Loader; use pocketmine\command\CommandSender; -use pocketmine\Server; use pocketmine\utils\TextFormat; class KickAll extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "kickall", "Kick all the players", "/kickall "); - $this->setPermission("essentials.command.kickall"); + $this->setPermission("essentials.kickall"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -24,7 +23,7 @@ public function execute(CommandSender $sender, $alias, array $args){ $reason = implode(" ", $args); } - foreach(Server::getInstance()->getOnlinePlayers() as $p){ + foreach($sender->getServer()->getOnlinePlayers() as $p){ if($p != $sender){ $p->kick($reason); } diff --git a/src/EssentialsPE/Commands/More.php b/src/EssentialsPE/Commands/More.php index 4915182c..1795c715 100644 --- a/src/EssentialsPE/Commands/More.php +++ b/src/EssentialsPE/Commands/More.php @@ -10,7 +10,7 @@ class More extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "more", "Get a stack of the item you're holding", "/more"); - $this->setPermission("essentials.command.more"); + $this->setPermission("essentials.more.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -27,8 +27,17 @@ public function execute(CommandSender $sender, $alias, array $args){ } $inv = $sender->getInventory(); $item = $inv->getItemInHand(); - $item->setCount($item->getMaxStackSize()); - $inv->setItemInHand($item); + if($item->getID() === 0){ + $sender->sendMessage(TextFormat::RED . "You can't get a stack of AIR"); + return false; + } + if(!$sender->hasPermission("essentials.more.oversizedstacks")){ + $item->setCount($item->getMaxStackSize()); + $inv->setItemInHand($item); + }else{ + $item->setCount(64); + $inv->setItemInHand($item); + } return true; } } diff --git a/src/EssentialsPE/Commands/Mute.php b/src/EssentialsPE/Commands/Mute.php index ec262654..5505a4c3 100644 --- a/src/EssentialsPE/Commands/Mute.php +++ b/src/EssentialsPE/Commands/Mute.php @@ -10,7 +10,7 @@ class Mute extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "mute", "Prevent a player from chatting", "/mute ", ["silence"]); - $this->setPermission("essentials.command.mute"); + $this->setPermission("essentials.mute"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -25,7 +25,7 @@ public function execute(CommandSender $sender, $alias, array $args){ if($player === false){ $sender->sendMessage(TextFormat::RED . "[Error] Player not found."); }else{ - if($player->hasPermission("essentials.command.mute.exempt")){ + if($player->hasPermission("essentials.mute.exempt")){ if(!$this->getAPI()->isMuted($player)){ $sender->sendMessage(TextFormat::RED . "$args[0] can't be muted"); return false; diff --git a/src/EssentialsPE/Commands/Nick.php b/src/EssentialsPE/Commands/Nick.php index 80a34cd7..88f860a4 100644 --- a/src/EssentialsPE/Commands/Nick.php +++ b/src/EssentialsPE/Commands/Nick.php @@ -10,7 +10,7 @@ class Nick extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "nick", "Change your in-game name", "/nick [player]", ["nickname"]); - $this->setPermission("essentials.command.nick.use"); + $this->setPermission("essentials.nick.use"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -38,7 +38,7 @@ public function execute(CommandSender $sender, $alias, array $args){ } break; case 2: - if(!$sender->hasPermission("essentials.command.nick.other")){ + if(!$sender->hasPermission("essentials.nick.other")){ $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); }else{ $nickname = $args[0]; diff --git a/src/EssentialsPE/Commands/PowerTool/PowerTool.php b/src/EssentialsPE/Commands/PowerTool/PowerTool.php index 13b81f65..6875213a 100644 --- a/src/EssentialsPE/Commands/PowerTool/PowerTool.php +++ b/src/EssentialsPE/Commands/PowerTool/PowerTool.php @@ -11,7 +11,7 @@ class PowerTool extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "powertool", "Toogle PowerTool on the item you're holding", "/powertool ", ["pt"]); - $this->setPermission("essentials.command.powertool"); + $this->setPermission("essentials.powertool"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -26,21 +26,71 @@ public function execute(CommandSender $sender, $alias, array $args){ if($item->getID() == Item::AIR){ $sender->sendMessage(TextFormat::RED . "You can't assign a command to an empty hand."); return false; - }elseif($args[0] == "pt" || $args[0] == "ptt" || $args[0] == "powertool" || $args[0] == "powertooltoggle"){ - $sender->sendMessage(TextFormat::RED . "This command can't be assigned"); - return false; } - if(count($args) == 0){ - if(!$this->getAPI()->getPowerToolItemCommand($sender, $item)){ + if(count($args) === 0){ + if(!$this->getAPI()->getPowerToolItemCommands($sender, $item)){ $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); return false; } $this->getAPI()->disablePowerToolItem($sender, $item); $sender->sendMessage(TextFormat::GREEN . "Command removed from this item."); }else{ - $this->getAPI()->setPowerToolItemCommand($sender, $item, implode(" ", $args)); - $sender->sendMessage(TextFormat::GREEN . "Command successfully assigned to this item!"); + if($args[0] == "pt" || $args[0] == "ptt" || $args[0] == "powertool" || $args[0] == "powertooltoggle"){ + $sender->sendMessage(TextFormat::RED . "This command can't be assigned"); + return false; + } + $command = implode(" ", $args); + if(stripos($command, "c:") !== false){ //Create a chat macro + $c = substr($command, 2); + $this->getAPI()->setPowerToolItemChatMacro($sender, $item, $c); + $sender->sendMessage(TextFormat::GREEN . "Chat macro successfully assigned to this item!"); + }elseif(stripos($command, "a:") !== false){ //Add multiple commands + $a = substr($command, 2); + $a = explode(";", $a); + $this->getAPI()->setPowerToolItemCommands($sender, $item, $a); + $sender->sendMessage(TextFormat::GREEN . "Commands successfully assigned to this item!"); + }elseif(stripos($command, "r:") !== false){ //Remove a single command + $r = substr($command, 2); + $this->getAPI()->removePowerToolCommand($sender, $item, $r); + $sender->sendMessage(TextFormat::GREEN . "Command successfully removed from this item!"); + }elseif(count($args) === 1){ + switch(strtolower($args[0])){ + case "l": + $commands = $this->getAPI()->getPowerToolItemCommands($sender, $item); + $list = "=== List of commands ==="; + if($commands === false){ + $list .= "\n" . TextFormat::ITALIC . "**There aren't any commands for this item**"; + }else{ + foreach($commands as $c){ + $list .= "\n* /$c"; + } + } + $chat_macro = $this->getAPI()->getPowerToolItemChatMacro($sender, $item); + $list .= "\n=== Chat Macro ==="; + if($chat_macro === false){ + $list .= "\n" . TextFormat::ITALIC . "**There aren't any chat macros for this item**"; + }else{ + $list .= "\n$chat_macro"; + } + $list .= "=== End of the lists ==="; + $sender->sendMessage($list); + return true; + break; + case "d": + if(!$this->getAPI()->getPowerToolItemCommands($sender, $item)){ + $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); + return false; + } + $this->getAPI()->disablePowerToolItem($sender, $item); + $sender->sendMessage(TextFormat::GREEN . "Command removed from this item."); + return true; + break; + } + }else{ + $this->getAPI()->setPowerToolItemCommand($sender, $item, $command); + $sender->sendMessage(TextFormat::GREEN . "Command successfully assigned to this item!"); + } } return true; } diff --git a/src/EssentialsPE/Commands/PowerTool/PowerToolToggle.php b/src/EssentialsPE/Commands/PowerTool/PowerToolToggle.php index 7b86644c..ad4c3d25 100644 --- a/src/EssentialsPE/Commands/PowerTool/PowerToolToggle.php +++ b/src/EssentialsPE/Commands/PowerTool/PowerToolToggle.php @@ -10,7 +10,7 @@ class PowerToolToggle extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "powertooltoggle", "Disable PowerTool from all the items", "/powertooltoggle", ["ptt", "pttoggle"]); - $this->setPermission("essentials.command.powertooltoggle"); + $this->setPermission("essentials.powertooltoggle"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/PvP.php b/src/EssentialsPE/Commands/PvP.php index 36d7f864..2c753c24 100644 --- a/src/EssentialsPE/Commands/PvP.php +++ b/src/EssentialsPE/Commands/PvP.php @@ -10,7 +10,7 @@ class PvP extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "pvp", "Toggle PvP on/off", "/pvp "); - $this->setPermission("essentials.command.pvp"); + $this->setPermission("essentials.pvp"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/RealName.php b/src/EssentialsPE/Commands/RealName.php index 28451565..19692c23 100644 --- a/src/EssentialsPE/Commands/RealName.php +++ b/src/EssentialsPE/Commands/RealName.php @@ -9,7 +9,7 @@ class RealName extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "realname", "Check the realname of a player", "/realname "); - $this->setPermission("essentials.command.realname"); + $this->setPermission("essentials.realname"); } public function execute(CommandSender $sender, $alias, array $args){ diff --git a/src/EssentialsPE/Commands/Repair.php b/src/EssentialsPE/Commands/Repair.php index b4b4cdbd..01ed3d8d 100644 --- a/src/EssentialsPE/Commands/Repair.php +++ b/src/EssentialsPE/Commands/Repair.php @@ -4,13 +4,14 @@ use EssentialsPE\BaseCommand; use EssentialsPE\Loader; use pocketmine\command\CommandSender; +use pocketmine\item\Item; use pocketmine\Player; use pocketmine\utils\TextFormat; class Repair extends BaseCommand{ public function __construct(Loader $plugin){ - parent::__construct($plugin, "repair", "Repair the item you're holding", "/repair", ["fix"]); - $this->setPermission("essentials.command.repair"); + parent::__construct($plugin, "repair", "Repair the item you're holding", "/repair [all]", ["fix"]); + $this->setPermission("essentials.repair"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -20,20 +21,68 @@ public function execute(CommandSender $sender, $alias, array $args){ if(!$sender instanceof Player){ $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); return false; - }elseif(count($args) != 0){ + }elseif(count($args) > 1){ $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); return false; } + switch(count($args)){ + case 0: + $inv = $sender->getInventory(); + $item = $inv->getItemInHand(); + if(!$this->isReparable($item)){ + $sender->sendMessage(TextFormat::RED . "[Error] This item can't be repaired!"); + return false; + } + $item->setDamage(0); + $inv->setItemInHand($item); + $sender->sendMessage(TextFormat::GREEN . "Item successfully repaired!"); + break; + case 1: + switch(strtolower($args[0])){ + case "all": + if(!$sender->hasPermission("essentials.repair.all")){ + $sender->sendMessage(TextFormat::RED . $this->getPermissionMessage()); + return false; + } + $inv = $sender->getInventory(); + foreach($inv->getContents() as $item){ + if($this->isReparable($item)){ + $item->setDamage(0); + } + } + $r = "All the tools on your inventory were repaired!"; + if($sender->hasPermission("essentials.repair.armor")){ + foreach($inv->getArmorContents() as $item){ + $item->setDamage(0); + } + $r .= "\n(including the equipped Armor)"; + } + $sender->sendMessage(TextFormat::GREEN . $r); + break; + case "hand": + $inv = $sender->getInventory(); + $item = $inv->getItemInHand(); + if(!$this->isReparable($item)){ + $sender->sendMessage(TextFormat::RED . "[Error] This item can't be repaired!"); + return false; + } + $item->setDamage(0); + $inv->setItemInHand($item); + $sender->sendMessage(TextFormat::GREEN . "Item successfully repaired!"); + break; + default: + $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); + return false; + break; + } + } + return true; + } - $inv = $sender->getInventory(); - $item = $inv->getItemInHand(); - if(!$item->isTool()){ - $sender->sendMessage(TextFormat::RED . "[Error] This item can't be repaired!"); + private function isReparable(Item $item){ + if(!$item->isTool() || $item->getID() !== Item::CHAIN_BOOTS|Item::CHAIN_LEGGINGS|Item::CHAIN_CHESTPLATE|Item::CHAIN_HELMET|Item::LEATHER_BOOTS|Item::LEATHER_PANTS|Item::LEATHER_TUNIC|Item::LEATHER_CAP|Item::IRON_BOOTS|Item::IRON_LEGGINGS|Item::IRON_CHESTPLATE|Item::IRON_HELMET|Item::GOLD_BOOTS|Item::GOLD_LEGGINGS|Item::GOLD_CHESTPLATE|Item::GOLD_HELMET|Item::DIAMOND_BOOTS|Item::DIAMOND_LEGGINGS|Item::DIAMOND_CHESTPLATE|Item::DIAMOND_HELMET){ return false; } - $item->setDamage(0); - $inv->setItemInHand($item); - $sender->sendMessage(TextFormat::GREEN . "Item successfully repaired!"); return true; } } diff --git a/src/EssentialsPE/Commands/Seen.php b/src/EssentialsPE/Commands/Seen.php index e1be88ec..16dc10b4 100644 --- a/src/EssentialsPE/Commands/Seen.php +++ b/src/EssentialsPE/Commands/Seen.php @@ -4,13 +4,12 @@ use EssentialsPE\BaseCommand; use EssentialsPE\Loader; use pocketmine\command\CommandSender; -use pocketmine\Server; use pocketmine\utils\TextFormat; class Seen extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "seen", "See player's last played time", "/seen "); - $this->setPermission("essentials.command.seen"); + $this->setPermission("essentials.seen"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -24,10 +23,10 @@ public function execute(CommandSender $sender, $alias, array $args){ if($player != false){ $sender->sendMessage(TextFormat::GREEN . $player->getDisplayName() . " is online!"); }else{ - if(!is_numeric(Server::getInstance()->getOfflinePlayer($args[0])->getLastPlayed())){ + if(!is_numeric($sender->getServer()->getOfflinePlayer($args[0])->getLastPlayed())){ $sender->sendMessage(TextFormat::RED . "$args[0] never played on this server."); }else{ - $player = Server::getInstance()->getOfflinePlayer($args[0])->getLastPlayed() / 1000; + $player = $sender->getServer()->getOfflinePlayer($args[0])->getLastPlayed() / 1000; $current = time(); if(date("Y", $player) == date("Y", $current)){ //Year (Ex. "2014") if(date("n", $player) == date("n", $current)){ //Month in numbers (1 - 12) diff --git a/src/EssentialsPE/Commands/SetSpawn.php b/src/EssentialsPE/Commands/SetSpawn.php index 5fb3a760..68138e13 100644 --- a/src/EssentialsPE/Commands/SetSpawn.php +++ b/src/EssentialsPE/Commands/SetSpawn.php @@ -6,13 +6,12 @@ use pocketmine\command\CommandSender; use pocketmine\math\Vector3; use pocketmine\Player; -use pocketmine\Server; use pocketmine\utils\TextFormat; class SetSpawn extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "setspawn", "Change your server main spawn point", "/setspawn"); - $this->setPermission("essentials.command.setspawn"); + $this->setPermission("essentials.setspawn"); } public function execute(CommandSender $sender, $alias, array $args){ @@ -25,7 +24,7 @@ public function execute(CommandSender $sender, $alias, array $args){ return false; } $sender->getLevel()->setSpawnLocation(new Vector3($sender->getFloorX(), $sender->getFloorY(), $sender->getFloorZ())); - Server::getInstance()->setDefaultLevel($sender->getLevel()); + $sender->getServer()->setDefaultLevel($sender->getLevel()); $sender->sendMessage(TextFormat::YELLOW . "Spawn point changed!"); return true; } diff --git a/src/EssentialsPE/Commands/TempBan.php b/src/EssentialsPE/Commands/TempBan.php index 56e0a85f..7f924877 100644 --- a/src/EssentialsPE/Commands/TempBan.php +++ b/src/EssentialsPE/Commands/TempBan.php @@ -10,7 +10,7 @@ class TempBan extends BaseCommand{ public function __construct(Loader $plugin){ parent::__construct($plugin, "tempban", "Temporary bans the specified player", "/tempban