Skip to content

Commit

Permalink
fix: command give can now executed by console
Browse files Browse the repository at this point in the history
  • Loading branch information
NgLoader committed Jul 21, 2024
1 parent dc964fc commit 66bb7d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zip-plugin/src/main/java/net/imprex/zip/command/GiveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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());
Expand Down

0 comments on commit 66bb7d4

Please sign in to comment.