Handler created for UnCommitToTradeMsg

This commit is contained in:
2024-03-29 08:48:43 -04:00
parent 2768980f6e
commit 5f16289052
5 changed files with 68 additions and 57 deletions
@@ -0,0 +1,67 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.UncommitToTradeMsg;
import engine.objects.CharacterItemManager;
import engine.objects.PlayerCharacter;
import static engine.objects.CharacterItemManager.canTrade;
public class UncommitToTradeMsgHandler extends AbstractClientMsgHandler {
public UncommitToTradeMsgHandler() {
super(UncommitToTradeMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter source = origin.getPlayerCharacter();
// Member variable declaration
UncommitToTradeMsg msg;
// Member variable assignment
msg = (UncommitToTradeMsg) baseMsg;
if (source == null || !source.isAlive())
return true;
CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null)
return true;
sourceItemMan.setTradeCommitted((byte) 0);
ClientConnection ccOther = sourceItemMan.getTradingWith();
if (ccOther == null)
return true;
PlayerCharacter other = ccOther.getPlayerCharacter();
if (other == null)
return true;
if (!canTrade(source, other))
return true;
source.charItemManager.modifyCommitToTrade();
return true;
}
}