mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
GiveCommand: Make invalid player checking logic less confusing
some code in this namespace is just total WTF...
This commit is contained in:
parent
aeba15c5c6
commit
c26e3aa9fa
@ -54,6 +54,11 @@ class GiveCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
$player = $sender->getServer()->getPlayer($args[0]);
|
||||
if($player === null){
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try{
|
||||
$item = ItemFactory::fromString($args[1]);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
@ -84,14 +89,8 @@ class GiveCommand extends VanillaCommand{
|
||||
$item->setNamedTag($tags);
|
||||
}
|
||||
|
||||
if($player instanceof Player){
|
||||
//TODO: overflow
|
||||
$player->getInventory()->addItem(clone $item);
|
||||
}else{
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
|
||||
|
||||
return true;
|
||||
}
|
||||
//TODO: overflow
|
||||
$player->getInventory()->addItem(clone $item);
|
||||
|
||||
Command::broadcastCommandMessage($sender, new TranslationContainer("%commands.give.success", [
|
||||
$item->getName() . " (" . $item->getId() . ":" . $item->getDamage() . ")",
|
||||
|
Loading…
x
Reference in New Issue
Block a user