From 1cb118d3e5be2d615f0c270dd304c6aee471047e Mon Sep 17 00:00:00 2001 From: samczsun Date: Mon, 6 Mar 2017 17:04:49 -0500 Subject: [PATCH] Allow force giving items --- .../inventory/command/GiveItemCommand.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index b5f03fe3e..67444ebe3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -32,9 +32,18 @@ public class GiveItemCommand extends CommandBase final String playerName = args[0]; final int amount = Integer.parseInt(args[1]); String itemNameTemp = ""; + + boolean force = false; for (int i = 2; i < args.length; i++) { - itemNameTemp += args[i] + " "; + if (i == args.length - 1 && args[i].equals("-f")) + { + force = true; + } + else + { + itemNameTemp += args[i] + " "; + } } itemNameTemp = itemNameTemp.trim(); @@ -44,11 +53,13 @@ public class GiveItemCommand extends CommandBase final Item item = Plugin.getItem(itemName); Player player = UtilPlayer.searchExact(playerName); - if (item == null) + if (item == null && !force) { - UtilPlayer.message(caller, F.main("Item", "Item with the name " + F.item(itemName) + " not found!")); + UtilPlayer.message(caller, F.main("Item", "Item with the name " + F.item(itemName) + " not found! If you meant to do this, add " + F.elem("-f") + " after the item name.")); + return; } - else if (playerName.equalsIgnoreCase("@a")) + + if (playerName.equalsIgnoreCase("@a")) { for (Player pl : UtilServer.getPlayers()) {