mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-18 15:24:45 +01:00
Add Remote Command API (Use KEY)
This commit is contained in:
@@ -10,7 +10,7 @@ import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.player_login_req)
|
||||
public class HandlerPlayerLoginReq extends NetHandler {
|
||||
|
||||
|
||||
public boolean requirePlayer() {
|
||||
return false;
|
||||
}
|
||||
@@ -20,21 +20,21 @@ public class HandlerPlayerLoginReq extends NetHandler {
|
||||
// Parse request
|
||||
var req = LoginReq.parseFrom(message);
|
||||
var loginToken = req.getOfficialOverseas().getToken();
|
||||
|
||||
|
||||
// Login
|
||||
boolean result = session.login(loginToken);
|
||||
|
||||
|
||||
if (!result) {
|
||||
return session.encodeMsg(NetMsgId.player_login_failed_ack);
|
||||
}
|
||||
|
||||
|
||||
// Regenerate session token because we are switching encrpytion method
|
||||
Nebula.getGameContext().generateSessionToken(session);
|
||||
|
||||
|
||||
// Create rsp
|
||||
var rsp = LoginResp.newInstance()
|
||||
.setToken(session.getToken());
|
||||
|
||||
|
||||
// Encode and send to client
|
||||
return session.encodeMsg(NetMsgId.player_login_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,24 @@ 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return session.encodeMsg(
|
||||
NetMsgId.player_signature_edit_failed_ack,
|
||||
Error.newInstance().setCode(119902).addArguments("\nCommand Success")
|
||||
|
||||
Reference in New Issue
Block a user