(a bit broken) level command

This commit is contained in:
Hiro
2023-11-30 10:24:26 +02:00
parent 71c8f11327
commit d0c40f8349
2 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package emu.lunarcore.command.commands;
import emu.lunarcore.util.Utils;
import emu.lunarcore.LunarCore;
import emu.lunarcore.GameConstants;
import emu.lunarcore.command.Command;
import emu.lunarcore.command.CommandArgs;
import emu.lunarcore.command.CommandHandler;
import emu.lunarcore.game.player.Player;
@Command(label = "setlevel", aliases = {"level"}, permission = "player.setlevel", desc = "/setlevel - Set your Equilibrium level.")
public class SetLevelCommand implements CommandHandler {
@Override
public void execute(Player sender, CommandArgs args) {
int targetLevel = Utils.parseSafeInt(args.get(0));
sender.setLevel(targetLevel);
this.sendMessage(sender, "Set level to "+args.get(0));
}
}

View File

@@ -188,6 +188,16 @@ public class Player {
public Account getAccount() {
return session.getAccount();
}
public void setLevel(int newLevel) {
if (newLevel >= 71) {
newLevel = 70;
}
this.level = (newLevel);
this.exp = 0;
this.sendPacket(new PacketPlayerSyncScNotify(this));
this.save();
}
public boolean isOnline() {
return this.getSession() != null && this.loggedIn;