forked from MagicBane/Server
MagicBot
8 months ago
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; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue