Add /worldlevel command

This commit is contained in:
Melledy
2023-09-29 17:55:40 -07:00
parent b476fc73f2
commit cd73057114
2 changed files with 26 additions and 0 deletions

View File

@@ -131,6 +131,26 @@ public class PlayerCommands {
player.dropMessage("Giving you " + count + " of " + itemId);
}
}
@Command(aliases = {"wl", "el"}, desc = "/worldlevel [world level]")
public static class WorldLevel extends PlayerCommand {
@Override
public void execute(Player player, String raw) {
int level = 0;
try {
level = Integer.parseInt(raw);
} catch (Exception e) {
level = 0;
}
level = Math.min(Math.max(level, 0), 6);
// Set world level
player.setWorldLevel(level);
player.dropMessage("Set world level to " + level);
}
}
/* Temporarily disabled as spawned monsters need
@Command(desc = "/spawn [monster id] [count] - Creates {count} amount of {item id}")

View File

@@ -150,6 +150,12 @@ public class Player {
return 0;
}
public void setWorldLevel(int level) {
this.worldLevel = level;
this.save();
this.sendPacket(new PacketPlayerSyncScNotify(this));
}
public boolean hasLoggedIn() {
return this.getSession() != null && this.getSession().getState() != SessionState.WAITING_FOR_TOKEN;