forked from MagicBane/Server
FatBoy-DOTC
8 months ago
59 changed files with 3036 additions and 2001 deletions
@ -1,161 +0,0 @@
@@ -1,161 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.gameManager; |
||||
|
||||
import engine.Enum; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.*; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
public enum TradeManager { |
||||
|
||||
TRADEMANAGER; |
||||
|
||||
public static void tradeRequest(TradeRequestMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null) |
||||
return; |
||||
|
||||
source.charItemManager.tradeRequest(msg); |
||||
|
||||
} |
||||
|
||||
|
||||
public static void acceptTradeRequest(AcceptTradeRequestMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null) |
||||
return; |
||||
|
||||
try { |
||||
source.charItemManager.acceptTradeRequest(msg); |
||||
} catch (Exception e) { |
||||
Logger.error(e); |
||||
// TODO Auto-generated catch block
|
||||
} |
||||
|
||||
} |
||||
|
||||
public static void rejectTradeRequest(RejectTradeRequestMsg msg, ClientConnection origin) { |
||||
// TODO Do nothing? If so, delete this method & case above
|
||||
} |
||||
|
||||
public static void addItemToTradeWindow(AddItemToTradeWindowMsg msg, ClientConnection origin) { |
||||
|
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
if (source == null || !source.isAlive()) |
||||
return; |
||||
try { |
||||
source.charItemManager.addItemToTradeWindow(msg); |
||||
|
||||
} catch (Exception e) { |
||||
Logger.error(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static void addGoldToTradeWindow(AddGoldToTradeWindowMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return; |
||||
|
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager; |
||||
|
||||
if (sourceItemMan == null) |
||||
return; |
||||
|
||||
try { |
||||
sourceItemMan.addGoldToTradeWindow(msg); |
||||
} catch (Exception e) { |
||||
Logger.error(e); |
||||
} |
||||
} |
||||
|
||||
public static void commitToTrade(CommitToTradeMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return; |
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager; |
||||
|
||||
if (sourceItemMan == null) |
||||
return; |
||||
|
||||
try { |
||||
sourceItemMan.commitToTrade(msg); |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e); |
||||
} |
||||
} |
||||
|
||||
public static void uncommitToTrade(UncommitToTradeMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return; |
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager; |
||||
|
||||
if (sourceItemMan == null) |
||||
return; |
||||
|
||||
try { |
||||
sourceItemMan.uncommitToTrade(msg); |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
public static void closeTradeWindow(CloseTradeWindowMsg msg, ClientConnection origin) { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
if (source == null) |
||||
return; |
||||
|
||||
CharacterItemManager sourceItemMan = source.charItemManager; |
||||
|
||||
if (sourceItemMan == null) |
||||
return; |
||||
|
||||
try { |
||||
sourceItemMan.closeTradeWindow(msg, true); |
||||
} catch (Exception e) { |
||||
// TODO Auto-generated catch block
|
||||
Logger.error(e); |
||||
} |
||||
} |
||||
|
||||
public static void invalidTradeRequest(InvalidTradeRequestMsg msg) { |
||||
PlayerCharacter requester = PlayerCharacter.getFromCache(msg.getRequesterID()); |
||||
Dispatch dispatch; |
||||
|
||||
dispatch = Dispatch.borrow(requester, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.Protocol; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.chat.*; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
import static engine.gameManager.ChatManager.FLOOD_QTY_THRESHOLD; |
||||
import static engine.gameManager.ChatManager.FLOOD_TIME_THRESHOLD; |
||||
|
||||
public class AbstractChatMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public AbstractChatMsgHandler() { |
||||
super(AbstractChatMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
AbstractChatMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AbstractChatMsg) baseMsg; |
||||
|
||||
if (msg == null) |
||||
return true; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
Protocol protocolMsg = msg.getProtocolMsg(); |
||||
|
||||
// Flood control, implemented per channel
|
||||
|
||||
boolean isFlood = false; |
||||
long curMsgTime = System.currentTimeMillis(); |
||||
long checkTime = playerCharacter.chatFloodTime(protocolMsg.opcode, curMsgTime, FLOOD_QTY_THRESHOLD - 1); |
||||
|
||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD)) |
||||
isFlood = true; |
||||
|
||||
switch (protocolMsg) { |
||||
case CHATSAY: |
||||
ChatManager.chatSay(playerCharacter, msg.getMessage(), isFlood); |
||||
return true; |
||||
case CHATCSR: |
||||
ChatManager.chatCSR(msg); |
||||
return true; |
||||
case CHATTELL: |
||||
ChatTellMsg ctm = (ChatTellMsg) msg; |
||||
ChatManager.chatTell(playerCharacter, ctm.getTargetName(), ctm.getMessage(), isFlood); |
||||
return true; |
||||
case CHATSHOUT: |
||||
ChatManager.chatShout(playerCharacter, msg.getMessage(), isFlood); |
||||
return true; |
||||
case CHATGUILD: |
||||
ChatManager.chatGuild(playerCharacter, (ChatGuildMsg) msg); |
||||
return true; |
||||
case CHATGROUP: |
||||
ChatManager.chatGroup(playerCharacter, (ChatGroupMsg) msg); |
||||
return true; |
||||
case CHATIC: |
||||
ChatManager.chatIC(playerCharacter, (ChatICMsg) msg); |
||||
return true; |
||||
case LEADERCHANNELMESSAGE: |
||||
case GLOBALCHANNELMESSAGE: |
||||
ChatManager.chatGlobal(playerCharacter, msg.getMessage(), isFlood); |
||||
return true; |
||||
case CHATPVP: |
||||
case CHATCITY: |
||||
case CHATINFO: |
||||
case SYSTEMBROADCASTCHANNEL: |
||||
default: |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.AcceptTradeRequestMsg; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.OpenTradeWindowMsg; |
||||
import engine.net.client.msg.UpdateVaultMsg; |
||||
import engine.objects.Account; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
import static engine.math.FastMath.sqr; |
||||
import static engine.objects.CharacterItemManager.canTrade; |
||||
|
||||
public class AcceptTradeRequestMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public AcceptTradeRequestMsgHandler() { |
||||
super(AcceptTradeRequestMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
// Member variable declaration
|
||||
|
||||
AcceptTradeRequestMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AcceptTradeRequestMsg) baseMsg; |
||||
|
||||
PlayerCharacter source = (PlayerCharacter) origin.getPlayerCharacter(); |
||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID()); |
||||
|
||||
Dispatch dispatch; |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return false; |
||||
|
||||
if (target == null || !target.isAlive()) |
||||
return false; |
||||
|
||||
if (source.charItemManager.tradingWith != null) |
||||
return false; |
||||
|
||||
if (!canTrade(source, target)) |
||||
return false; |
||||
|
||||
// verify characterTarget is in range
|
||||
if (source.getLoc().distanceSquared2D(target.getLoc()) > sqr(MBServerStatics.TRADE_RANGE)) |
||||
return false; |
||||
|
||||
// TODO uncomment this block after we determine when we
|
||||
// setBankOpen(false) and setVaultOpen(false)
|
||||
/* |
||||
* CharacterItemManager cim1 = source.getCharItemManager(); |
||||
* CharacterItemManager cim2 = characterTarget.getCharItemManager(); if (cim1 == |
||||
* null) return false; if (cim2 == null) return false; if (cim1.isBankOpen()) |
||||
* return false; if (cim2.isVaultOpen()) return false; |
||||
*/ |
||||
ClientConnection sourceConn = origin; |
||||
ClientConnection targetConn = target.getClientConnection(); |
||||
|
||||
if (sourceConn == null) |
||||
return false; |
||||
|
||||
if (targetConn == null) |
||||
return false; |
||||
|
||||
CharacterItemManager toTradeWith = target.charItemManager; |
||||
|
||||
if (toTradeWith == null) |
||||
return false; |
||||
|
||||
Account sourceAccount = source.getAccount(); |
||||
Account targetAccount = target.getAccount(); |
||||
|
||||
UpdateVaultMsg uvmSource = new UpdateVaultMsg(sourceAccount); |
||||
UpdateVaultMsg uvmTarget = new UpdateVaultMsg(targetAccount); |
||||
|
||||
dispatch = Dispatch.borrow(source, uvmSource); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
dispatch = Dispatch.borrow(target, uvmTarget); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
source.charItemManager.setVaultOpen(false); |
||||
toTradeWith.setVaultOpen(false); |
||||
source.charItemManager.setBankOpen(false); |
||||
toTradeWith.setBankOpen(false); |
||||
|
||||
OpenTradeWindowMsg otwm = new OpenTradeWindowMsg(msg.getUnknown01(), source, target); |
||||
|
||||
// Only start trade if both players aren't already trading with
|
||||
// someone
|
||||
|
||||
if (source.charItemManager.tradingWith != null || toTradeWith.getTradingWith() != null) |
||||
return false; |
||||
|
||||
source.charItemManager.initializeTrade(); |
||||
toTradeWith.initializeTrade(); |
||||
source.charItemManager.setTradingWith(targetConn); |
||||
toTradeWith.setTradingWith(sourceConn); |
||||
source.charItemManager.tradeID = msg.getUnknown01(); |
||||
toTradeWith.tradeID = msg.getUnknown01(); |
||||
|
||||
dispatch = Dispatch.borrow(source, otwm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
dispatch = Dispatch.borrow(target, otwm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.AddGoldToTradeWindowMsg; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.UpdateGoldMsg; |
||||
import engine.net.client.msg.UpdateTradeWindowMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade; |
||||
|
||||
public class AddGoldToTradeWindowMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public AddGoldToTradeWindowMsgHandler() { |
||||
super(AddGoldToTradeWindowMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
AddGoldToTradeWindowMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AddGoldToTradeWindowMsg) baseMsg; |
||||
Dispatch dispatch; |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return false; |
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith; |
||||
|
||||
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; |
||||
|
||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(other, source); |
||||
UpdateTradeWindowMsg utwmOther = new UpdateTradeWindowMsg(source, other); |
||||
|
||||
if (!canTrade(source, other)) |
||||
return false; |
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 0); |
||||
tradingWith.setTradeCommitted((byte) 0); |
||||
|
||||
int amt = msg.getAmount(); |
||||
|
||||
if (amt <= 0) { |
||||
Logger.info(source.getFirstName() + " added negative gold to trade window. Dupe attempt FAILED!"); |
||||
return false; |
||||
} |
||||
|
||||
if (amt > MBServerStatics.PLAYER_GOLD_LIMIT) |
||||
return false; |
||||
|
||||
if (source.charItemManager.getGoldInventory().getNumOfItems() - amt < 0) |
||||
return false; |
||||
|
||||
source.charItemManager.addGoldToTrade(amt); |
||||
|
||||
// BONUS CODE BELOW: Thanks some unknown retard!
|
||||
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true);
|
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(source); |
||||
ugm.configure(); |
||||
|
||||
source.charItemManager.modifyCommitToTrade(); |
||||
|
||||
dispatch = Dispatch.borrow(source, utwm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
dispatch = Dispatch.borrow(source, ugm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
dispatch = Dispatch.borrow(other, utwmOther); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.AddItemToTradeWindowMsg; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.UpdateTradeWindowMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.Item; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade; |
||||
|
||||
public class AddItemToTradeWindowMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public AddItemToTradeWindowMsgHandler() { |
||||
super(AddItemToTradeWindowMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
// Member variable declaration
|
||||
|
||||
AddItemToTradeWindowMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AddItemToTradeWindowMsg) baseMsg; |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
Dispatch dispatch; |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return false; |
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith; |
||||
|
||||
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; |
||||
|
||||
Item item = Item.getFromCache(msg.getItemID()); |
||||
|
||||
if (item == null) |
||||
return false; |
||||
|
||||
if (!source.charItemManager.doesCharOwnThisItem(item.getObjectUUID())) |
||||
return false; |
||||
|
||||
//can't add item to trade window twice
|
||||
if (source.charItemManager.tradingContains(item)) |
||||
return false; |
||||
|
||||
//dupe check
|
||||
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager)) |
||||
return false; |
||||
|
||||
if (!tradingWith.hasRoomTrade(item.template.item_wt)) { |
||||
dispatch = Dispatch.borrow(source, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
return false; |
||||
} |
||||
|
||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(source, other); |
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 0); |
||||
tradingWith.setTradeCommitted((byte) 0); |
||||
|
||||
source.charItemManager.addItemToTrade(item); |
||||
|
||||
dispatch = Dispatch.borrow(other, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
source.charItemManager.modifyCommitToTrade(); |
||||
|
||||
dispatch = Dispatch.borrow(other, utwm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.DevCmdManager; |
||||
import engine.gameManager.SessionManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.commands.ClientAdminCommandMsg; |
||||
import engine.objects.AbstractGameObject; |
||||
import engine.objects.AbstractWorldObject; |
||||
import engine.objects.Account; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
public class ClientAdminCommandMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ClientAdminCommandMsgHandler() { |
||||
super(ClientAdminCommandMsg.class); |
||||
} |
||||
|
||||
public static boolean processDevCommand(AbstractWorldObject sender, String text) { |
||||
|
||||
if (sender.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { |
||||
|
||||
PlayerCharacter pcSender = (PlayerCharacter) sender; |
||||
|
||||
// first remove the DEV_CMD_PREFIX
|
||||
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2); |
||||
|
||||
if (words[1].length() == 0) |
||||
return false; |
||||
|
||||
// next get the command
|
||||
String[] commands = words[1].split(" ", 2); |
||||
String cmd = commands[0].toLowerCase(); |
||||
String cmdArgument = ""; |
||||
|
||||
if (commands.length > 1) |
||||
cmdArgument = commands[1].trim(); |
||||
|
||||
AbstractGameObject target = pcSender.getLastTarget(); |
||||
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
||||
// target);
|
||||
return DevCmdManager.handleDevCmd(pcSender, cmd, |
||||
cmdArgument, target); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ClientAdminCommandMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ClientAdminCommandMsg) baseMsg; |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
Account acct = SessionManager.getAccount(player); |
||||
|
||||
if (acct == null) |
||||
return true; |
||||
|
||||
// require minimal access to continue
|
||||
// specific accessLevel checks performed by the DevCmdManager
|
||||
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) { |
||||
Logger.warn(player.getFirstName() + " Attempted to use a client admin command"); |
||||
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
||||
return true; |
||||
} |
||||
|
||||
// First remove the initial slash
|
||||
String d = msg.getMsgCommand(); |
||||
String[] words = d.split("/", 2); |
||||
|
||||
if (words[1].length() == 0) |
||||
return true; |
||||
|
||||
// Next get the command
|
||||
String[] commands = words[1].split(" ", 2); |
||||
String cmd = commands[0].toLowerCase(); |
||||
String cmdArgument = ""; |
||||
|
||||
if (commands.length > 1) |
||||
cmdArgument = commands[1].trim(); |
||||
|
||||
AbstractGameObject target = msg.getTarget(); |
||||
|
||||
// Map to a DevCmd
|
||||
String devCmd = ""; |
||||
|
||||
if (cmd.compareTo("goto") == 0) |
||||
devCmd = "goto"; |
||||
else if (cmd.compareTo("suspend") == 0) |
||||
devCmd = "suspend"; |
||||
else if (cmd.compareTo("getinfo") == 0) |
||||
devCmd = "info"; |
||||
else if (devCmd.isEmpty()) { |
||||
Logger.info("Unhandled admin command was used: /" |
||||
+ cmd); |
||||
return true; |
||||
} |
||||
|
||||
DevCmdManager.handleDevCmd(player, devCmd, cmdArgument, |
||||
target); |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.CloseTradeWindowMsg; |
||||
import engine.net.client.msg.CommitToTradeMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
import static engine.objects.CharacterItemManager.canTrade; |
||||
|
||||
public class CommitToTradeMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public CommitToTradeMsgHandler() { |
||||
super(CommitToTradeMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
CommitToTradeMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (CommitToTradeMsg) baseMsg; |
||||
|
||||
if (source == null || !source.isAlive()) |
||||
return false; |
||||
|
||||
source.charItemManager.setTradeCommitted((byte) 1); |
||||
|
||||
ClientConnection ccOther = source.charItemManager.tradingWith; |
||||
|
||||
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; |
||||
|
||||
source.charItemManager.modifyCommitToTrade(); |
||||
|
||||
if (source.charItemManager.getTradeCommitted() == (byte) 1 && tradingWith.getTradeCommitted() == (byte) 1) { |
||||
int tradeID = source.charItemManager.tradeID; |
||||
CloseTradeWindowMsg ctwm1 = new CloseTradeWindowMsg(source, tradeID); |
||||
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID); |
||||
source.charItemManager.commitTrade(); |
||||
source.charItemManager.closeTradeWindow(ctwm1, false); |
||||
other.charItemManager.closeTradeWindow(ctwm2, false); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum.DispatchChannel; |
||||
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.DeleteItemMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.Item; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class DeleteItemMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public DeleteItemMsgHandler() { |
||||
super(DeleteItemMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
DeleteItemMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (DeleteItemMsg) baseMsg; |
||||
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager; |
||||
int uuid = msg.getUUID(); |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
if (!player.isAlive()) |
||||
return true; |
||||
|
||||
Item item = Item.getFromCache(msg.getUUID()); |
||||
|
||||
if (item == null) |
||||
return true; |
||||
|
||||
if (!itemManager.doesCharOwnThisItem(item.getObjectUUID())) |
||||
return true; |
||||
|
||||
if (!itemManager.inventoryContains(item)) |
||||
return true; |
||||
|
||||
if (item.isCanDestroy()) |
||||
if (itemManager.delete(item) == true) { |
||||
Dispatch dispatch = Dispatch.borrow(player, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.gameManager.DbManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.IgnoreMsg; |
||||
import engine.objects.Account; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class IgnoreMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public IgnoreMsgHandler() { |
||||
super(IgnoreMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
IgnoreMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (IgnoreMsg) baseMsg; |
||||
|
||||
if (msg.nameToIgnore.isEmpty()) { // list ignored players
|
||||
String[] ignoredPlayers = playerCharacter.getIgnoredPlayerNames(); |
||||
String crlf = "\r\n"; |
||||
String out = "Ignored players (" + ignoredPlayers.length + "):"; |
||||
|
||||
for (String name : ignoredPlayers) |
||||
out += crlf + name; |
||||
|
||||
ChatManager.chatSystemInfo(playerCharacter, out); |
||||
return true; |
||||
} |
||||
|
||||
//FIX THIS, USE OUR CACHE!
|
||||
PlayerCharacter pcToIgnore = PlayerCharacter.getByFirstName(msg.nameToIgnore); |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
|
||||
if (pcToIgnore == null || pcToIgnore.getAccount() == null) { |
||||
ChatManager.chatSystemError(playerCharacter, "Character name " + msg.nameToIgnore + " does not exist and cannot be ignored."); |
||||
return true; |
||||
} |
||||
if (pcToIgnore.getObjectUUID() == playerCharacter.getObjectUUID()) { |
||||
ChatManager.chatSystemError(playerCharacter, "Try as you might, you are unable to ignore yourself!"); |
||||
return true; |
||||
} |
||||
String firstName = pcToIgnore.getFirstName(); |
||||
|
||||
Account account = playerCharacter.getAccount(); |
||||
|
||||
if (account == null) |
||||
return true; |
||||
|
||||
if (playerCharacter.isIgnoringPlayer(pcToIgnore)) { |
||||
|
||||
if (account != null) { |
||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), false, pcToIgnore.getFirstName())) { |
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list."); |
||||
} |
||||
} else { |
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list."); |
||||
} |
||||
|
||||
playerCharacter.removeIgnoredPlayer(pcToIgnore.getAccount()); |
||||
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is no longer ignored."); |
||||
} else { |
||||
|
||||
if (!PlayerCharacter.isIgnorable()) { |
||||
ChatManager.chatSystemError(playerCharacter, "This character cannot be ignored."); |
||||
return true; |
||||
} |
||||
|
||||
if (PlayerCharacter.isIgnoreListFull()) { |
||||
ChatManager.chatSystemError(playerCharacter, "Your ignore list is already full."); |
||||
return true; |
||||
} |
||||
|
||||
if (account != null) { |
||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), true, pcToIgnore.getFirstName())) { |
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list. This ignore will not persist past server down."); |
||||
} |
||||
} else { |
||||
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list."); |
||||
} |
||||
|
||||
playerCharacter.addIgnoredPlayer(pcToIgnore.getAccount(), pcToIgnore.getFirstName()); |
||||
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is now being ignored."); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.InvalidTradeRequestMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class InvalidTradeRequestMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public InvalidTradeRequestMsgHandler() { |
||||
super(InvalidTradeRequestMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
InvalidTradeRequestMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (InvalidTradeRequestMsg) baseMsg; |
||||
|
||||
Dispatch dispatch; |
||||
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,260 @@
@@ -0,0 +1,260 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.Enum.DispatchChannel; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.gameManager.GroupManager; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.*; |
||||
import engine.objects.*; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import static engine.math.FastMath.sqr; |
||||
|
||||
public class LootMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public LootMsgHandler() { |
||||
super(LootMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
LootMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (LootMsg) baseMsg; |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
if (!player.isAlive()) |
||||
return true; |
||||
|
||||
Item item = msg.getItem(); |
||||
|
||||
if (item == null) |
||||
return true; |
||||
|
||||
if (item.lootLock.tryLock()) { |
||||
try { |
||||
Item itemRet = null; |
||||
// get current owner
|
||||
int targetType = msg.getTargetType(); |
||||
int targetID = msg.getTargetID(); |
||||
|
||||
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal() || targetType == Enum.GameObjectType.Mob.ordinal() || targetType == Enum.GameObjectType.Corpse.ordinal()) { |
||||
} else { //needed for getting contracts for some reason
|
||||
targetType = msg.getSourceID2(); |
||||
targetID = msg.getUnknown01(); |
||||
} |
||||
|
||||
//can't loot while flying
|
||||
if (player.getAltitude() > 0) |
||||
return true; |
||||
|
||||
AbstractCharacter tar = null; |
||||
Corpse corpse = null; |
||||
|
||||
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal() || targetType == Enum.GameObjectType.Mob.ordinal()) { |
||||
|
||||
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) { |
||||
tar = PlayerCharacter.getFromCache(targetID); |
||||
|
||||
if (tar == null) |
||||
return true; |
||||
|
||||
if (player.getObjectUUID() != tar.getObjectUUID() && ((PlayerCharacter) tar).isInSafeZone()) |
||||
return true; |
||||
|
||||
} else if (targetType == Enum.GameObjectType.NPC.ordinal()) |
||||
tar = NPC.getFromCache(targetID); |
||||
else if (targetType == Enum.GameObjectType.Mob.ordinal()) |
||||
tar = Mob.getFromCache(targetID); |
||||
|
||||
if (tar == null) |
||||
return true; |
||||
|
||||
if (tar.equals(player)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot loot this item."); |
||||
return true; |
||||
} |
||||
|
||||
if (player.getLoc().distanceSquared2D(tar.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse."); |
||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(tar.getLoc()) + " distance."); |
||||
return true; |
||||
} |
||||
|
||||
//can't loot from someone who is alive.
|
||||
if (AbstractWorldObject.IsAbstractCharacter(tar)) { |
||||
if (tar.isAlive()) |
||||
return true; |
||||
// Logger.error("WorldServer.loot", "Looting from live player");
|
||||
} |
||||
|
||||
if (!GroupManager.goldSplit(player, item, origin, tar)) { |
||||
|
||||
if (tar.charItemManager != null) { |
||||
|
||||
itemRet = tar.charItemManager.lootItemFromMe(item, player, origin); |
||||
|
||||
//Take equipment off mob
|
||||
if (tar.getObjectType() == Enum.GameObjectType.Mob && itemRet != null) { |
||||
Mob mobTarget = (Mob) tar; |
||||
|
||||
if (item != null && item.getObjectType() == Enum.GameObjectType.MobLoot) { |
||||
|
||||
for (Item equip : mobTarget.charItemManager.equipped.values()) { |
||||
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.equipSlot); |
||||
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
|
||||
LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip); |
||||
Dispatch dispatch = Dispatch.borrow(player, lootMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} else if (targetType == Enum.GameObjectType.Corpse.ordinal()) { |
||||
corpse = Corpse.getCorpse(targetID); |
||||
|
||||
if (corpse == null) |
||||
return true; |
||||
|
||||
if (player.getLoc().distanceSquared2D(corpse.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse."); |
||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(corpse.getLoc()) + " distance."); |
||||
return true; |
||||
} |
||||
|
||||
//can't loot other players in safe zone.
|
||||
if (corpse.getBelongsToType() == Enum.GameObjectType.PlayerCharacter.ordinal()) { |
||||
|
||||
if (player.getObjectUUID() == corpse.getBelongsToID()) |
||||
itemRet = corpse.lootItem(item, player); |
||||
else if (!GroupManager.goldSplit(player, item, origin, corpse)) { |
||||
itemRet = corpse.lootItem(item, player); |
||||
|
||||
} |
||||
|
||||
if (itemRet == null) |
||||
return true; |
||||
|
||||
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { |
||||
// this is done to prevent the temporary goldItem item
|
||||
// (from the mob) from appearing in player's inventory.
|
||||
// It also updates the goldItem quantity display
|
||||
UpdateGoldMsg updateTargetGold = null; |
||||
|
||||
if (corpse != null) |
||||
updateTargetGold = new UpdateGoldMsg(corpse); |
||||
|
||||
updateTargetGold.configure(); |
||||
DispatchMessage.dispatchMsgToInterestArea(corpse, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player); |
||||
ugm.configure(); |
||||
Dispatch dispatch = Dispatch.borrow(player, ugm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
// respond back loot message. Try sending to everyone.
|
||||
|
||||
} else |
||||
DispatchMessage.dispatchMsgToInterestArea(corpse, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true); |
||||
|
||||
|
||||
//TODO send group loot message if player is grouped and visible
|
||||
Group group = GroupManager.getGroup(player); |
||||
|
||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) { |
||||
String name = item.getName(); |
||||
String text = player.getFirstName() + " has looted " + name + '.'; |
||||
ChatManager.chatGroupInfoCanSee(player, text); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} else |
||||
return true; |
||||
|
||||
if (itemRet == null) |
||||
return true; |
||||
|
||||
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { |
||||
// this is done to prevent the temporary goldItem item
|
||||
// (from the mob) from appearing in player's inventory.
|
||||
// It also updates the goldItem quantity display
|
||||
UpdateGoldMsg updateTargetGold = null; |
||||
|
||||
if (tar != null) |
||||
updateTargetGold = new UpdateGoldMsg(tar); |
||||
else if (corpse != null) |
||||
updateTargetGold = new UpdateGoldMsg(corpse); |
||||
|
||||
updateTargetGold.configure(); |
||||
DispatchMessage.dispatchMsgToInterestArea(tar, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); |
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player); |
||||
ugm.configure(); |
||||
Dispatch dispatch = Dispatch.borrow(player, ugm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
// respond back loot message. Try sending to everyone.
|
||||
|
||||
} else { |
||||
msg.setSourceType1(0); |
||||
msg.setSourceType2(0); |
||||
msg.setSourceID1(0); |
||||
msg.setSourceID2(0); |
||||
Dispatch dispatch = Dispatch.borrow(player, msg); |
||||
//DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
DispatchMessage.dispatchMsgToInterestArea(tar, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true); |
||||
LootMsg newItemMsg = new LootMsg(Enum.GameObjectType.PlayerCharacter.ordinal(), player.getObjectUUID(), 0, 0, itemRet); |
||||
dispatch = Dispatch.borrow(player, newItemMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); |
||||
|
||||
//player.getCharItemManager().updateInventory();
|
||||
} |
||||
|
||||
//TODO send group loot message if player is grouped and visible
|
||||
Group group = GroupManager.getGroup(player); |
||||
|
||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) { |
||||
String name = item.getName(); |
||||
String text = player.getFirstName() + " has looted " + name + '.'; |
||||
ChatManager.chatGroupInfoCanSee(player, text); |
||||
} |
||||
} catch (Exception e) { |
||||
Logger.info(e.getMessage()); |
||||
} finally { |
||||
item.lootLock.unlock(); |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,141 @@
@@ -0,0 +1,141 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.Enum.DispatchChannel; |
||||
import engine.InterestManagement.WorldGrid; |
||||
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.ErrorPopupMsg; |
||||
import engine.net.client.msg.LootWindowRequestMsg; |
||||
import engine.net.client.msg.LootWindowResponseMsg; |
||||
import engine.objects.*; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import static engine.math.FastMath.sqr; |
||||
|
||||
public class LootWindowRequestMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public LootWindowRequestMsgHandler() { |
||||
super(LootWindowRequestMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
LootWindowRequestMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (LootWindowRequestMsg) baseMsg; |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
if (!player.isAlive()) |
||||
return true; |
||||
|
||||
if (msg.getSourceType() != player.getObjectType().ordinal() || msg.getSourceID() != player.getObjectUUID()) { |
||||
Logger.error("Player " + player.getObjectUUID() + " looting from character of id " |
||||
+ msg.getSourceType() + ' ' + msg.getSourceID()); |
||||
return true; |
||||
} |
||||
|
||||
if (player.getAltitude() > 0) |
||||
return true; |
||||
|
||||
if (!player.isAlive()) |
||||
return true; |
||||
|
||||
LootWindowResponseMsg lwrm = null; |
||||
Enum.GameObjectType targetType = Enum.GameObjectType.values()[msg.getTargetType()]; |
||||
AbstractCharacter characterTarget = null; |
||||
Corpse corpseTarget; |
||||
|
||||
switch (targetType) { |
||||
case PlayerCharacter: |
||||
|
||||
characterTarget = PlayerCharacter.getFromCache(msg.getTargetID()); |
||||
|
||||
if (characterTarget == null) |
||||
return true; |
||||
|
||||
if (characterTarget.isAlive()) |
||||
return true; |
||||
|
||||
if (player.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse."); |
||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance."); |
||||
return true; |
||||
} |
||||
|
||||
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory(true)); |
||||
break; |
||||
case NPC: |
||||
characterTarget = NPC.getFromCache(msg.getTargetID()); |
||||
|
||||
if (characterTarget == null) |
||||
return true; |
||||
break; |
||||
case Mob: |
||||
characterTarget = Mob.getFromCache(msg.getTargetID()); |
||||
|
||||
if ((characterTarget == null) || characterTarget.isAlive()) |
||||
return true; |
||||
|
||||
if (player.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse."); |
||||
|
||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance."); |
||||
|
||||
if (!((Mob) characterTarget).isLootSync()) { |
||||
((Mob) characterTarget).setLootSync(true); |
||||
WorldGrid.updateObject(characterTarget, player); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory()); |
||||
break; |
||||
case Corpse: |
||||
corpseTarget = Corpse.getCorpse(msg.getTargetID()); |
||||
|
||||
if ((corpseTarget == null)) |
||||
return true; |
||||
|
||||
if (player.getLoc().distanceSquared(corpseTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) { |
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse."); |
||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance."); |
||||
return true; |
||||
} |
||||
lwrm = new LootWindowResponseMsg(corpseTarget.getObjectType().ordinal(), msg.getTargetID(), corpseTarget.getInventory()); |
||||
break; |
||||
} |
||||
|
||||
if (lwrm == null) |
||||
return true; |
||||
|
||||
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
Dispatch dispatch = Dispatch.borrow(player, lwrm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.ModifyStatMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class ModifyStatMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ModifyStatMsgHandler() { |
||||
super(ModifyStatMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ModifyStatMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ModifyStatMsg) baseMsg; |
||||
|
||||
int type = msg.getType(); |
||||
|
||||
switch (type) { |
||||
case MBServerStatics.STAT_STR_ID: |
||||
playerCharacter.addStr(msg.getAmount()); |
||||
break; |
||||
case MBServerStatics.STAT_DEX_ID: |
||||
playerCharacter.addDex(msg.getAmount()); |
||||
break; |
||||
case MBServerStatics.STAT_CON_ID: |
||||
playerCharacter.addCon(msg.getAmount()); |
||||
break; |
||||
case MBServerStatics.STAT_INT_ID: |
||||
playerCharacter.addInt(msg.getAmount()); |
||||
break; |
||||
case MBServerStatics.STAT_SPI_ID: |
||||
playerCharacter.addSpi(msg.getAmount()); |
||||
break; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.BuildingManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.PetAttackMsg; |
||||
import engine.objects.Mob; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class PetAttackMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public PetAttackMsgHandler() { |
||||
super(PetAttackMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
PetAttackMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (PetAttackMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
Mob pet = playerCharacter.getPet(); |
||||
|
||||
if (pet == null) |
||||
return true; |
||||
|
||||
if (!pet.isAlive()) |
||||
return true; |
||||
|
||||
if (pet.getCombatTarget() == null) |
||||
return true; |
||||
|
||||
if ((playerCharacter.inSafeZone()) |
||||
&& (msg.getTargetType() == Enum.GameObjectType.PlayerCharacter.ordinal())) |
||||
return true; |
||||
|
||||
if (msg.getTargetType() == Enum.GameObjectType.Building.ordinal()) |
||||
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); |
||||
|
||||
switch (msg.getTargetType()) { |
||||
case 53: //player character
|
||||
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); |
||||
break; |
||||
case 37://mob
|
||||
pet.setCombatTarget(Mob.getMob(msg.getTargetID())); |
||||
break; |
||||
case 8://mob
|
||||
pet.setCombatTarget(BuildingManager.getBuilding(msg.getTargetID())); |
||||
break; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.PetCmdMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.Mob; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class PetCmdMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public PetCmdMsgHandler() { |
||||
super(PetCmdMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
PetCmdMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (PetCmdMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
Mob pet = playerCharacter.getPet(); |
||||
|
||||
if (pet == null) |
||||
return true; |
||||
|
||||
if (!pet.isAlive()) |
||||
return true; |
||||
|
||||
//if (pet.state == STATE.Disabled)
|
||||
// return;
|
||||
|
||||
int type = msg.getType(); |
||||
|
||||
if (type == 1) { //stop attack
|
||||
pet.setCombatTarget(null); |
||||
playerCharacter.setCombat(false); |
||||
|
||||
} else if (type == 2) { //dismiss
|
||||
pet.dismiss(); |
||||
playerCharacter.dismissPet(); |
||||
|
||||
if (pet.isAlive()) |
||||
WorldGrid.updateObject(pet); |
||||
} else if (type == 3) //toggle assist
|
||||
pet.toggleAssist(); |
||||
else if (type == 5) { //rest
|
||||
boolean sit = (!(pet.isSit())); |
||||
pet.setSit(sit); |
||||
|
||||
// cancel effects that break on sit
|
||||
if (pet.isSit()) |
||||
pet.cancelOnSit(); |
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
rwss.setPlayer(pet); |
||||
DispatchMessage.sendToAllInRange(pet, rwss); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,135 @@
@@ -0,0 +1,135 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.job.JobContainer; |
||||
import engine.job.JobScheduler; |
||||
import engine.jobs.FinishSummonsJob; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.ErrorPopupMsg; |
||||
import engine.net.client.msg.RecvSummonsMsg; |
||||
import engine.objects.BaseClass; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.objects.PromotionClass; |
||||
|
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
public class RecvSummonsMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public RecvSummonsMsgHandler() { |
||||
super(RecvSummonsMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
RecvSummonsMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (RecvSummonsMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID()); |
||||
|
||||
if (source == null) |
||||
return true; |
||||
|
||||
long tooLate = playerCharacter.getSummoner(source.getObjectUUID()); |
||||
|
||||
if (tooLate < System.currentTimeMillis()) { |
||||
ChatManager.chatInfoError(playerCharacter, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons."); |
||||
playerCharacter.removeSummoner(source.getObjectUUID()); |
||||
return true; |
||||
} |
||||
|
||||
if (playerCharacter.getBonuses() != null && playerCharacter.getBonuses().getBool(Enum.ModType.BlockedPowerType, Enum.SourceType.SUMMON)) { |
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You have been blocked from receiving summons!"); |
||||
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!"); |
||||
playerCharacter.removeSummoner(source.getObjectUUID()); |
||||
return true; |
||||
} |
||||
|
||||
playerCharacter.removeSummoner(source.getObjectUUID()); |
||||
|
||||
// Handle Accepting or Denying a summons.
|
||||
// set timer based on summon type.
|
||||
|
||||
boolean wentThrough = false; |
||||
|
||||
if (msg.accepted()) // summons accepted, let's move the player if within time
|
||||
if (source.isAlive()) { |
||||
|
||||
//make sure summons handled in time
|
||||
ConcurrentHashMap<String, JobContainer> timers; |
||||
timers = playerCharacter.getTimers(); |
||||
|
||||
if (timers != null && timers.containsKey("Summon")) |
||||
timers.get("Summon").cancelJob(); |
||||
|
||||
// get time to wait before summons goes through
|
||||
|
||||
BaseClass base = source.baseClass; |
||||
PromotionClass promo = source.getPromotionClass(); |
||||
int duration; |
||||
|
||||
//determine if in combat with another player
|
||||
|
||||
//comment out this block to disable combat timer
|
||||
// if (lastAttacked < 60000) {
|
||||
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
|
||||
// combat = false;
|
||||
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
|
||||
// combat = true;
|
||||
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
|
||||
// combat = true; //more than 1.5x width of zone, not tactical summons
|
||||
// }
|
||||
|
||||
if (promo != null && promo.getObjectUUID() == 2519) |
||||
duration = 10000; // Priest summons, 10 seconds
|
||||
else if (base != null && base.getObjectUUID() == 2501) |
||||
duration = 15000; // Healer Summons, 15 seconds
|
||||
else |
||||
duration = 45000; // Belgosh Summons, 45 seconds
|
||||
|
||||
// Teleport to summoners location
|
||||
|
||||
FinishSummonsJob fsj = new FinishSummonsJob(source, playerCharacter); |
||||
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj, |
||||
duration); |
||||
|
||||
if (timers != null) |
||||
timers.put("Summon", jc); |
||||
|
||||
wentThrough = true; |
||||
} |
||||
|
||||
// Summons failed
|
||||
if (!wentThrough) // summons refused. Let's be nice and reset recycle timer
|
||||
{ |
||||
// Send summons refused Message
|
||||
ErrorPopupMsg.sendErrorPopup(source, 29); |
||||
// recycle summons power
|
||||
//finishRecycleTime(428523680, source, true);
|
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
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.RefineMsg; |
||||
import engine.net.client.msg.RefinerScreenMsg; |
||||
import engine.objects.*; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
public class RefineMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public RefineMsgHandler() { |
||||
super(RefineMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
RefineMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (RefineMsg) baseMsg; |
||||
|
||||
NPC npc = NPC.getFromCache(msg.npcID); |
||||
|
||||
if (npc == null) |
||||
return true; |
||||
|
||||
int type = msg.type; |
||||
int token = msg.token; |
||||
boolean worked = false; |
||||
boolean skillPower = true; |
||||
|
||||
if (type == 0) { //refine skill
|
||||
worked = refineSkill(origin, playerCharacter, token, msg); |
||||
} else if (type == 1) { //refine power
|
||||
worked = refinePower(origin, playerCharacter, token, msg); |
||||
} else if (type == 2) { //refine stat
|
||||
worked = refineStat(origin, playerCharacter, token, msg); |
||||
skillPower = false; |
||||
} |
||||
|
||||
if (worked) { |
||||
|
||||
//update player
|
||||
playerCharacter.applyBonuses(); |
||||
playerCharacter.charItemManager.RemoveEquipmentFromLackOfSkill(playerCharacter, true); |
||||
|
||||
//echo refine message back
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); |
||||
|
||||
// if (type == 0 && token == 1488335491){
|
||||
// dispatch = Dispatch.borrow(pc, msg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
// }
|
||||
|
||||
//resend refine screen
|
||||
|
||||
RefinerScreenMsg refinerScreenMsg = new RefinerScreenMsg(skillPower, npc.getSellPercent(playerCharacter)); //TODO set npc cost
|
||||
dispatch = Dispatch.borrow(playerCharacter, refinerScreenMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); |
||||
playerCharacter.recalculate(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public static boolean refineSkill(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) { |
||||
CharacterSkill skill = null; |
||||
ConcurrentHashMap<String, CharacterSkill> skills = pc.getSkills(); |
||||
for (CharacterSkill sk : skills.values()) { |
||||
if (sk == null) |
||||
continue; |
||||
SkillsBase sb = sk.getSkillsBase(); |
||||
if (sb == null) |
||||
continue; |
||||
if (sb.getToken() == token) |
||||
skill = sk; |
||||
} |
||||
//check if player has skill to refine
|
||||
if (skill == null) |
||||
return false; |
||||
//check there's a train to refine
|
||||
if (skill.getNumTrains() < 1) |
||||
return false; |
||||
|
||||
//TODO verify if any skills have this as prereq
|
||||
|
||||
//TODO verify if any powers have this as a prereq
|
||||
//get all players powers
|
||||
for (CharacterPower power : pc.getPowers().values()) { |
||||
ArrayList<PowerReq> reqs = PowerReq.getPowerReqsForRune(power.getPowerID()); |
||||
for (PowerReq req : reqs) { |
||||
ConcurrentHashMap<String, CharacterSkill> playerSkills = pc.getSkills(); |
||||
CharacterSkill playerSkill = playerSkills.get(token); |
||||
int currentSkillLevel = playerSkill.getTotalSkillPercet(); |
||||
if (token == req.getToken() && req.getLevel() == currentSkillLevel) { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//refine skill
|
||||
return skill.refine(pc); |
||||
} |
||||
|
||||
public static boolean refinePower(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) { |
||||
CharacterPower power = null; |
||||
ConcurrentHashMap<Integer, CharacterPower> powers = pc.getPowers(); |
||||
if (!powers.containsKey(token)) |
||||
return false; |
||||
power = powers.get(token); |
||||
if (power == null) |
||||
return false; |
||||
if (power.getTrains() < 1) |
||||
return false; |
||||
|
||||
//TODO verify if any powers have this as a prereq
|
||||
|
||||
return power.refine(pc); |
||||
} |
||||
|
||||
public static boolean refineStat(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) { |
||||
if (token == MBServerStatics.STAT_STR_ID) |
||||
return pc.refineStr(); |
||||
if (token == MBServerStatics.STAT_DEX_ID) |
||||
return pc.refineDex(); |
||||
if (token == MBServerStatics.STAT_CON_ID) |
||||
return pc.refineCon(); |
||||
if (token == MBServerStatics.STAT_INT_ID) |
||||
return pc.refineInt(msg); |
||||
if (token == MBServerStatics.STAT_SPI_ID) |
||||
return pc.refineSpi(); |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.RefinerScreenMsg; |
||||
import engine.objects.NPC; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class RefinerScreenMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public RefinerScreenMsgHandler() { |
||||
super(RefinerScreenMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
RefinerScreenMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (RefinerScreenMsg) baseMsg; |
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNpcID()); |
||||
|
||||
if (npc != null) |
||||
msg.setUnknown02(0); //cost to refine?
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum.DispatchChannel; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.MovementManager; |
||||
import engine.job.JobScheduler; |
||||
import engine.jobs.RefreshGroupJob; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.MoveToPointMsg; |
||||
import engine.net.client.msg.RespawnMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
public class RespawnMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public RespawnMsgHandler() { |
||||
super(RespawnMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
RespawnMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (RespawnMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
if (msg.getObjectType() != playerCharacter.getObjectType().ordinal() || msg.getObjectID() != playerCharacter.getObjectUUID()) { |
||||
Logger.error("Player " + playerCharacter.getObjectUUID() + " respawning character of id " + msg.getObjectType() + ' ' |
||||
+ msg.getObjectID()); |
||||
return true; |
||||
} |
||||
|
||||
if (playerCharacter.isAlive()) { |
||||
Logger.error("Player " + playerCharacter.getObjectUUID() + " respawning while alive"); |
||||
return true; |
||||
} |
||||
|
||||
// ResetAfterDeath player
|
||||
playerCharacter.respawnLock.writeLock().lock(); |
||||
try { |
||||
playerCharacter.respawn(true, false, true); |
||||
|
||||
} catch (Exception e) { |
||||
Logger.error(e); |
||||
} finally { |
||||
playerCharacter.respawnLock.writeLock().unlock(); |
||||
|
||||
} |
||||
// Echo ResetAfterDeath message back
|
||||
msg.setPlayerHealth(playerCharacter.getHealth()); |
||||
// TODO calculate any experience loss before this point
|
||||
msg.setPlayerExp(playerCharacter.getExp() + playerCharacter.getOverFlowEXP()); |
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); |
||||
|
||||
MoveToPointMsg moveMsg = new MoveToPointMsg(); |
||||
moveMsg.setPlayer(playerCharacter); |
||||
moveMsg.setStartCoord(playerCharacter.getLoc()); |
||||
moveMsg.setEndCoord(playerCharacter.getLoc()); |
||||
moveMsg.setInBuilding(-1); |
||||
moveMsg.setInBuildingFloor(-1); |
||||
|
||||
dispatch = Dispatch.borrow(playerCharacter, moveMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); |
||||
|
||||
MovementManager.sendRWSSMsg(playerCharacter); |
||||
|
||||
// refresh the whole group with what just happened
|
||||
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(playerCharacter), MBServerStatics.LOAD_OBJECT_DELAY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.gameManager.ConfigManager; |
||||
import engine.gameManager.SessionManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.PerformActionMsg; |
||||
import engine.net.client.msg.SendSummonsMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
import static engine.gameManager.PowersManager.*; |
||||
|
||||
public class SendSummonsMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public SendSummonsMsgHandler() { |
||||
super(SendSummonsMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
SendSummonsMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (SendSummonsMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
PlayerCharacter target = SessionManager |
||||
.getPlayerCharacterByLowerCaseName(msg.getTargetName()); |
||||
|
||||
if (target == null || target.equals(playerCharacter) || target.isCombat()) { |
||||
|
||||
if (target == null) // Player not found. Send not found message
|
||||
ChatManager.chatInfoError(playerCharacter, |
||||
"Cannot find that player to summon."); |
||||
else if (target.isCombat()) |
||||
ChatManager.chatInfoError(playerCharacter, |
||||
"Cannot summon player in combat."); |
||||
|
||||
// else trying to summon self, just fail
|
||||
|
||||
// recycle summon
|
||||
sendRecyclePower(msg.getPowerToken(), origin); |
||||
|
||||
// TODO: client already subtracted 200 mana.. need to correct it
|
||||
// end cast
|
||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), |
||||
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0, |
||||
0, 0f, 0f, 0f, 1, 0); |
||||
sendPowerMsg(playerCharacter, 2, pam); |
||||
|
||||
return true; |
||||
} |
||||
if (ConfigManager.MB_RULESET.getValue() == "LORE") { |
||||
if (playerCharacter.guild.getGuildType().equals(target.guild.getGuildType()) == false) { |
||||
ChatManager.chatInfoError(playerCharacter, |
||||
"Cannot summon player outside your charter."); |
||||
return true; |
||||
} |
||||
} |
||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg |
||||
.getTrains(), msg.getSourceType(), msg.getSourceID(), target |
||||
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0); |
||||
|
||||
// Client removes 200 mana on summon use.. so don't send message to self
|
||||
target.addSummoner(playerCharacter.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS); |
||||
usePower(pam, origin, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.SetCombatModeMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class SetCombatModeMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public SetCombatModeMsgHandler() { |
||||
super(SetCombatModeMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
SetCombatModeMsg msg; |
||||
boolean toggle; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (SetCombatModeMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
toggle = msg.getToggle(); |
||||
playerCharacter.setCombat(toggle); |
||||
|
||||
if (!toggle) // toggle is move it to false so clear combat target
|
||||
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
rwss.setPlayer(playerCharacter); |
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.Enum.DispatchChannel; |
||||
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.ShowMsg; |
||||
import engine.objects.AbstractCharacter; |
||||
import engine.objects.Mob; |
||||
import engine.objects.NPC; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class ShowMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ShowMsgHandler() { |
||||
super(ShowMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ShowMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ShowMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
int targetType = msg.getTargetType(); |
||||
AbstractCharacter tar = null; |
||||
|
||||
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) |
||||
tar = PlayerCharacter.getFromCache(msg.getTargetID()); |
||||
else if (targetType == Enum.GameObjectType.NPC.ordinal()) |
||||
tar = NPC.getFromCache(msg.getTargetID()); |
||||
else if (targetType == Enum.GameObjectType.Mob.ordinal()) |
||||
tar = Mob.getFromCache(msg.getTargetID()); |
||||
|
||||
if (tar == null || !tar.isAlive() || !tar.isActive()) |
||||
return true; |
||||
|
||||
msg.setUnknown01(playerCharacter.getLoc()); |
||||
msg.setUnknown02(playerCharacter.getLoc()); |
||||
msg.setRange01(playerCharacter.getRange()); |
||||
msg.setUnknown03(tar.getLoc()); |
||||
msg.setUnknown04(tar.getLoc()); |
||||
msg.setRange01(tar.getRange()); |
||||
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.job.JobContainer; |
||||
import engine.job.JobScheduler; |
||||
import engine.jobs.StuckJob; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.StuckMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
public class StuckMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public StuckMsgHandler() { |
||||
super(StuckMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
StuckMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (StuckMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
if (playerCharacter.getTimers().containsKey("Stuck")) |
||||
return true; |
||||
|
||||
StuckJob sj = new StuckJob(playerCharacter); |
||||
JobContainer jc = JobScheduler.getInstance().scheduleJob(sj, 10000); // Convert
|
||||
ConcurrentHashMap<String, JobContainer> timers = playerCharacter.getTimers(); |
||||
|
||||
if (timers != null) { |
||||
if (timers.containsKey("Stuck")) { |
||||
timers.get("Stuck").cancelJob(); |
||||
timers.remove("Stuck"); |
||||
} |
||||
timers.put("Stuck", jc); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.ToggleCombatMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class ToggleCombatMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ToggleCombatMsgHandler() { |
||||
super(ToggleCombatMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ToggleCombatMsg msg; |
||||
boolean toggle; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ToggleCombatMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
toggle = msg.toggleCombat(); |
||||
playerCharacter.setCombat(toggle); |
||||
|
||||
if (!toggle) // toggle is move it to false so clear combat target
|
||||
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
rwss.setPlayer(playerCharacter); |
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum.DispatchChannel; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.ToggleLfgRecruitingMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class ToggleLfgRecruitingMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ToggleLfgRecruitingMsgHandler() { |
||||
super(ToggleLfgRecruitingMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ToggleLfgRecruitingMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ToggleLfgRecruitingMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
int num = msg.toggleLfgRecruiting(); |
||||
|
||||
if (num == 1) |
||||
playerCharacter.toggleLFGroup(); |
||||
else if (num == 2) |
||||
playerCharacter.toggleLFGuild(); |
||||
else if (num == 3) |
||||
playerCharacter.toggleRecruiting(); |
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
rwss.setPlayer(playerCharacter); |
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum.DispatchChannel; |
||||
import engine.exception.MsgSendException; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.ToggleSitStandMsg; |
||||
import engine.net.client.msg.UpdateStateMsg; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
public class ToggleSitStandMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ToggleSitStandMsgHandler() { |
||||
super(ToggleSitStandMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ToggleSitStandMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ToggleSitStandMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
playerCharacter.update(); |
||||
|
||||
playerCharacter.setSit(msg.toggleSitStand()); |
||||
|
||||
// cancel effects that break on sit
|
||||
if (playerCharacter.isSit()) { |
||||
playerCharacter.setCombat(false); |
||||
playerCharacter.cancelOnSit(); |
||||
} |
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg(); |
||||
|
||||
if (playerCharacter.isSit()) { |
||||
playerCharacter.setCombat(false); |
||||
rwss.setAware(1); |
||||
} |
||||
rwss.setPlayer(playerCharacter); |
||||
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.Enum.DispatchChannel; |
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.gameManager.PowersManager; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.TrackWindowMsg; |
||||
import engine.objects.*; |
||||
import engine.powers.ActionsBase; |
||||
import engine.powers.PowersBase; |
||||
import engine.powers.RangeBasedAwo; |
||||
import engine.powers.poweractions.AbstractPowerAction; |
||||
import engine.powers.poweractions.TrackPowerAction; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.Iterator; |
||||
|
||||
public class TrackWindowMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public TrackWindowMsgHandler() { |
||||
super(TrackWindowMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
TrackWindowMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (TrackWindowMsg) baseMsg; |
||||
|
||||
if (playerCharacter == null) |
||||
return true; |
||||
|
||||
if (MBServerStatics.POWERS_DEBUG) { |
||||
ChatManager.chatSayInfo( |
||||
playerCharacter, |
||||
"Using Power: " + Integer.toHexString(msg.getPowerToken()) |
||||
+ " (" + msg.getPowerToken() + ')'); |
||||
Logger.info("Using Power: " |
||||
+ Integer.toHexString(msg.getPowerToken()) + " (" |
||||
+ msg.getPowerToken() + ')'); |
||||
} |
||||
|
||||
// get track power used
|
||||
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerToken()); |
||||
|
||||
if (pb == null || !pb.isTrack()) |
||||
return true; |
||||
|
||||
//check track threshold timer to prevent spam
|
||||
|
||||
long currentTime = System.currentTimeMillis(); |
||||
long timestamp = playerCharacter.getTimeStamp("trackWindow"); |
||||
long dif = currentTime - timestamp; |
||||
|
||||
if (dif < MBServerStatics.TRACK_WINDOW_THRESHOLD) |
||||
return true; |
||||
|
||||
playerCharacter.setTimeStamp("trackWindow", currentTime); |
||||
|
||||
ArrayList<ActionsBase> ablist = pb.getActions(); |
||||
|
||||
if (ablist == null) |
||||
return true; |
||||
|
||||
TrackPowerAction tpa = null; |
||||
|
||||
for (ActionsBase ab : ablist) { |
||||
AbstractPowerAction apa = ab.getPowerAction(); |
||||
if (apa != null && apa instanceof TrackPowerAction) |
||||
tpa = (TrackPowerAction) apa; |
||||
} |
||||
|
||||
if (tpa == null) |
||||
return true; |
||||
|
||||
// Check powers for normal users
|
||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerToken())) |
||||
if (!playerCharacter.isCSR()) |
||||
if (!MBServerStatics.POWERS_DEBUG) { |
||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||
// this.logEXPLOIT("usePowerA(): Cheat attempted? '" + msg.getPowerToken() + "' was not associated with " + pc.getName());
|
||||
return true; |
||||
} |
||||
|
||||
// Get search mask for track
|
||||
|
||||
int mask = 0; |
||||
|
||||
if (pb.targetPlayer()) |
||||
if (tpa.trackVampire()) // track vampires
|
||||
mask = MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD; |
||||
else |
||||
// track all players
|
||||
mask = MBServerStatics.MASK_PLAYER; |
||||
else if (pb.targetCorpse()) // track corpses
|
||||
mask = MBServerStatics.MASK_CORPSE; |
||||
else if (tpa.trackNPC()) // Track NPCs
|
||||
mask = MBServerStatics.MASK_NPC; |
||||
else if (tpa.trackUndead()) // Track Undead
|
||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_UNDEAD; |
||||
else |
||||
// Track All
|
||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_NPC; |
||||
|
||||
// Find characters in range
|
||||
|
||||
HashSet<AbstractWorldObject> allTargets; |
||||
allTargets = WorldGrid.getObjectsInRangeContains(playerCharacter.getLoc(), |
||||
pb.getRange(), mask); |
||||
|
||||
//remove anyone who can't be tracked
|
||||
|
||||
Iterator<AbstractWorldObject> it = allTargets.iterator(); |
||||
|
||||
while (it.hasNext()) { |
||||
AbstractWorldObject awo = it.next(); |
||||
|
||||
if (awo == null) |
||||
continue; |
||||
|
||||
else if (!awo.isAlive()) |
||||
it.remove(); |
||||
|
||||
else if (awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { |
||||
PlayerBonuses bonus = ((PlayerCharacter) awo).getBonuses(); |
||||
|
||||
if (bonus != null && bonus.getBool(Enum.ModType.CannotTrack, Enum.SourceType.NONE)) |
||||
it.remove(); |
||||
} |
||||
} |
||||
|
||||
// get max characters for window
|
||||
|
||||
int maxTargets = 20; |
||||
PromotionClass promo = playerCharacter.getPromotionClass(); |
||||
|
||||
if (promo != null) { |
||||
int tableID = promo.getObjectUUID(); |
||||
if (tableID == 2512 || tableID == 2514 || tableID == 2515) |
||||
maxTargets = 40; |
||||
} |
||||
|
||||
// create list of characters
|
||||
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList( |
||||
allTargets, playerCharacter, maxTargets); |
||||
|
||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg); |
||||
|
||||
// send track window
|
||||
trackWindowMsg.setSource(playerCharacter); |
||||
trackWindowMsg.setCharacters(trackChars); |
||||
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, trackWindowMsg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.TradeRequestMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class TradeRequestMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public TradeRequestMsgHandler() { |
||||
super(TradeRequestMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
TradeRequestMsg msg = (TradeRequestMsg) baseMsg; |
||||
|
||||
PlayerCharacter source = origin.getPlayerCharacter(); |
||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getPlayerID()); |
||||
Dispatch dispatch; |
||||
|
||||
if (!CharacterItemManager.canTrade(source, target)) { |
||||
ChatManager.chatSystemError(source, "Can't currently trade with target player"); |
||||
return false; |
||||
} |
||||
|
||||
// TODO uncomment this block after we determine when we
|
||||
// setBankOpen(false) and setVaultOpen(false)
|
||||
CharacterItemManager cim1 = source.charItemManager; |
||||
CharacterItemManager cim2 = target.charItemManager; |
||||
|
||||
if (cim1 == null) |
||||
return false; |
||||
|
||||
if (cim2 == null) |
||||
return false; |
||||
|
||||
dispatch = Dispatch.borrow(target, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
return true; |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.TrainerInfoMsg; |
||||
import engine.objects.NPC; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class TrainerInfoMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public TrainerInfoMsgHandler() { |
||||
super(TrainerInfoMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
TrainerInfoMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (TrainerInfoMsg) baseMsg; |
||||
|
||||
NPC npc = NPC.getFromCache(msg.getObjectID()); |
||||
float sellPercent = 1; |
||||
|
||||
if (npc != null) { |
||||
|
||||
if (origin.getPlayerCharacter() != null) |
||||
sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); |
||||
else |
||||
sellPercent = npc.getSellPercent(); |
||||
|
||||
msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc));
|
||||
} |
||||
|
||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,67 @@
@@ -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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.Enum.DispatchChannel; |
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.BuildingManager; |
||||
import engine.net.Dispatch; |
||||
import engine.net.DispatchMessage; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.ViewResourcesMsg; |
||||
import engine.objects.Building; |
||||
import engine.objects.City; |
||||
import engine.objects.Guild; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class ViewResourcesMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public ViewResourcesMsgHandler() { |
||||
super(ViewResourcesMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
||||
|
||||
// Member variable declaration
|
||||
|
||||
ViewResourcesMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (ViewResourcesMsg) baseMsg; |
||||
|
||||
Guild guild = playerCharacter.getGuild(); |
||||
City city = guild.getOwnedCity(); |
||||
|
||||
if (city == null) |
||||
return true; |
||||
|
||||
Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID()); |
||||
|
||||
if (warehouse == null) |
||||
return true; |
||||
|
||||
ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); |
||||
vrm.setWarehouseBuilding(warehouse); |
||||
vrm.setGuild(playerCharacter.getGuild()); |
||||
vrm.configure(); |
||||
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, vrm); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue