mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 12:24:35 +01:00
Add Command SetLevel (#8)
* Add Remote Command API (Use KEY) * Clean up HttpServer by removing unused code Removed commented-out code * Add SetLevel Command (need to restart the game for it to take effect) * Add Proto Request Change Level (Not Work) * Update setlevel command --------- Co-authored-by: Melledy <121644117+Melledy@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,6 +47,7 @@ tmp/
|
|||||||
*~.nib
|
*~.nib
|
||||||
.loadpath
|
.loadpath
|
||||||
.recommenders
|
.recommenders
|
||||||
|
./StellaSoraData
|
||||||
|
|
||||||
# VSCode
|
# VSCode
|
||||||
.vscode
|
.vscode
|
||||||
|
|||||||
1
StellaSoraData
Submodule
1
StellaSoraData
Submodule
Submodule StellaSoraData added at bb5ed8a3fd
@@ -21,7 +21,7 @@ public class RemoteKeyCommand implements CommandHandler {
|
|||||||
int index = random.nextInt(characters.length());
|
int index = random.nextInt(characters.length());
|
||||||
sb.append(characters.charAt(index));
|
sb.append(characters.charAt(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
args.getTarget().setRemoteToken(sb.toString());
|
args.getTarget().setRemoteToken(sb.toString());
|
||||||
return "Key Generated: " + sb.toString();
|
return "Key Generated: " + sb.toString();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package emu.nebula.command.commands;
|
||||||
|
|
||||||
|
import emu.nebula.command.Command;
|
||||||
|
import emu.nebula.command.CommandArgs;
|
||||||
|
import emu.nebula.command.CommandHandler;
|
||||||
|
import emu.nebula.data.GameData;
|
||||||
|
import emu.nebula.net.NetMsgId;
|
||||||
|
import emu.nebula.proto.NotifyGm.GmWorldClass;
|
||||||
|
import emu.nebula.util.Utils;
|
||||||
|
|
||||||
|
@Command(label = "setlevel", aliases = {"level", "l"}, permission = "player.level", requireTarget = true, desc = "/level [level]. Set player level")
|
||||||
|
public class SetLevelCommand implements CommandHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(CommandArgs args) {
|
||||||
|
// Get target
|
||||||
|
var target = args.getTarget();
|
||||||
|
|
||||||
|
// Parse level
|
||||||
|
int level = Utils.parseSafeInt(args.get(0));
|
||||||
|
|
||||||
|
// Check to make sure world class data exists for this level
|
||||||
|
var data = GameData.getWorldClassDataTable().get(level);
|
||||||
|
if (data == null) {
|
||||||
|
return "The game does not support level " + level;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.setLevel(level);
|
||||||
|
target.setExp(0);
|
||||||
|
|
||||||
|
// Update
|
||||||
|
target.addNextPackage(
|
||||||
|
NetMsgId.world_class_number_notify,
|
||||||
|
GmWorldClass.newInstance()
|
||||||
|
.setFinalClass(target.getLevel())
|
||||||
|
.setLastExp(target.getExp())
|
||||||
|
);
|
||||||
|
|
||||||
|
return "Level set to " + level;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -130,4 +130,4 @@ public class GameData {
|
|||||||
|
|
||||||
// Score boss
|
// Score boss
|
||||||
@Getter private static DataTable<ScoreBossControlDef> ScoreBossControlDataTable = new DataTable<>();
|
@Getter private static DataTable<ScoreBossControlDef> ScoreBossControlDataTable = new DataTable<>();
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,17 @@ public class Player implements GameDatabaseObject {
|
|||||||
public boolean hasSession() {
|
public boolean hasSession() {
|
||||||
return this.session != null;
|
return this.session != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) {
|
||||||
|
this.level = level;
|
||||||
|
Nebula.getGameDatabase().update(this, this.getUid(), "level", this.level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExp(int exp) {
|
||||||
|
this.exp = exp;
|
||||||
|
Nebula.getGameDatabase().update(this, this.getUid(), "exp", this.exp);
|
||||||
|
}
|
||||||
|
|
||||||
public void setRemoteToken(String token) {
|
public void setRemoteToken(String token) {
|
||||||
// Skip if tokens are the same
|
// Skip if tokens are the same
|
||||||
if (this.remoteToken == null) {
|
if (this.remoteToken == null) {
|
||||||
@@ -898,4 +908,4 @@ public class Player implements GameDatabaseObject {
|
|||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -163,14 +163,9 @@ public class HttpServer {
|
|||||||
// https://nova-static.stellasora.global/
|
// https://nova-static.stellasora.global/
|
||||||
getApp().get("/meta/serverlist.html", new MetaServerlistHandler(this));
|
getApp().get("/meta/serverlist.html", new MetaServerlistHandler(this));
|
||||||
getApp().get("/meta/win.html", new MetaWinHandler(this));
|
getApp().get("/meta/win.html", new MetaWinHandler(this));
|
||||||
// if (!Nebula.getConfig().getRemoteCommand().useRemoteServices) {
|
|
||||||
// getApp().post("/api/command", new RemoteHandler());
|
|
||||||
// }
|
|
||||||
getApp().post("/api/command", new RemoteHandler());
|
getApp().post("/api/command", new RemoteHandler());
|
||||||
// getApp.get("/notice/noticelist.html");
|
|
||||||
getApp().get("/webchatv3/*", ctx -> {
|
|
||||||
ctx.redirect("https://google.com");
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user