forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
1 year ago
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||
|
// 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;
|
||
|
}
|
||
|
|
||
|
}
|