mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Changed usage message displaying to exceptions to reduce boilerplate code
Someday this won't need to be done by commands themselves, it'll be done by the parser.
This commit is contained in:
@@ -25,6 +25,7 @@ namespace pocketmine\command\defaults;
|
||||
|
||||
use pocketmine\command\Command;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
@@ -43,9 +44,7 @@ class TimeCommand extends VanillaCommand{
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
if(count($args) < 1){
|
||||
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
|
||||
|
||||
return false;
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
||||
if($args[0] === "start"){
|
||||
@@ -91,9 +90,7 @@ class TimeCommand extends VanillaCommand{
|
||||
|
||||
|
||||
if(count($args) < 2){
|
||||
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
|
||||
|
||||
return false;
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
||||
if($args[0] === "set"){
|
||||
@@ -132,7 +129,7 @@ class TimeCommand extends VanillaCommand{
|
||||
}
|
||||
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.time.added", [$value]));
|
||||
}else{
|
||||
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user