Browse Source

Handler created for WhoRequestMsg

combat-2
MagicBot 8 months ago
parent
commit
5397833dea
  1. 24
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 48
      src/engine/net/client/handlers/WhoRequestMsgHandler.java

24
src/engine/net/client/ClientMessagePump.java

@ -52,27 +52,6 @@ public class ClientMessagePump implements NetMsgHandler {
this.server = server; 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 { private static void toggleLfgRecruiting(ToggleLfgRecruitingMsg msg, ClientConnection origin) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null) if (pc == null)
@ -844,9 +823,6 @@ public class ClientMessagePump implements NetMsgHandler {
break; break;
case OPENVAULT: case OPENVAULT:
break; break;
case WHOREQUEST:
WhoRequest((WhoRequestMsg) msg, origin);
break;
case CLIENTADMINCOMMAND: case CLIENTADMINCOMMAND:
ChatManager.HandleClientAdminCmd((ClientAdminCommandMsg) msg, origin); ChatManager.HandleClientAdminCmd((ClientAdminCommandMsg) msg, origin);
break; break;

2
src/engine/net/client/Protocol.java

@ -244,7 +244,7 @@ public enum Protocol {
VIEWRESOURCES(0xCEFD0346, ViewResourcesMessage.class, null), VIEWRESOURCES(0xCEFD0346, ViewResourcesMessage.class, null),
VISUALUPDATE(0x33402fd2, null, null), VISUALUPDATE(0x33402fd2, null, null),
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response 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 WHORESPONSE(0xD7C36568, WhoResponseMsg.class, null), // Response /who
REQUESTBALLLIST(0xE366FF64, RequestBallListMessage.class, RequestBallListHandler.class), REQUESTBALLLIST(0xE366FF64, RequestBallListMessage.class, RequestBallListHandler.class),
SENDBALLENTRY(0xAC2B5EDC, SendBallEntryMessage.class, SendBallEntryHandler.class), SENDBALLENTRY(0xAC2B5EDC, SendBallEntryMessage.class, SendBallEntryHandler.class),

48
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;
}
}
Loading…
Cancel
Save