Handler created for CommitToTradeMsg

This commit is contained in:
2024-03-29 08:44:12 -04:00
parent 3a2b138deb
commit 2768980f6e
5 changed files with 82 additions and 68 deletions
@@ -474,47 +474,6 @@ public class CharacterItemManager {
return modifyCommitToTrade();
}
public synchronized boolean commitToTrade(CommitToTradeMsg msg) {
PlayerCharacter source = (PlayerCharacter) this.getOwner();
if (source == null || !source.isAlive())
return false;
this.setTradeCommitted((byte) 1);
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;
modifyCommitToTrade();
if (this.getTradeCommitted() == (byte) 1 && tradingWith.getTradeCommitted() == (byte) 1) {
int tradeID = this.tradeID;
CloseTradeWindowMsg ctwm1 = new CloseTradeWindowMsg(source, tradeID);
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID);
this.commitTrade();
this.closeTradeWindow(ctwm1, false);
other.charItemManager.closeTradeWindow(ctwm2, false);
}
return true;
}
public synchronized boolean modifyCommitToTrade() {
CharacterItemManager man1 = this;