diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index 5b84b6bd8..847bd5193 100644 --- a/src/pocketmine/command/defaults/GiveCommand.php +++ b/src/pocketmine/command/defaults/GiveCommand.php @@ -54,7 +54,12 @@ class GiveCommand extends VanillaCommand{ } $player = $sender->getServer()->getPlayer($args[0]); - $item = ItemFactory::fromString($args[1]); + try{ + $item = ItemFactory::fromString($args[1]); + }catch(\InvalidArgumentException $e){ + $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.give.item.notFound", [$args[1]])); + return true; + } if(!isset($args[2])){ $item->setCount($item->getMaxStackSize()); @@ -80,12 +85,6 @@ class GiveCommand extends VanillaCommand{ } if($player instanceof Player){ - if($item->getId() === 0){ - $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.give.item.notFound", [$args[1]])); - - return true; - } - //TODO: overflow $player->getInventory()->addItem(clone $item); }else{