From fa5980bc6ab55c3a0eeb190d03a43dba49c8c394 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 27 Mar 2024 13:51:14 -0400 Subject: [PATCH] Handler created for GuildTreeStatusMSg --- src/engine/net/client/ClientMessagePump.java | 29 --------- src/engine/net/client/Protocol.java | 2 +- .../handlers/GuildTreeStatusMsgHandler.java | 59 +++++++++++++++++++ 3 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 src/engine/net/client/handlers/GuildTreeStatusMsgHandler.java diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 045ef89e..b0dd40e8 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -631,32 +631,6 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgToInterestArea(source, msg, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true); } - //returns true if looted item is goldItem and is split. Otherwise returns false - - private static void GuildTreeStatusMsg(GuildTreeStatusMsg msg, ClientConnection origin) throws SQLException { - - PlayerCharacter player = SessionManager.getPlayerCharacter(origin); - Dispatch dispatch; - - if (player == null) - return; - - if (origin.guildtreespam > System.currentTimeMillis()) { - return; - } - origin.guildtreespam = System.currentTimeMillis() + 5000; - - Building b = BuildingManager.getBuildingFromCache(msg.getTargetID()); - if (b == null) - return; - - GuildTreeStatusMsg gtsm = new GuildTreeStatusMsg(b, player); - gtsm.configure(); - - dispatch = Dispatch.borrow(player, gtsm); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - } - protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException { PlayerCharacter pc = SessionManager.getPlayerCharacter(conn); @@ -819,9 +793,6 @@ public class ClientMessagePump implements NetMsgHandler { ToggleSitStandMsg tssm = (ToggleSitStandMsg) msg; toggleSitStand(tssm, origin); break; - case GUILDTREESTATUS: - GuildTreeStatusMsg((GuildTreeStatusMsg) msg, origin); - break; case IGNORE: ((IgnoreMsg) msg).handleRequest(origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 1f766e71..d9fb20c4 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -108,7 +108,7 @@ public enum Protocol { GROUPTREASURE(0x01041C66, ToggleGroupSplitMsg.class, ToggleGroupSplitHandler.class), // Toggle Group Split GUILDMEMBERONLINE(0x7B79EB3A, GuildEnterWorldMsg.class, null), // Send Enter World Message to Guild GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank - GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, null), + GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, GuildTreeStatusMsgHandler.class), HIRELINGSERVICE(0xD3D93322, HirelingServiceMsg.class, HirelingServiceMsgHandler.class), IGNORE(0xBD8881EE, IgnoreMsg.class, null), //client sent /ignore command INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window diff --git a/src/engine/net/client/handlers/GuildTreeStatusMsgHandler.java b/src/engine/net/client/handlers/GuildTreeStatusMsgHandler.java new file mode 100644 index 00000000..120f3403 --- /dev/null +++ b/src/engine/net/client/handlers/GuildTreeStatusMsgHandler.java @@ -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.gameManager.BuildingManager; +import engine.gameManager.SessionManager; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.GuildTreeStatusMsg; +import engine.objects.Building; +import engine.objects.PlayerCharacter; + +public class GuildTreeStatusMsgHandler extends AbstractClientMsgHandler { + + public GuildTreeStatusMsgHandler() { + super(GuildTreeStatusMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + GuildTreeStatusMsg msg = (GuildTreeStatusMsg) baseMsg; + + PlayerCharacter player = SessionManager.getPlayerCharacter(origin); + + Dispatch dispatch; + + if (player == null) + return true; + + if (origin.guildtreespam > System.currentTimeMillis()) + return true; + + origin.guildtreespam = System.currentTimeMillis() + 5000; + + Building building = BuildingManager.getBuildingFromCache(msg.getTargetID()); + + if (building == null) + return true; + + GuildTreeStatusMsg guildTreeStatusMsg = new GuildTreeStatusMsg(building, player); + guildTreeStatusMsg.configure(); + + dispatch = Dispatch.borrow(player, guildTreeStatusMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + return true; + } + +} \ No newline at end of file