From 266e4214d4d7edd9aab5ba89a86ecfba2a7e2c45 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 3 Mar 2024 08:05:36 -0500 Subject: [PATCH] Itembase refactored out. --- src/engine/devcmd/cmds/MakeItemCmd.java | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/engine/devcmd/cmds/MakeItemCmd.java b/src/engine/devcmd/cmds/MakeItemCmd.java index dbe6cb53..8761a20c 100644 --- a/src/engine/devcmd/cmds/MakeItemCmd.java +++ b/src/engine/devcmd/cmds/MakeItemCmd.java @@ -31,7 +31,9 @@ public class MakeItemCmd extends AbstractDevCmd { AbstractGameObject target) { if (words[0].equals("resources")) { + for (int ibID : Warehouse.getMaxResources().keySet()) { + if (ibID == 7) continue; @@ -41,7 +43,6 @@ public class MakeItemCmd extends AbstractDevCmd { if (!pc.getCharItemManager().hasRoomInventory(weight)) { throwbackError(pc, "Not enough room in inventory for any more of this item"); - pc.getCharItemManager().updateInventory(); return; } @@ -102,16 +103,23 @@ public class MakeItemCmd extends AbstractDevCmd { numItems = (numItems > 5000) ? 5000 : numItems; } - int itembaseID; + int templateID; + ItemTemplate template; try { - itembaseID = Integer.parseInt(words[0]); - } catch (NumberFormatException e) { - itembaseID = ItemBase.getIDByName(words[0].toLowerCase()); - if (itembaseID == 0) { + templateID = Integer.parseInt(words[0]); + template = ItemTemplate.itemTemplates.get(words[0].toLowerCase()); + + if (template == null) { throwbackError(pc, "Supplied type " + words[0] + " failed to parse to an Integer"); return; } + + if (template.item_type == ItemType.GOLD) { + this.throwbackInfo(pc, "use /addgold to add gold."); + return; + } + } catch (Exception e) { throwbackError(pc, "An unknown exception occurred when trying to use createitem command for type " @@ -119,10 +127,6 @@ public class MakeItemCmd extends AbstractDevCmd { return; // NaN } - if (itembaseID == 7) { - this.throwbackInfo(pc, "use /addgold to add gold."); - return; - } String prefix = ""; String suffix = ""; @@ -173,10 +177,10 @@ public class MakeItemCmd extends AbstractDevCmd { return; } } - ItemTemplate template = ItemTemplate.itemTemplates.get(itembaseID); + template = ItemTemplate.itemTemplates.get(templateID); if (template == null) { - throwbackError(pc, "Unable to find itembase of ID " + itembaseID); + throwbackError(pc, "Unable to find itembase of ID " + templateID); return; } @@ -207,7 +211,7 @@ public class MakeItemCmd extends AbstractDevCmd { return; } - Item item = new Item(itembaseID); + Item item = new Item(templateID); item.ownerID = pc.getObjectUUID(); item.ownerType = OwnerType.PlayerCharacter; @@ -239,12 +243,12 @@ public class MakeItemCmd extends AbstractDevCmd { @Override protected String _getHelpString() { - return "Creates an item of type 'itembaseID' with a prefix and suffix"; + return "Creates an item of type templateID with a prefix and suffix"; } @Override protected String _getUsageString() { - return "'./makeitem itembaseID PrefixID SuffixID [quantity] [numResources]'"; + return "'./makeitem templateID PrefixID SuffixID [quantity] [numResources]'"; } }