Browse Source

Mobloot vestiges removed

combat-2
MagicBot 7 months ago
parent
commit
e6d83ca36c
  1. 47
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

47
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -15,7 +15,6 @@ import engine.gameManager.DbManager;
import engine.gameManager.ForgeManager; import engine.gameManager.ForgeManager;
import engine.loot.WorkOrder; import engine.loot.WorkOrder;
import engine.mbEnums; import engine.mbEnums;
import engine.mbEnums.GameObjectType;
import engine.mbEnums.ItemType; import engine.mbEnums.ItemType;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
@ -24,7 +23,10 @@ import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.ItemProductionMsg; import engine.net.client.msg.ItemProductionMsg;
import engine.net.client.msg.ManageNPCMsg; import engine.net.client.msg.ManageNPCMsg;
import engine.objects.*; import engine.objects.CharacterItemManager;
import engine.objects.Item;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.HashMap; import java.util.HashMap;
@ -113,7 +115,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
depositItem(msg.itemUUID, vendor, origin); depositItem(msg.itemUUID, vendor, origin);
break; break;
case SETPRICE: case SETPRICE:
setItemPrice(msg.itemType, msg.itemUUID, msg.itemPrice, vendor, origin); setItemPrice(msg.itemUUID, msg.itemPrice, vendor, origin);
break; break;
case TAKE: case TAKE:
takeItem(msg.items, vendor, origin); takeItem(msg.items, vendor, origin);
@ -151,7 +153,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
} }
private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) {
Item targetItem; Item targetItem;
ItemProductionMsg outMsg; ItemProductionMsg outMsg;
@ -162,35 +164,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (player == null) if (player == null)
return; return;
if (itemType == GameObjectType.Item.ordinal())
targetItem = Item.getFromCache(itemUUID); targetItem = Item.getFromCache(itemUUID);
else if (itemType == GameObjectType.MobLoot.ordinal())
targetItem = MobLoot.getFromCache(itemUUID);
else
targetItem = null;
if (targetItem == null) if (targetItem == null)
return; return;
if (targetItem.getObjectType() == GameObjectType.Item) {
if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) {
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
return; return;
} }
targetItem.setValue(itemPrice);
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true);
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true);
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
} else if (targetItem.getObjectType() == GameObjectType.MobLoot) {
MobLoot mobLoot = (MobLoot) targetItem;
if (!DbManager.NPCQueries.UPDATE_ITEM_PRICE(mobLoot.getObjectUUID(), vendor.getObjectUUID(), itemPrice)) {
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
return;
}
targetItem.setValue(itemPrice); targetItem.setValue(itemPrice);
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true);
dispatch = Dispatch.borrow(player, outMsg); dispatch = Dispatch.borrow(player, outMsg);
@ -199,7 +182,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true);
dispatch = Dispatch.borrow(player, outMsg); dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
}
} }
// Method sets the price on an item in the vendor inventory // Method sets the price on an item in the vendor inventory
@ -299,12 +282,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
for (int itemUUID : itemList.keySet()) { for (int itemUUID : itemList.keySet()) {
int itemValue = 0; int itemValue = 0;
int type = itemList.get(itemUUID);
if (type == GameObjectType.Item.ordinal())
targetItem = Item.getFromCache(itemUUID); targetItem = Item.getFromCache(itemUUID);
else
targetItem = MobLoot.getFromCache(itemUUID);
if (targetItem == null) if (targetItem == null)
continue; continue;
@ -314,6 +292,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID()))
continue; continue;
if (vendor.charItemManager.inventoryContains(targetItem) == false) if (vendor.charItemManager.inventoryContains(targetItem) == false)
continue; continue;
@ -333,6 +312,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
case POTION: case POTION:
continue; continue;
} }
totalValue += itemValue; totalValue += itemValue;
vendor.charItemManager.recycle(targetItem); vendor.charItemManager.recycle(targetItem);
@ -344,8 +324,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
// Refund a portion of the gold // Refund a portion of the gold
if (!vendor.getBuilding().transferGold(totalValue, false)) vendor.getBuilding().transferGold(totalValue, false);
return;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
@ -414,18 +393,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
for (int itemUUID : itemList.keySet()) { for (int itemUUID : itemList.keySet()) {
int type = itemList.get(itemUUID);
if (type == GameObjectType.Item.ordinal()) {
targetItem = Item.getFromCache(itemUUID); targetItem = Item.getFromCache(itemUUID);
} else
targetItem = MobLoot.getFromCache(itemUUID);
if (targetItem == null) if (targetItem == null)
return; return;
if (targetItem.template.item_type.equals(ItemType.GOLD)) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (vendor.charItemManager.inventoryContains(targetItem) == false) if (vendor.charItemManager.inventoryContains(targetItem) == false)
return; return;

Loading…
Cancel
Save