Browse Source

Itembase refactored out.

combat-2
MagicBot 9 months ago
parent
commit
266e4214d4
  1. 34
      src/engine/devcmd/cmds/MakeItemCmd.java

34
src/engine/devcmd/cmds/MakeItemCmd.java

@ -31,7 +31,9 @@ public class MakeItemCmd extends AbstractDevCmd {
AbstractGameObject target) { AbstractGameObject target) {
if (words[0].equals("resources")) { if (words[0].equals("resources")) {
for (int ibID : Warehouse.getMaxResources().keySet()) { for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7) if (ibID == 7)
continue; continue;
@ -41,7 +43,6 @@ public class MakeItemCmd extends AbstractDevCmd {
if (!pc.getCharItemManager().hasRoomInventory(weight)) { if (!pc.getCharItemManager().hasRoomInventory(weight)) {
throwbackError(pc, "Not enough room in inventory for any more of this item"); throwbackError(pc, "Not enough room in inventory for any more of this item");
pc.getCharItemManager().updateInventory(); pc.getCharItemManager().updateInventory();
return; return;
} }
@ -102,16 +103,23 @@ public class MakeItemCmd extends AbstractDevCmd {
numItems = (numItems > 5000) ? 5000 : numItems; numItems = (numItems > 5000) ? 5000 : numItems;
} }
int itembaseID; int templateID;
ItemTemplate template;
try { try {
itembaseID = Integer.parseInt(words[0]); templateID = Integer.parseInt(words[0]);
} catch (NumberFormatException e) { template = ItemTemplate.itemTemplates.get(words[0].toLowerCase());
itembaseID = ItemBase.getIDByName(words[0].toLowerCase());
if (itembaseID == 0) { if (template == null) {
throwbackError(pc, "Supplied type " + words[0] throwbackError(pc, "Supplied type " + words[0]
+ " failed to parse to an Integer"); + " failed to parse to an Integer");
return; return;
} }
if (template.item_type == ItemType.GOLD) {
this.throwbackInfo(pc, "use /addgold to add gold.");
return;
}
} catch (Exception e) { } catch (Exception e) {
throwbackError(pc, throwbackError(pc,
"An unknown exception occurred when trying to use createitem command for type " "An unknown exception occurred when trying to use createitem command for type "
@ -119,10 +127,6 @@ public class MakeItemCmd extends AbstractDevCmd {
return; // NaN return; // NaN
} }
if (itembaseID == 7) {
this.throwbackInfo(pc, "use /addgold to add gold.");
return;
}
String prefix = ""; String prefix = "";
String suffix = ""; String suffix = "";
@ -173,10 +177,10 @@ public class MakeItemCmd extends AbstractDevCmd {
return; return;
} }
} }
ItemTemplate template = ItemTemplate.itemTemplates.get(itembaseID); template = ItemTemplate.itemTemplates.get(templateID);
if (template == null) { if (template == null) {
throwbackError(pc, "Unable to find itembase of ID " + itembaseID); throwbackError(pc, "Unable to find itembase of ID " + templateID);
return; return;
} }
@ -207,7 +211,7 @@ public class MakeItemCmd extends AbstractDevCmd {
return; return;
} }
Item item = new Item(itembaseID); Item item = new Item(templateID);
item.ownerID = pc.getObjectUUID(); item.ownerID = pc.getObjectUUID();
item.ownerType = OwnerType.PlayerCharacter; item.ownerType = OwnerType.PlayerCharacter;
@ -239,12 +243,12 @@ public class MakeItemCmd extends AbstractDevCmd {
@Override @Override
protected String _getHelpString() { 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 @Override
protected String _getUsageString() { protected String _getUsageString() {
return "'./makeitem itembaseID PrefixID SuffixID [quantity] [numResources]'"; return "'./makeitem templateID PrefixID SuffixID [quantity] [numResources]'";
} }
} }

Loading…
Cancel
Save