forked from MagicBane/Server
MagicBot
8 months ago
4 changed files with 70 additions and 29 deletions
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.CloseTradeWindowMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class CloseTradeWindowMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public CloseTradeWindowMsgHandler() { |
||||
super(CloseTradeWindowMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
CloseTradeWindowMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (CloseTradeWindowMsg) baseMsg; |
||||
|
||||
Dispatch dispatch; |
||||
|
||||
if (source == null) |
||||
return false; |
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager; |
||||
|
||||
if (sourceItemMan == null) |
||||
return false; |
||||
|
||||
int tradeID = source.charItemManager.tradeID; |
||||
CloseTradeWindowMsg closeMsg = new CloseTradeWindowMsg(source, tradeID); |
||||
|
||||
dispatch = Dispatch.borrow(source, closeMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
ClientConnection cc2 = sourceItemMan.getTradingWith(); |
||||
|
||||
if (cc2 == null || cc2.getPlayerCharacter() == null) { |
||||
sourceItemMan.endTrade(); |
||||
return true; |
||||
} |
||||
|
||||
sourceItemMan.endTrade(); |
||||
cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue