Refactor item_type

This commit is contained in:
2024-03-10 13:34:24 -04:00
parent 87290baa52
commit df5c607375
24 changed files with 137 additions and 203 deletions
@@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
// Filter hirelings by slot type
for (Item hirelings : player.getInventory()) {
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID);
if (contract == null)
continue;
@@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.Guild;
import engine.objects.Item;
import engine.objects.ItemBase;
import engine.objects.PlayerCharacter;
import engine.util.StringUtils;
@@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
Enum.GuildCharterType charterType;
Guild newGuild;
Guild playerGuild;
ItemBase itemBase;
Item charter;
Dispatch dispatch;
@@ -69,16 +68,14 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
return true;
}
itemBase = charter.getItemBase();
// Item must be a valid charterType (type 10 in db)
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
if (charter == null || (charter.template.item_type.equals(ItemType.CHARTER) == false)) {
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
return true;
}
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase);
charterType = Enum.GuildCharterType.getGuildTypeFromCharter(charter);
if (charterType == null) {
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
@@ -126,7 +126,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
return;
if (targetItem.getItemBase().getType() == ItemType.GOLD)
if (targetItem.template.item_type.equals(ItemType.GOLD))
return;
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) {
@@ -266,7 +266,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem == null)
continue;
if (targetItem.getItemBase().getType() == ItemType.GOLD)
if (targetItem.template.item_type.equals(ItemType.GOLD))
return;
if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID()))
@@ -281,13 +281,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
break;
}
switch (targetItem.getItemBase().getType()) {
case CONTRACT:
case GUILDCHARTER:
switch (targetItem.template.item_type) {
case EMPLOYMENTCONTRACT:
case CHARTER:
case DEED:
case REALMCHARTER:
case SCROLL:
case TEARS:
case POTION:
itemValue = 0;
continue;
}
@@ -402,7 +402,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
return;
if (targetItem.getItemBase().getType() == ItemType.GOLD)
if (targetItem.template.item_type.equals(ItemType.GOLD))
return;
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
return;
@@ -315,18 +315,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) {
if (ib.isConsumable() || ib.getType() == ItemType.FARMABLE) {
if (ib.isConsumable() || item.template.item_type.equals(ItemType.REAGENT)) {
int uuid = ib.getUUID();
int type = ib.getType().getValue();
int uuid = item.templsteID;
switch (type) {
case 27: //Mithril repair
break;
case 10: //charters
//don't think they're handled here?
break;
case 19: //buildings
switch (item.template.item_type) {
case DEED: //buildings
//Call add building screen here, ib.getUseID() get's building ID
//if inside player city, center loc on tol. otherwise center on player.
@@ -352,10 +347,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
//itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent.
break;
case 25: //furniture
case FURNITUREDEED: //furniture
//Call add furniture screen here. ib.getUseID() get's furniture ID
break;
case 33:
case OFFERING:
long shrineCompID = comps.get(1);
Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID);
if (shrineBuilding == null) {
@@ -381,7 +376,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
}
break;
case 35:
case REALMCHARTER:
int charterType = 0;
switch (uuid) {
case 910020:
@@ -398,7 +393,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
itemMan.consume(item);
}
break;
case 7: //rod of command
case WAND: //rod of command
long compID = comps.get(1);
int objectType = AbstractWorldObject.extractTypeID(compID).ordinal();
@@ -422,7 +417,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
}
break;
//ANNIVERSERY GIFT
case 31:
case TREASURE:
// *** Disabled for now: Needs bootyset created
//if (ib.getUUID() == 971012) {
@@ -440,13 +435,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
// break;
//}
LootManager.peddleFate(player,item);
LootManager.peddleFate(player, item);
break;
case 30: //water bucket
case 8: //potions, tears of saedron
case BUCKET: //water bucket
case POTION: //potions, tears of saedron
case 5: //runes, petition, warrant, scrolls
case SCROLL: //runes, petition, warrant, scrolls
if (uuid > 3000 && uuid < 3050) { //Discipline Runes
if (ApplyRuneMsg.applyRune(uuid, origin, player)) {
itemMan.consume(item);