From edd2441cdad2b5293f8b0e900febbdf2ee079c0d Mon Sep 17 00:00:00 2001 From: Rob Date: Sun, 12 Jul 2026 04:05:49 +0100 Subject: [PATCH] Increase resource stack limits and improve makeitem resources --- src/engine/devcmd/cmds/MakeItemCmd.java | 67 +++++++++++++++++++------ 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/engine/devcmd/cmds/MakeItemCmd.java b/src/engine/devcmd/cmds/MakeItemCmd.java index 3f70e4fc..e115d628 100644 --- a/src/engine/devcmd/cmds/MakeItemCmd.java +++ b/src/engine/devcmd/cmds/MakeItemCmd.java @@ -32,47 +32,82 @@ public class MakeItemCmd extends AbstractDevCmd { @Override protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { - if (words[0].equals("resources")) { + + int resourceAmount = 1000; + + if (words.length > 1) { + try { + resourceAmount = Integer.parseInt(words[1]); + } catch (NumberFormatException e) { + throwbackError(pc, "Resource amount must be a number."); + return; + } + } + + if (resourceAmount < 1) + resourceAmount = 1; + + resourceAmount = Math.min( + resourceAmount, + MBServerStatics.RESOURCE_STACK_LIMIT + ); + for (int ibID : Warehouse.getMaxResources().keySet()) { + if (ibID == 7) continue; ItemBase ib = ItemBase.getItemBase(ibID); - short weight = ib.getWeight(); - if (!pc.getCharItemManager().hasRoomInventory(weight)) { - throwbackError(pc, "Not enough room in inventory for any more of this item"); + if (ib == null) + continue; + short weight = ib.getWeight(); + + if (!pc.getCharItemManager().hasRoomInventory(weight)) { + throwbackError(pc, "Not enough room in inventory for any more resources."); pc.getCharItemManager().updateInventory(); return; } - boolean worked = false; - Item item = new Item(ib, pc.getObjectUUID(), - OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(), - true, false, ItemContainerType.INVENTORY, (byte) 0, - new ArrayList<>(), ""); + Item item = new Item( + ib, + pc.getObjectUUID(), + OwnerType.PlayerCharacter, + (byte) 0, + (byte) 0, + (short) ib.getDurability(), + (short) ib.getDurability(), + true, + false, + ItemContainerType.INVENTORY, + (byte) 0, + new ArrayList<>(), + "" + ); - item.setNumOfItems(Warehouse.getMaxResources().get(ibID)); + item.setNumOfItems(resourceAmount); try { item = DbManager.ItemQueries.ADD_ITEM(item); - worked = true; } catch (Exception e) { - throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage()); + throwbackError( + pc, + "Unable to create resource " + ib.getName() + ": " + e.getMessage() + ); return; } - if (item == null || !worked) { - throwbackError(pc, "DB error 2: Unable to create item."); + if (item == null) { + throwbackError(pc, "Unable to create resource " + ib.getName() + "."); return; } - - //add item to inventory pc.getCharItemManager().addItemToInventory(item); } + + pc.getCharItemManager().updateInventory(); return; } if (words.length < 3 || words.length > 5) {