From 66bb7d4a6203476db8081e10824c9991cf4cd489 Mon Sep 17 00:00:00 2001 From: Nils Gereke Date: Mon, 22 Jul 2024 00:57:29 +0200 Subject: [PATCH] fix: command give can now executed by console --- .../java/net/imprex/zip/command/GiveCommand.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zip-plugin/src/main/java/net/imprex/zip/command/GiveCommand.java b/zip-plugin/src/main/java/net/imprex/zip/command/GiveCommand.java index 8255006..23d289a 100644 --- a/zip-plugin/src/main/java/net/imprex/zip/command/GiveCommand.java +++ b/zip-plugin/src/main/java/net/imprex/zip/command/GiveCommand.java @@ -24,11 +24,6 @@ public GiveCommand(BackpackPlugin plugin) { @Override public void onCommand(CommandSender sender, String[] args) { - Player player = this.isPlayer(sender); - if (player == null) { - return; - } - if (args.length < 1) { this.messageConfig.send(sender, MessageKey.PleaseEnterABackpackType); return; @@ -41,7 +36,7 @@ public void onCommand(CommandSender sender, String[] args) { } if (args.length > 1) { - Player target = Bukkit.getPlayer(args[1]); + Player target = Bukkit.getPlayerExact(args[1]); if (target == null || !target.isOnline()) { this.messageConfig.send(sender, MessageKey.NoOnlinePlayerWasFound, args[1]); return; @@ -54,6 +49,11 @@ public void onCommand(CommandSender sender, String[] args) { this.messageConfig.send(sender, MessageKey.TargetPlayerNeedMoreSpaceInYourInventory, target.getDisplayName()); } } else { + Player player = this.isPlayer(sender); + if (player == null) { + return; + } + ItemStack backpack = backpackType.createItem(); if (player.getInventory().addItem(backpack).isEmpty()) { this.messageConfig.send(sender, MessageKey.YouHaveGivenYourselfABackpack, backpackType.getUniqueName());