Itembase refactored out.

This commit is contained in:
2024-03-03 08:05:36 -05:00
parent 08aa431f5d
commit 266e4214d4
+19 -15
View File
@@ -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]'";
}
}