// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2026 // https://www.magicbane.com package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; import engine.mbEnums; import engine.objects.AbstractGameObject; import engine.objects.Building; import engine.objects.City; import engine.objects.PlayerCharacter; import engine.objects.Warehouse; import java.util.HashMap; public class FillCmd extends AbstractDevCmd { public FillCmd() { super("fill"); } @Override protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { Building building; City city; Warehouse warehouse; int amount = Integer.MAX_VALUE; HashMap oldResources; if (words.length > 1) { this.sendUsage(pc); return; } if (words.length == 1 && !words[0].isEmpty()) { try { amount = Integer.parseInt(words[0]); } catch (NumberFormatException e) { throwbackError(pc, "Amount must be a number, " + words[0] + " is invalid"); return; } if (amount < 0) { throwbackError(pc, "Amount must be 0 or more"); return; } } if (!(target instanceof Building)) { throwbackError(pc, "Select a warehouse"); return; } building = (Building) target; if (building.getBlueprint() == null || building.getBlueprint().getBuildingGroup() != mbEnums.BuildingGroup.WAREHOUSE) { throwbackError(pc, "Selected building is not a warehouse"); return; } city = building.getCity(); if (city == null || city.warehouse == null || city.warehouse.building == null || city.warehouse.building.getObjectUUID() != building.getObjectUUID()) { throwbackError(pc, "Selected warehouse is not the active warehouse of a city"); return; } warehouse = city.warehouse; oldResources = new HashMap<>(warehouse.resources); for (mbEnums.ResourceType resourceType : mbEnums.ResourceType.values()) warehouse.resources.put(resourceType, Math.min(amount, resourceType.deposit_limit)); if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) { warehouse.resources.putAll(oldResources); throwbackError(pc, "Failed to update the warehouse in the database"); return; } ChatManager.chatSayInfo(pc, "Filled the " + city.getCityName() + " warehouse" + (amount == Integer.MAX_VALUE ? " to each deposit limit" : " with " + amount + " of each resource (capped at the deposit limit)")); } @Override protected String _getHelpString() { return "Sets every resource in the selected warehouse"; } @Override protected String _getUsageString() { return "' ./fill [amount]' with a warehouse selected (no amount fills each resource to its deposit limit)"; } }