From 5397833dea02b9509aab9007de118a15456806ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 27 Mar 2024 13:23:00 -0400 Subject: [PATCH] Handler created for WhoRequestMsg --- src/engine/net/client/ClientMessagePump.java | 24 ---------- src/engine/net/client/Protocol.java | 2 +- .../client/handlers/WhoRequestMsgHandler.java | 48 +++++++++++++++++++ 3 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 src/engine/net/client/handlers/WhoRequestMsgHandler.java diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index ebc48f41..aef4c228 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -52,27 +52,6 @@ public class ClientMessagePump implements NetMsgHandler { this.server = server; } - /* - * Incoming client protocol message are processed here - */ - - private static void WhoRequest(WhoRequestMsg msg, ClientConnection origin) { - - // Handle /who request - PlayerCharacter pc = origin.getPlayerCharacter(); - - if (pc == null) - return; - - if (pc.getTimeStamp("WHO") > System.currentTimeMillis()) { - ErrorPopupMsg.sendErrorMsg(pc, "Who too fast! Please wait 3 seconds."); - return; - } - - WhoResponseMsg.HandleResponse(msg.getSet(), msg.getFilterType(), msg.getFilter(), origin); - pc.getTimestamps().put("WHO", System.currentTimeMillis() + 3000); - } - private static void toggleLfgRecruiting(ToggleLfgRecruitingMsg msg, ClientConnection origin) throws MsgSendException { PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); if (pc == null) @@ -844,9 +823,6 @@ public class ClientMessagePump implements NetMsgHandler { break; case OPENVAULT: break; - case WHOREQUEST: - WhoRequest((WhoRequestMsg) msg, origin); - break; case CLIENTADMINCOMMAND: ChatManager.HandleClientAdminCmd((ClientAdminCommandMsg) msg, origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index b5ecaa05..3282adaf 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -244,7 +244,7 @@ public enum Protocol { VIEWRESOURCES(0xCEFD0346, ViewResourcesMessage.class, null), VISUALUPDATE(0x33402fd2, null, null), WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response - WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, null), // Request /who + WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, WhoRequestMsgHandler.class), // Request /who WHORESPONSE(0xD7C36568, WhoResponseMsg.class, null), // Response /who REQUESTBALLLIST(0xE366FF64, RequestBallListMessage.class, RequestBallListHandler.class), SENDBALLENTRY(0xAC2B5EDC, SendBallEntryMessage.class, SendBallEntryHandler.class), diff --git a/src/engine/net/client/handlers/WhoRequestMsgHandler.java b/src/engine/net/client/handlers/WhoRequestMsgHandler.java new file mode 100644 index 00000000..aef875c7 --- /dev/null +++ b/src/engine/net/client/handlers/WhoRequestMsgHandler.java @@ -0,0 +1,48 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// 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.ErrorPopupMsg; +import engine.net.client.msg.WhoRequestMsg; +import engine.net.client.msg.WhoResponseMsg; +import engine.objects.PlayerCharacter; + +public class WhoRequestMsgHandler extends AbstractClientMsgHandler { + + public WhoRequestMsgHandler() { + super(WhoRequestMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + + WhoRequestMsg msg = (WhoRequestMsg) baseMsg; + + // Handle /who request + PlayerCharacter player = origin.getPlayerCharacter(); + + if (player == null) + return true; + + if (player.getTimeStamp("WHO") > System.currentTimeMillis()) { + ErrorPopupMsg.sendErrorMsg(player, "Who too fast! Please wait 3 seconds."); + return true; + } + + WhoResponseMsg.HandleResponse(msg.getSet(), msg.getFilterType(), msg.getFilter(), origin); + player.getTimestamps().put("WHO", System.currentTimeMillis() + 3000); + + return true; + } + +} \ No newline at end of file