Allow force giving items

This commit is contained in:
samczsun 2017-03-06 17:04:49 -05:00 committed by cnr
parent db2feeac42
commit 1cb118d3e5

View File

@ -32,9 +32,18 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
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<InventoryManager>
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())
{