Handler created for AddItemToTradeWindowMsg

This commit is contained in:
2024-03-29 08:34:29 -04:00
parent a70585448f
commit 3f1385dd33
5 changed files with 108 additions and 85 deletions
+1 -66
View File
@@ -444,71 +444,6 @@ public class CharacterItemManager {
return true;
}
public synchronized boolean addItemToTradeWindow(AddItemToTradeWindowMsg msg) {
PlayerCharacter source = (PlayerCharacter) this.getOwner();
Dispatch dispatch;
if (source == null || !source.isAlive())
return false;
ClientConnection ccOther = this.getTradingWith();
if (ccOther == null)
return false;
PlayerCharacter other = ccOther.getPlayerCharacter();
if (other == null || !other.isAlive())
return false;
CharacterItemManager tradingWith = other.charItemManager;
if (tradingWith == null)
return false;
if (!canTrade(source, other))
return false;
Item i = Item.getFromCache(msg.getItemID());
if (i == null)
return false;
if (!this.doesCharOwnThisItem(i.getObjectUUID()))
return false;
//can't add item to trade window twice
if (this.tradingContains(i))
return false;
//dupe check
if (!i.validForInventory(source.getClientConnection(), source, this))
return false;
if (!tradingWith.hasRoomTrade(i.template.item_wt)) {
dispatch = Dispatch.borrow(source, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
return false;
}
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(source, other);
this.setTradeCommitted((byte) 0);
tradingWith.setTradeCommitted((byte) 0);
this.addItemToTrade(i);
dispatch = Dispatch.borrow(other, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
modifyCommitToTrade();
dispatch = Dispatch.borrow(other, utwm);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
return true;
}
public synchronized boolean addGoldToTradeWindow(AddGoldToTradeWindowMsg msg) {
PlayerCharacter source = (PlayerCharacter) this.getOwner();
@@ -648,7 +583,7 @@ public class CharacterItemManager {
return true;
}
private synchronized boolean modifyCommitToTrade() {
public synchronized boolean modifyCommitToTrade() {
CharacterItemManager man1 = this;
if (this.getTradingWith() == null)