Browse Source

Refactor out itembase

combat-2
MagicBot 8 months ago
parent
commit
6ed4faded2
  1. 2
      src/engine/db/handlers/dbItemHandler.java
  2. 2
      src/engine/devcmd/cmds/InfoCmd.java
  3. 2
      src/engine/devcmd/cmds/PrintBankCmd.java
  4. 2
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  5. 2
      src/engine/devcmd/cmds/PrintEquipCmd.java
  6. 2
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  7. 2
      src/engine/devcmd/cmds/PrintVaultCmd.java
  8. 2
      src/engine/gameManager/ChatManager.java
  9. 6
      src/engine/gameManager/LootManager.java
  10. 2
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  11. 2
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  12. 4
      src/engine/net/client/msg/ItemProductionMsg.java
  13. 4
      src/engine/net/client/msg/ManageNPCMsg.java
  14. 20
      src/engine/objects/Item.java
  15. 20
      src/engine/objects/ItemFactory.java
  16. 6
      src/engine/objects/Warehouse.java

2
src/engine/db/handlers/dbItemHandler.java

@ -61,7 +61,7 @@ public class dbItemHandler extends dbHandlerBase { @@ -61,7 +61,7 @@ public class dbItemHandler extends dbHandlerBase {
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
preparedStatement.setInt(1, toAdd.ownerID);
preparedStatement.setInt(2, toAdd.getTemplsteID());
preparedStatement.setInt(2, toAdd.getTemplateID());
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
preparedStatement.setInt(4, (short) toAdd.durabilityCurrent);
preparedStatement.setInt(5, (int) toAdd.template.item_health_full);

2
src/engine/devcmd/cmds/InfoCmd.java

@ -506,7 +506,7 @@ public class InfoCmd extends AbstractDevCmd { @@ -506,7 +506,7 @@ public class InfoCmd extends AbstractDevCmd {
case MobLoot:
Item item = (Item) target;
ItemBase itemBase = item.getItemBase();
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
output += "Weight: " + template.item_wt;
output += newline;

2
src/engine/devcmd/cmds/PrintBankCmd.java

@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd { @@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd {
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
}

2
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd { @@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd {
if (target instanceof Item) {
type = "Item";
tar = (Item) target;
ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplateID());
name = template.item_base_name;
} else if (target instanceof AbstractCharacter) {
tar = (AbstractCharacter) target;

2
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -89,7 +89,7 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -89,7 +89,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
for (Enum.EquipSlotType slot : list.keySet()) {
Item item = list.get(slot);
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);
}
}

2
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -75,7 +75,7 @@ public class PrintInventoryCmd extends AbstractDevCmd { @@ -75,7 +75,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
int goldCount = 0;
for (Item item : inventory) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID);
ItemTemplate template = ItemTemplate.itemTemplates.get(item.templateID);
if (item.template.item_type.equals(ItemType.GOLD) == false) {

2
src/engine/devcmd/cmds/PrintVaultCmd.java

@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd { @@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
}
Item gold = cim.getGoldVault();

2
src/engine/gameManager/ChatManager.java

@ -612,7 +612,7 @@ public enum ChatManager { @@ -612,7 +612,7 @@ public enum ChatManager {
name = amount + " gold ";
else {
String vowels = "aeiou";
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
String iName = template.item_base_name;
if (iName.length() > 0)
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)

6
src/engine/gameManager/LootManager.java

@ -87,7 +87,7 @@ public enum LootManager { @@ -87,7 +87,7 @@ public enum LootManager {
if (ib == null)
break;
ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplateID());
if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
@ -381,8 +381,8 @@ public enum LootManager { @@ -381,8 +381,8 @@ public enum LootManager {
int tableID = 0;
if (_bootySetMap.get(gift.getTemplsteID()) != null)
tableID = _bootySetMap.get(gift.getTemplsteID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplsteID()).size())).genTable;
if (_bootySetMap.get(gift.getTemplateID()) != null)
tableID = _bootySetMap.get(gift.getTemplateID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplateID()).size())).genTable;
if (tableID == 0)
return;

2
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -50,7 +50,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { @@ -50,7 +50,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
for (Item hirelings : player.getInventory()) {
if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID);
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
if (contract == null)
continue;

2
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -77,7 +77,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { @@ -77,7 +77,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) {
int uuid = item.templsteID;
int uuid = item.templateID;
switch (item.template.item_type) {

4
src/engine/net/client/msg/ItemProductionMsg.java

@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(this.itemUUID);
writer.putInt(0); //items left to produce?
if (toRoll != null) {
writer.putInt(toRoll.getTemplsteID());
writer.putInt(toRoll.getTemplateID());
writer.putInt(toRoll.getValue());
} else {
writer.putInt(0);
@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg {
timeLeft /= 1000;
writer.putInt((int) timeLeft);
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplsteID()));
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplateID()));
}
} else {

4
src/engine/net/client/msg/ManageNPCMsg.java

@ -450,14 +450,14 @@ public class ManageNPCMsg extends ClientNetMsg { @@ -450,14 +450,14 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(i.getObjectUUID());
writer.putInt(0);
writer.putInt(i.getTemplsteID());
writer.putInt(i.getTemplateID());
writer.putInt(template.item_value);
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
timeLife /= 1000;
writer.putInt((int) timeLife);
writer.putInt(npc.getRollingTimeInSeconds(i.getTemplsteID()));
writer.putInt(npc.getRollingTimeInSeconds(i.getTemplateID()));
writer.putInt(1);
if (i.isComplete())

20
src/engine/objects/Item.java

@ -52,7 +52,7 @@ public class Item extends AbstractWorldObject { @@ -52,7 +52,7 @@ public class Item extends AbstractWorldObject {
private boolean isRandom = false;
private int value;
public OwnerType ownerType;
public int templsteID;
public int templateID;
private AbstractWorldObject lastOwner;
private long dateToUpgrade;
private String customName = "";
@ -67,7 +67,7 @@ public class Item extends AbstractWorldObject { @@ -67,7 +67,7 @@ public class Item extends AbstractWorldObject {
public Item(int templateID) {
super();
this.templsteID = templateID;
this.templateID = templateID;
this.template = ItemTemplate.itemTemplates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges;
this.durabilityCurrent = this.template.combat_health_full;
@ -84,11 +84,11 @@ public class Item extends AbstractWorldObject { @@ -84,11 +84,11 @@ public class Item extends AbstractWorldObject {
public Item(ResultSet rs) throws SQLException {
super(rs);
this.templsteID = rs.getInt("item_itemBaseID");
this.template = ItemTemplate.itemTemplates.get(this.templsteID);
this.templateID = rs.getInt("item_itemBaseID");
this.template = ItemTemplate.itemTemplates.get(this.templateID);
if (this.template == null)
Logger.error("Null template of " + this.templsteID)
Logger.error("Null template of " + this.templateID)
;
// Set container enumeration
@ -227,7 +227,7 @@ public class Item extends AbstractWorldObject { @@ -227,7 +227,7 @@ public class Item extends AbstractWorldObject {
writer.putInt(0); // Pad
writer.putInt(0); // Pad
if (item.getItemBase().equals(ItemBase.GOLD_ITEM_BASE)) {
if (item.templateID == ResourceType.GOLD.templateID) {
if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter player = (PlayerCharacter) item.getOwner();
@ -660,11 +660,11 @@ public class Item extends AbstractWorldObject { @@ -660,11 +660,11 @@ public class Item extends AbstractWorldObject {
}
public ItemBase getItemBase() {
return ItemBase.getItemBase(templsteID);
return ItemBase.getItemBase(templateID);
}
public int getTemplsteID() {
return this.templsteID;
public int getTemplateID() {
return this.templateID;
}
public int getOwnerID() {
@ -1012,7 +1012,7 @@ public class Item extends AbstractWorldObject { @@ -1012,7 +1012,7 @@ public class Item extends AbstractWorldObject {
if (this.customName.isEmpty() == false)
return this.customName;
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplsteID());
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplateID());
return template.item_base_name;
}

20
src/engine/objects/ItemFactory.java

@ -179,8 +179,8 @@ public class ItemFactory { @@ -179,8 +179,8 @@ public class ItemFactory {
time = (20 - rate);
time *= MBServerStatics.ONE_MINUTE;
if (ml.templsteID > 910010 && ml.templsteID < 910019) {
rank = ml.getTemplsteID() - 910010;
if (ml.templateID > 910010 && ml.templateID < 910019) {
rank = ml.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000;
}
@ -201,8 +201,8 @@ public class ItemFactory { @@ -201,8 +201,8 @@ public class ItemFactory {
if (pc != null)
playerID = pc.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, "", "", "", false, playerID);
ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, "", "", "", playerID);
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, "", "", "", false, playerID);
ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, "", "", "", playerID);
pi.setProducedItemID(ml.getObjectUUID());
pi.setAmount(itemsToRoll);
pi.setRandom(false);
@ -589,7 +589,7 @@ public class ItemFactory { @@ -589,7 +589,7 @@ public class ItemFactory {
time *= MBServerStatics.ONE_MINUTE;
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
rank = ml.getTemplsteID() - 910010;
rank = ml.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000;
}
@ -610,8 +610,8 @@ public class ItemFactory { @@ -610,8 +610,8 @@ public class ItemFactory {
if (pc != null)
playerID = pc.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
pi.setProducedItemID(ml.getObjectUUID());
pi.setAmount(itemsToRoll);
@ -728,7 +728,7 @@ public class ItemFactory { @@ -728,7 +728,7 @@ public class ItemFactory {
time *= MBServerStatics.ONE_MINUTE;
if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) {
rank = toRoll.getTemplsteID() - 910010;
rank = toRoll.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000;
}
@ -748,9 +748,9 @@ public class ItemFactory { @@ -748,9 +748,9 @@ public class ItemFactory {
if (playerCharacter != null)
playerID = playerCharacter.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
pi.setProducedItemID(toRoll.getObjectUUID());
pi.setAmount(itemsToRoll);
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));

6
src/engine/objects/Warehouse.java

@ -223,7 +223,7 @@ public class Warehouse extends AbstractWorldObject { @@ -223,7 +223,7 @@ public class Warehouse extends AbstractWorldObject {
return false;
}
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templsteID);
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templateID);
if (warehouse.resources.get(resourceType) == null)
return false;
@ -251,7 +251,7 @@ public class Warehouse extends AbstractWorldObject { @@ -251,7 +251,7 @@ public class Warehouse extends AbstractWorldObject {
int newAmount = oldAmount + amount;
if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templsteID).deposit_limit) {
if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templateID).deposit_limit) {
//ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource.");
return false;
}
@ -293,7 +293,7 @@ public class Warehouse extends AbstractWorldObject { @@ -293,7 +293,7 @@ public class Warehouse extends AbstractWorldObject {
if (resource.template.item_type.equals(Enum.ItemType.GOLD))
resourceType = Enum.ResourceType.GOLD;
else
resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase());
resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplateID()).item_base_name.toUpperCase());
if (transaction)
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);

Loading…
Cancel
Save