Read item_type through the cache template bridge

Every consumer of the legacy ItemTemplate item_type now reads
template.cacheTemplate.getItemType(). Left on the legacy field: the
type count in dbItemHandler.LOAD_ITEM_TEMPLATES, which runs before the
bridge is linked. The charter checks already read DeedTemplate.

Parity (offline, static_item_templates vs the template
CObjectIndex.lookup picks, scripts/p14.py, 7586 templates: ITEM 4011,
DEED 880, RUNE 2695): 0 differences in item_type. No value changes
expected.

JSON-Refactor-Plan Task 1.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-19 12:43:57 -04:00
1 parent 6825f94f1e
commit b8ac8cce3e
28 files changed
+69 -69

No files matched your search

+3 -3
View File
@@ -701,7 +701,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (itemTemplate == null)
noWeapon = true;
else if (!weapon.template.item_type.equals(ItemType.WEAPON)) {
else if (!weapon.template.cacheTemplate.getItemType().equals(ItemType.WEAPON)) {
defaultAtrAndDamage(abstractCharacter, mainHand);
return;
} else
@@ -718,7 +718,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (noWeapon) {
if (mainHand) {
Item off = abstractCharacter.charItemManager.getEquipped().get(EquipSlotType.LHELD);
if (off != null && off.template != null && off.template.item_type.equals(ItemType.WEAPON))
if (off != null && off.template != null && off.template.cacheTemplate.getItemType().equals(ItemType.WEAPON))
abstractCharacter.rangeHandOne = 10 * (1 + (abstractCharacter.statStrBase / 600)); // Set
// to
// no
@@ -997,7 +997,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (template == null)
return 0;
if (!armor.template.item_type.equals(ItemType.ARMOR))
if (!armor.template.cacheTemplate.getItemType().equals(ItemType.ARMOR))
return 0;
if (armor.template.item_skill_used.isEmpty())
+1 -1
View File
@@ -172,7 +172,7 @@ public class Account extends AbstractGameObject {
this.vault = DbManager.ItemQueries.GET_ITEMS_FOR_ACCOUNT(this.getObjectUUID());
for (Item item : this.vault) {
if (item.template.item_type.equals(mbEnums.ItemType.GOLD)) {
if (item.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD)) {
this.vaultGold = item;
}
}
+20 -20
View File
@@ -130,19 +130,19 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
break;
case VAULT:
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.goldVault = i;
else if (this.vault.contains(i) == false)
this.vault.add(i);
@@ -175,13 +175,13 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
@@ -511,7 +511,7 @@ public class CharacterItemManager {
if (i == null)
return false;
if (i.template.item_type.equals(ItemType.GOLD)) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (this.getGoldInventory() != null) {
if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID())
this.goldInventory = null;
@@ -541,7 +541,7 @@ public class CharacterItemManager {
}
private synchronized boolean junk(Item i, boolean updateInventory) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID())
if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0);
@@ -596,7 +596,7 @@ public class CharacterItemManager {
if (equippedContains(item)) {
fromEquip = true;
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip();
}
@@ -814,7 +814,7 @@ public class CharacterItemManager {
// This removes ingame item from inventory for loot.
private synchronized boolean removeItemFromInventory(Item i) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID())
return false;
if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) {
@@ -837,7 +837,7 @@ public class CharacterItemManager {
// This adds item to inventory for loot. Validity checks already handled
public synchronized boolean addItemToInventory(Item i) {
if (i.template.item_type.equals(ItemType.GOLD))
if (i.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (this.absCharacter.getObjectType() == GameObjectType.Mob) {
if (this.goldInventory == null)
loadGoldItems();
@@ -1041,7 +1041,7 @@ public class CharacterItemManager {
if (npc.getContractID() >= 1900 && npc.getContractID() <= 1906)
eatItem = true;
if (itemToSell.template.item_type.equals(ItemType.POTION))
if (itemToSell.template.cacheTemplate.getItemType().equals(ItemType.POTION))
eatItem = true;
if (eatItem) {
@@ -1184,9 +1184,9 @@ public class CharacterItemManager {
synchronized (lockFirst) {
synchronized (lockSecond) {
// make sure current player has item in inventory
if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
if (lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
return null;
else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD))
else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
return null;
// get weight of item
@@ -1197,10 +1197,10 @@ public class CharacterItemManager {
int weight = lootItem.template.item_wt;
// make sure lootingPlayer has room for item
if (!lootItem.template.item_type.equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
if (!lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
return null;
if (lootItem.template.item_type.equals(ItemType.GOLD))
if (lootItem.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (amount != -1) { //from steal
int total = lootItem.getNumOfItems();
amount = (amount > total) ? total : amount;
@@ -1263,19 +1263,19 @@ public class CharacterItemManager {
* Delegates
*/
public synchronized boolean bankContains(Item item) {
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == item.getObjectUUID());
return bank.contains(item);
}
public synchronized boolean inventoryContains(Item item) {
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID());
return inventory.contains(item);
}
public synchronized boolean vaultContains(Item item) {
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == item.getObjectUUID());
return this.account.getVault().contains(item);
}
@@ -1518,13 +1518,13 @@ public class CharacterItemManager {
item.zeroItem();
item.containerType = mbEnums.ItemContainerType.INVENTORY;
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
//only add gold item once
if (!corpse.hasGold())
corpse.setHasGold(true);
newInventory.add(item);
} else //item
if (item.template.item_type.equals(ItemType.GOLD)) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
int amt = item.getNumOfItems();
item.setNumOfItems(0);
MobLoot ml = new MobLoot(this.absCharacter, amt);
+2 -2
View File
@@ -299,11 +299,11 @@ public class Corpse extends AbstractWorldObject {
int weight = item.template.item_wt;
//make sure looter has room for item
if (item.template.item_type.equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD) == false && !looterItems.hasRoomInventory(weight))
return null;
//attempt to transfer item in db
if (item.template.item_type.equals(ItemType.GOLD)) {
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD)) {
if (!looterItems.moveGoldToInventory(item, item.getNumOfItems()))
return null;
} else if (!item.moveItemToInventory(looter))
+2 -2
View File
@@ -463,7 +463,7 @@ public class Item extends AbstractWorldObject {
int serialized = 0;
for (Item item : list) {
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.numberOfItems == 0)
continue;
try {
@@ -497,7 +497,7 @@ public class Item extends AbstractWorldObject {
int serialized = 0;
for (Item item : list) {
if (item.template.item_type.equals(ItemType.GOLD))
if (item.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
if (item.numberOfItems == 0)
continue;
try {
+2 -2
View File
@@ -45,7 +45,7 @@ public final class MobLoot extends Item {
this.ownerID = mob.getObjectUUID();
this.objectUUID = generateId();
if (quantity == 0 && template.item_type == ItemType.RESOURCE)
if (quantity == 0 && template.cacheTemplate.getItemType() == ItemType.RESOURCE)
quantity = 1;
if (quantity > 0)
@@ -105,7 +105,7 @@ public final class MobLoot extends Item {
if (isDeleted)
return null;
if (this.template.item_type.equals(ItemType.GOLD))
if (this.template.cacheTemplate.getItemType().equals(ItemType.GOLD))
return null;
Item item = this;
+1 -1
View File
@@ -969,7 +969,7 @@ public class NPC extends AbstractCharacter {
if (itemTemplate.item_skill_required.values().iterator().hasNext())
skillRequired = itemTemplate.item_skill_required.values().iterator().next();
boolean exclude = skillRequired == 0 && ItemTemplate.templates.get(itemID).item_type.equals(ItemType.WEAPON);
boolean exclude = skillRequired == 0 && ItemTemplate.templates.get(itemID).cacheTemplate.getItemType().equals(ItemType.WEAPON);
if (skillRequired <= maxSkill && !exclude)
filteredItemList.add(itemID);
}
+2 -2
View File
@@ -2819,11 +2819,11 @@ public class PlayerCharacter extends AbstractCharacter {
ItemTemplate ib = item.template;
if (ib != null) {
if ((item.template.item_type.equals(ItemType.WEAPON))
if ((item.template.cacheTemplate.getItemType().equals(ItemType.WEAPON))
&& (item.template.item_skill_used.equals(type) || ib.item_skill_mastery_used.equals(type)))
return true;
return (item.template.item_type.equals(ItemType.ARMOR))
return (item.template.cacheTemplate.getItemType().equals(ItemType.ARMOR))
&& (item.template.item_skill_used.equals(type));
}
+1 -1
View File
@@ -162,7 +162,7 @@ public class Resists {
if (armor == null)
return phys;
if (armor.template.item_type.equals(mbEnums.ItemType.ARMOR)) {
if (armor.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.ARMOR)) {
phys[0] += armor.template.combat_attack_resist.get("SLASHING");
phys[1] += armor.template.combat_attack_resist.get("CRUSHING");
phys[2] += armor.template.combat_attack_resist.get("PIERCING");
+1 -1
View File
@@ -304,7 +304,7 @@ public class Warehouse {
return false;
}
if (resource.template.item_type.equals(mbEnums.ItemType.GOLD))
if (resource.template.cacheTemplate.getItemType().equals(mbEnums.ItemType.GOLD))
resourceType = mbEnums.ResourceType.GOLD;
else
resourceType = mbEnums.ResourceType.valueOf(ItemTemplate.templates.get(resource.templateID).item_base_name.toUpperCase());