Browse Source

Handler created for StuckMsg

combat-2
MagicBot 8 months ago
parent
commit
5a5fd8155c
  1. 26
      src/engine/gameManager/MovementManager.java
  2. 8
      src/engine/net/client/ClientMessagePump.java
  3. 2
      src/engine/net/client/Protocol.java
  4. 61
      src/engine/net/client/handlers/StuckMsgHandler.java
  5. 6
      src/engine/net/client/msg/StuckMsg.java

26
src/engine/gameManager/MovementManager.java

@ -14,9 +14,6 @@ import engine.Enum.ModType; @@ -14,9 +14,6 @@ import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.InterestManagement.InterestManager;
import engine.exception.MsgSendException;
import engine.job.JobContainer;
import engine.job.JobScheduler;
import engine.jobs.StuckJob;
import engine.math.Bounds;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
@ -30,7 +27,6 @@ import engine.server.MBServerStatics; @@ -30,7 +27,6 @@ import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static engine.math.FastMath.sqr;
@ -474,26 +470,4 @@ public enum MovementManager { @@ -474,26 +470,4 @@ public enum MovementManager {
ac.teleport(ac.getLoc());
}
public static void stuck(ClientConnection origin) {
PlayerCharacter sourcePlayer = origin.getPlayerCharacter();
if (sourcePlayer == null)
return;
if (sourcePlayer.getTimers().containsKey("Stuck"))
return;
StuckJob sj = new StuckJob(sourcePlayer);
JobContainer jc = JobScheduler.getInstance().scheduleJob(sj, 10000); // Convert
ConcurrentHashMap<String, JobContainer> timers = sourcePlayer.getTimers();
if (timers != null) {
if (timers.containsKey("Stuck")) {
timers.get("Stuck").cancelJob();
timers.remove("Stuck");
}
timers.put("Stuck", jc);
}
}
}

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

@ -9,7 +9,10 @@ @@ -9,7 +9,10 @@
package engine.net.client;
import engine.gameManager.*;
import engine.gameManager.ChatManager;
import engine.gameManager.PowersManager;
import engine.gameManager.SessionManager;
import engine.gameManager.TradeManager;
import engine.net.NetMsgHandler;
import engine.net.client.handlers.AbstractClientMsgHandler;
import engine.net.client.msg.*;
@ -138,9 +141,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -138,9 +141,6 @@ public class ClientMessagePump implements NetMsgHandler {
case ARCTRACKINGLIST:
PowersManager.trackWindow((TrackWindowMsg) msg, origin);
break;
case STUCK:
MovementManager.stuck(origin);
break;
case CHANNELMUTE:
break;
case KEEPALIVESERVERCLIENT:

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

@ -200,7 +200,7 @@ public enum Protocol { @@ -200,7 +200,7 @@ public enum Protocol {
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages
STUCK(0x3D04AF3A, StuckCommandMsg.class, null), // /Stuck Command
STUCK(0x3D04AF3A, StuckMsg.class, StuckMsgHandler.class), // /Stuck Command
SWEARINGUILD(0x389B66B1, SwearInGuildMsg.class, SwearInGuildHandler.class),
SYNC(0x49ec109f, null, null), //Client/Server loc sync
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message

61
src/engine/net/client/handlers/StuckMsgHandler.java

@ -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;
}
}

6
src/engine/net/client/msg/StuckCommandMsg.java → src/engine/net/client/msg/StuckMsg.java

@ -16,12 +16,12 @@ import engine.net.ByteBufferWriter; @@ -16,12 +16,12 @@ import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;
public class StuckCommandMsg extends ClientNetMsg {
public class StuckMsg extends ClientNetMsg {
/**
* This is the general purpose constructor.
*/
public StuckCommandMsg() {
public StuckMsg() {
super(Protocol.STUCK);
}
@ -31,7 +31,7 @@ public class StuckCommandMsg extends ClientNetMsg { @@ -31,7 +31,7 @@ public class StuckCommandMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the
* caller.
*/
public StuckCommandMsg(AbstractConnection origin, ByteBufferReader reader) {
public StuckMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.STUCK, origin, reader);
}
Loading…
Cancel
Save