forked from MagicBane/Server
Handler created for StuckMsg
This commit is contained in:
@@ -14,9 +14,6 @@ import engine.Enum.ModType;
|
|||||||
import engine.Enum.SourceType;
|
import engine.Enum.SourceType;
|
||||||
import engine.InterestManagement.InterestManager;
|
import engine.InterestManagement.InterestManager;
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.job.JobContainer;
|
|
||||||
import engine.job.JobScheduler;
|
|
||||||
import engine.jobs.StuckJob;
|
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -30,7 +27,6 @@ import engine.server.MBServerStatics;
|
|||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import static engine.math.FastMath.sqr;
|
import static engine.math.FastMath.sqr;
|
||||||
|
|
||||||
@@ -474,26 +470,4 @@ public enum MovementManager {
|
|||||||
ac.teleport(ac.getLoc());
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
|
|
||||||
package engine.net.client;
|
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.NetMsgHandler;
|
||||||
import engine.net.client.handlers.AbstractClientMsgHandler;
|
import engine.net.client.handlers.AbstractClientMsgHandler;
|
||||||
import engine.net.client.msg.*;
|
import engine.net.client.msg.*;
|
||||||
@@ -138,9 +141,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
case ARCTRACKINGLIST:
|
case ARCTRACKINGLIST:
|
||||||
PowersManager.trackWindow((TrackWindowMsg) msg, origin);
|
PowersManager.trackWindow((TrackWindowMsg) msg, origin);
|
||||||
break;
|
break;
|
||||||
case STUCK:
|
|
||||||
MovementManager.stuck(origin);
|
|
||||||
break;
|
|
||||||
case CHANNELMUTE:
|
case CHANNELMUTE:
|
||||||
break;
|
break;
|
||||||
case KEEPALIVESERVERCLIENT:
|
case KEEPALIVESERVERCLIENT:
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public enum Protocol {
|
|||||||
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
|
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
|
||||||
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
|
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
|
||||||
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages
|
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),
|
SWEARINGUILD(0x389B66B1, SwearInGuildMsg.class, SwearInGuildHandler.class),
|
||||||
SYNC(0x49ec109f, null, null), //Client/Server loc sync
|
SYNC(0x49ec109f, null, null), //Client/Server loc sync
|
||||||
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message
|
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -16,12 +16,12 @@ import engine.net.ByteBufferWriter;
|
|||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
|
|
||||||
|
|
||||||
public class StuckCommandMsg extends ClientNetMsg {
|
public class StuckMsg extends ClientNetMsg {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
public StuckCommandMsg() {
|
public StuckMsg() {
|
||||||
super(Protocol.STUCK);
|
super(Protocol.STUCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class StuckCommandMsg extends ClientNetMsg {
|
|||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public StuckCommandMsg(AbstractConnection origin, ByteBufferReader reader) {
|
public StuckMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.STUCK, origin, reader);
|
super(Protocol.STUCK, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user