Rename ./fillwarehouse to ./fill and require a selected warehouse
The command now acts on the selected building and refuses anything whose blueprint is not a warehouse, or a warehouse that is not its city's active one, instead of using the city the player stands in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c616afa33b
commit
077dcc071d
2 files changed
+23
-15
No files matched your search
+22
-14
@@ -12,25 +12,26 @@ package engine.devcmd.cmds;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
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 FillWarehouseCmd extends AbstractDevCmd {
|
||||
public class FillCmd extends AbstractDevCmd {
|
||||
|
||||
public FillWarehouseCmd() {
|
||||
super("fillwarehouse");
|
||||
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;
|
||||
@@ -55,20 +56,27 @@ public class FillWarehouseCmd extends AbstractDevCmd {
|
||||
}
|
||||
}
|
||||
|
||||
city = ZoneManager.getCityAtLocation(pc.getLoc());
|
||||
if (!(target instanceof Building)) {
|
||||
throwbackError(pc, "Select a warehouse");
|
||||
return;
|
||||
}
|
||||
|
||||
if (city == null) {
|
||||
throwbackError(pc, "You are not standing in a city");
|
||||
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 != building) {
|
||||
throwbackError(pc, "Selected warehouse is not the active warehouse of a city");
|
||||
return;
|
||||
}
|
||||
|
||||
warehouse = city.warehouse;
|
||||
|
||||
if (warehouse == null) {
|
||||
throwbackError(pc, city.getCityName() + " has no warehouse");
|
||||
return;
|
||||
}
|
||||
|
||||
oldResources = new HashMap<>(warehouse.resources);
|
||||
|
||||
for (mbEnums.ResourceType resourceType : mbEnums.ResourceType.values())
|
||||
@@ -86,12 +94,12 @@ public class FillWarehouseCmd extends AbstractDevCmd {
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets every resource in the warehouse of the city you are standing in";
|
||||
return "Sets every resource in the selected warehouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' ./fillwarehouse [amount]' (no amount fills each resource to its deposit limit)";
|
||||
return "' ./fill [amount]' with a warehouse selected (no amount fills each resource to its deposit limit)";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
||||
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
||||
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
||||
DevCmdManager.registerDevCmd(new FillWarehouseCmd());
|
||||
DevCmdManager.registerDevCmd(new FillCmd());
|
||||
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
||||
// Admin
|
||||
|
||||
|
||||
Reference in new issue
Block a user