Skip to content

Commit

Permalink
(a bit broken) level command
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiro420 committed Nov 30, 2023
1 parent 71c8f11 commit d0c40f8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/emu/lunarcore/command/commands/SetLevelCommand.java
Original file line number Diff line number Diff line change
@@ -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));
}

}
10 changes: 10 additions & 0 deletions src/main/java/emu/lunarcore/game/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ public GameServer getServer() {
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;
Expand Down

0 comments on commit d0c40f8

Please sign in to comment.