Dev commands, BuildingManager, ChatManager, ForgeManager, NPCManager, NPC, Warehouse, WorkOrder and ManageNPCMsg now call CObjectTemplate.lookup instead of ItemTemplate.templates.get. Forge production cost reads getItemResourceCosts(). Only the DB loader and linkCacheTemplates still use the legacy class (removed in Task 1.8). Removes the static_item_templates ParityCheck comparator. Final parity (offline p17.py, 7586 rows): every id has a cache template, 0 item_type differences, 0 item_resource_costs differences (84 ITEMs have costs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
2.9 KiB
Java
85 lines
2.9 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// 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.Item;
|
|
import engine.objects.PlayerCharacter;
|
|
import engine.parsers.objects.CObjectTemplate;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
/**
|
|
* @author Eighty
|
|
*/
|
|
public class CreateItemCmd extends AbstractDevCmd {
|
|
|
|
public CreateItemCmd() {
|
|
super("createitem");
|
|
}
|
|
|
|
@Override
|
|
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
|
AbstractGameObject target) {
|
|
|
|
if (words.length < 2) {
|
|
this.sendUsage(playerCharacter);
|
|
return;
|
|
}
|
|
|
|
int templateID = Integer.parseInt(words[0]);
|
|
CObjectTemplate template = CObjectTemplate.lookup(templateID);
|
|
|
|
if (template == null) {
|
|
ChatManager.chatSystemInfo(playerCharacter, "No such template found.");
|
|
return;
|
|
}
|
|
int size = 1;
|
|
|
|
if (words.length == 2)
|
|
size = Integer.parseInt(words[1]);
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
if (!playerCharacter.charItemManager.hasRoomInventory(template.getItemWt())) {
|
|
ChatManager.chatSystemInfo(playerCharacter, "You are encumbered!.");
|
|
break;
|
|
}
|
|
|
|
Item item = new Item(templateID);
|
|
item.ownerID = playerCharacter.getObjectUUID();
|
|
item.ownerType = mbEnums.OwnerType.PlayerCharacter;
|
|
item.containerType = mbEnums.ItemContainerType.INVENTORY;
|
|
|
|
try {
|
|
item = DbManager.ItemQueries.PERSIST(item);
|
|
playerCharacter.charItemManager.addItemToInventory(item);
|
|
} catch (Exception e) {
|
|
Logger.error(e);
|
|
}
|
|
}
|
|
playerCharacter.charItemManager.updateInventory();
|
|
}
|
|
|
|
@Override
|
|
protected String _getHelpString() {
|
|
return "Fill your inventory with items";
|
|
}
|
|
|
|
@Override
|
|
protected String _getUsageString() {
|
|
return "' /createitem <templateID> <quantity>'";
|
|
}
|
|
|
|
}
|