mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-25 10:44:37 +01:00
Improve command system
This commit is contained in:
@@ -23,27 +23,11 @@ public class HandlerPlayerSignatureEdit extends NetHandler {
|
||||
|
||||
// Check if we need to handle a command
|
||||
if (signature.charAt(0) == '!' || signature.charAt(0) == '/') {
|
||||
String commandLabel = signature.toLowerCase().trim();
|
||||
if (commandLabel.startsWith("!") || commandLabel.startsWith("/")) {
|
||||
commandLabel = commandLabel.substring(1).split(" ")[0];
|
||||
}
|
||||
|
||||
Nebula.getCommandManager().invoke(session.getPlayer(), signature);
|
||||
|
||||
// If this is the remote command, return the message
|
||||
if ("remote".equals(commandLabel)) {
|
||||
String remoteMessage = emu.nebula.command.commands.RemoteKeyCommand.getLastMessage();
|
||||
if (remoteMessage != null) {
|
||||
return session.encodeMsg(
|
||||
NetMsgId.player_signature_edit_failed_ack,
|
||||
Error.newInstance().setCode(119902).addArguments("\n" + remoteMessage)
|
||||
);
|
||||
}
|
||||
}
|
||||
var result = Nebula.getCommandManager().invoke(session.getPlayer(), signature);
|
||||
|
||||
return session.encodeMsg(
|
||||
NetMsgId.player_signature_edit_failed_ack,
|
||||
Error.newInstance().setCode(119902).addArguments("\nCommand Success")
|
||||
Error.newInstance().setCode(119902).addArguments("\nCommand Result: " + result.getMessage())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class RemoteHandler implements Handler {
|
||||
if (cachedUid != null) {
|
||||
player = Nebula.getGameContext().getPlayerModule().getPlayer(cachedUid);
|
||||
// Verify token matches (in case player changed token or cache is stale)
|
||||
if (player != null && !token.equals(player.getPlayerRemoteToken())) {
|
||||
if (player != null && !token.equals(player.getRemoteToken())) {
|
||||
player = null;
|
||||
tokenCache.remove(token);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class RemoteHandler implements Handler {
|
||||
|
||||
// 2. Fallback to DB if not in cache or cache invalid
|
||||
if (player == null) {
|
||||
player = Nebula.getGameDatabase().getObjectByField(Player.class, "playerRemoteToken", token);
|
||||
player = Nebula.getGameDatabase().getObjectByField(Player.class, "remoteToken", token);
|
||||
if (player != null) {
|
||||
tokenCache.put(token, player.getUid());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user