Browse Source

Minor class cleanup

combat-2
MagicBot 7 months ago
parent
commit
4a3a8d4b65
  1. 27
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

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

@ -218,16 +218,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
case REALMCHARTER: case REALMCHARTER:
case SCROLL: case SCROLL:
case POTION: case POTION:
itemValue = 0;
continue; continue;
} }
totalValue += itemValue; totalValue += itemValue;
long start = System.currentTimeMillis();
vendor.charItemManager.recycle(targetItem); vendor.charItemManager.recycle(targetItem);
long end = System.currentTimeMillis();
long timetook = end - start;
// ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish");
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE.ordinal(), true); outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE.ordinal(), true);
@ -240,18 +234,12 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (!vendor.getBuilding().transferGold(totalValue, false)) if (!vendor.getBuilding().transferGold(totalValue, false))
return; return;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} finally { } finally {
origin.sellLock.unlock(); origin.sellLock.unlock();
} }
} }
// Refresh vendor's inventory to client
} }
// Method handles recycling of an item // Method handles recycling of an item
@ -271,12 +259,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (player == null) if (player == null)
return; return;
// Can't junk nothing! // junk nothing?
if (targetItem == null) if (targetItem == null)
return; return;
if (!vendor.charItemManager.forgeContains(targetItem, vendor)) if (!vendor.charItemManager.forgeContains(targetItem, vendor))
return; return;
@ -296,7 +283,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
outMsg.setMessageType(1); outMsg.setMessageType(1);
dispatch = Dispatch.borrow(player, outMsg); dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
;
} finally { } finally {
origin.sellLock.unlock(); origin.sellLock.unlock();
} }
@ -304,34 +290,26 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
} }
// Method junks an item that has been rolled but not completed
private static void takeItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) { private static void takeItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) {
Item targetItem; Item targetItem;
PlayerCharacter player = origin.getPlayerCharacter(); PlayerCharacter player = origin.getPlayerCharacter();
if (player == null) if (player == null)
return; return;
for (int itemUUID : itemList.keySet()) { for (int itemUUID : itemList.keySet()) {
int type = itemList.get(itemUUID); int type = itemList.get(itemUUID);
if (type == GameObjectType.Item.ordinal()) { if (type == GameObjectType.Item.ordinal()) {
targetItem = Item.getFromCache(itemUUID); targetItem = Item.getFromCache(itemUUID);
} else { } else
targetItem = MobLoot.getFromCache(itemUUID); 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)
@ -341,7 +319,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
return; return;
player.charItemManager.buyFromNPC(targetItem, vendor); player.charItemManager.buyFromNPC(targetItem, vendor);
} }
player.charItemManager.updateInventory(); player.charItemManager.updateInventory();

Loading…
Cancel
Save