From 9c90276df49a7d737bb21d783d9fe1d3dac4ea72 Mon Sep 17 00:00:00 2001 From: iksaku Date: Mon, 10 Aug 2015 19:08:31 -0500 Subject: [PATCH] Fixes some bugs related to "nicks", "warps" and "homes" command logs... Going to 1.1.2 >:( --- plugin.yml | 2 +- src/EssentialsPE/Commands/Home/SetHome.php | 5 ++++- src/EssentialsPE/Commands/Nick.php | 10 ++++++++-- src/EssentialsPE/Commands/Warp/Setwarp.php | 5 ++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugin.yml b/plugin.yml index 7bfe3638..2b276ff3 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: EssentialsPE main: EssentialsPE\Loader -version: 1.1.1 +version: 1.1.2 api: 1.12.0 author: LegendsOfMCPE Team website: https://github.com/LegendOfMCPE/EssentialsPE diff --git a/src/EssentialsPE/Commands/Home/SetHome.php b/src/EssentialsPE/Commands/Home/SetHome.php index 364a9682..59a519da 100644 --- a/src/EssentialsPE/Commands/Home/SetHome.php +++ b/src/EssentialsPE/Commands/Home/SetHome.php @@ -42,7 +42,10 @@ public function execute(CommandSender $sender, $alias, array $args){ return false; } $existed = $this->getPlugin()->homeExists($sender, $args[0]); - $this->getPlugin()->setHome($sender, strtolower($args[0]), $sender->getLocation(), $sender->getYaw(), $sender->getPitch()); + if(!$this->getPlugin()->setHome($sender, strtolower($args[0]), $sender->getLocation(), $sender->getYaw(), $sender->getPitch())){ + $sender->sendMessage(TextFormat::RED . "Invalid home name given! Please be sure to only use alphanumerical characters and underscores"); + return false; + } $sender->sendMessage(TextFormat::GREEN . "Home successfuly " . ($existed ? "updated" : "created")); return true; } diff --git a/src/EssentialsPE/Commands/Nick.php b/src/EssentialsPE/Commands/Nick.php index b2f36c99..41460d17 100644 --- a/src/EssentialsPE/Commands/Nick.php +++ b/src/EssentialsPE/Commands/Nick.php @@ -33,7 +33,10 @@ public function execute(CommandSender $sender, $alias, array $args){ return false; } $nickname = $args[0]; - $nickname === "off" ? $this->getPlugin()->removeNick($sender) : $this->getPlugin()->setNick($sender, $nickname); + if(!($nickname === "off" ? $this->getPlugin()->removeNick($sender) : $this->getPlugin()->setNick($sender, $nickname))){ + $sender->sendMessage(TextFormat::RED . "Invalid warp name given! Please be sure to only use alphanumerical characters and underscores"); + return false; + } $sender->sendMessage(TextFormat::GREEN . "Your nick " . ($nickname === "off" ? "has been removed" : "is now " . $nickname)); break; case 2: @@ -47,7 +50,10 @@ public function execute(CommandSender $sender, $alias, array $args){ return false; } $nickname = $args[0]; - $nickname === "off" ? $this->getPlugin()->removeNick($player) : $this->getPlugin()->setNick($player, $nickname); + if(!($nickname === "off" ? $this->getPlugin()->removeNick($player) : $this->getPlugin()->setNick($player, $nickname))){ + $sender->sendMessage(TextFormat::RED . "Invalid warp name given! Please be sure to only use alphanumerical characters and underscores"); + return false; + } $sender->sendMessage(TextFormat::GREEN . $player->getName() . (substr($player->getName(), -1, 1) === "s" ? "'" : "'s") . " nick " . ($nickname === "off" ? "has been removed" : "is now " . $nickname)); $player->sendMessage(TextFormat::GREEN . "Your nick " . ($nickname === "off" ? "has been removed" : "is now " . $nickname)); break; diff --git a/src/EssentialsPE/Commands/Warp/Setwarp.php b/src/EssentialsPE/Commands/Warp/Setwarp.php index 2656f3a9..17e38401 100644 --- a/src/EssentialsPE/Commands/Warp/Setwarp.php +++ b/src/EssentialsPE/Commands/Warp/Setwarp.php @@ -43,7 +43,10 @@ public function execute(CommandSender $sender, $alias, array $args){ $sender->sendMessage(TextFormat::RED . "[Error] You can't modify this warp position"); return false; } - $this->getPlugin()->setWarp($args[0], $sender->getPosition(), $sender->getYaw(), $sender->getPitch()); + if(!$this->getPlugin()->setWarp($args[0], $sender->getPosition(), $sender->getYaw(), $sender->getPitch())){ + $sender->sendMessage(TextFormat::RED . "Invalid warp name given! Please be sure to only use alphanumerical characters and underscores"); + return false; + } $sender->sendMessage(TextFormat::GREEN . "Warp successfully " . ($existed ? "updated!" : "created!")); return true; }