public void cancelRegisteredItem(Player player, int brokerItemId) { if (player.getInventory().isFull()) { PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(901298)); return; } int playerId = player.getObjectId(); Map<Integer, BrokerItem> brokerItems = getRaceBrokerItems(player.getCommonData().getRace()); BrokerItem brokerItem = brokerItems.get(brokerItemId); if (brokerItem == null) return; if (playerId != brokerItem.getSellerId()) { Logger.getLogger(this.getClass()) .info( "[AUDIT]Player: " + player.getName() + " is trying to steal: " + brokerItem.getItemId() + " => Hacking!"); return; } synchronized (brokerItem) { if (brokerItem != null) { Item item = player.getInventory().putToBag(brokerItem.getItem()); PacketSendUtility.sendPacket(player, new SM_INVENTORY_UPDATE(item, true)); PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(brokerItemId, 4)); brokerItem.setPersistentState(PersistentState.DELETED); saveManager.add(new BrokerOpSaveTask(brokerItem)); brokerItems.remove(brokerItemId); } showRegisteredItems(player); } }
private void checkExpiredItems() { Map<Integer, BrokerItem> asmoBrokerItems = getRaceBrokerItems(Race.ASMODIANS); Map<Integer, BrokerItem> elyosBrokerItems = getRaceBrokerItems(Race.ELYOS); Timestamp currentTime = new Timestamp(Calendar.getInstance().getTimeInMillis()); for (BrokerItem item : asmoBrokerItems.values()) { if (item != null && item.getExpireTime().getTime() <= currentTime.getTime()) { expireItem(Race.ASMODIANS, item); asmodianBrokerItems.remove(item.getItemUniqueId()); } } for (BrokerItem item : elyosBrokerItems.values()) { if (item != null && item.getExpireTime().getTime() <= currentTime.getTime()) { expireItem(Race.ELYOS, item); this.elyosBrokerItems.remove(item.getItemUniqueId()); } } }
public void removePlayerCache(Player player) { playerBrokerCache.remove(player.getObjectId()); }
public void settleAccount(Player player) { Race playerRace = player.getCommonData().getRace(); Map<Integer, BrokerItem> brokerSettledItems = getRaceBrokerSettledItems(playerRace); List<BrokerItem> collectedItems = new ArrayList<BrokerItem>(); int playerId = player.getObjectId(); long kinahCollect = 0; boolean itemsLeft = false; for (BrokerItem item : brokerSettledItems.values()) { if (item.getSellerId() == playerId) collectedItems.add(item); } for (BrokerItem item : collectedItems) { if (item.isSold()) { boolean result = false; switch (playerRace) { case ASMODIANS: result = asmodianSettledItems.remove(item.getItemUniqueId()) != null; break; case ELYOS: result = elyosSettledItems.remove(item.getItemUniqueId()) != null; break; } if (result) { item.setPersistentState(PersistentState.DELETED); saveManager.add(new BrokerOpSaveTask(item)); kinahCollect += item.getPrice(); } } else { if (item.getItem() != null) { Item resultItem = player.getInventory().putToBag(item.getItem()); if (resultItem != null) { boolean result = false; switch (playerRace) { case ASMODIANS: result = asmodianSettledItems.remove(item.getItemUniqueId()) != null; break; case ELYOS: result = elyosSettledItems.remove(item.getItemUniqueId()) != null; break; } if (result) { item.setPersistentState(PersistentState.DELETED); saveManager.add(new BrokerOpSaveTask(item)); PacketSendUtility.sendPacket( player, new SM_INVENTORY_UPDATE(Collections.singletonList(resultItem))); } } else itemsLeft = true; } else log.warn("Broker settled item missed. ObjID: " + item.getItemUniqueId()); } } player.getInventory().increaseKinah(kinahCollect); showSettledItems(player); if (!itemsLeft) PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(6)); }