diff --git a/src/main/java/emu/lunarcore/command/commands/AvatarCommand.java b/src/main/java/emu/lunarcore/command/commands/AvatarCommand.java index e0317af..edd42c7 100644 --- a/src/main/java/emu/lunarcore/command/commands/AvatarCommand.java +++ b/src/main/java/emu/lunarcore/command/commands/AvatarCommand.java @@ -7,6 +7,7 @@ import emu.lunarcore.data.GameData; import emu.lunarcore.game.avatar.GameAvatar; import emu.lunarcore.game.player.Player; import emu.lunarcore.server.packet.send.PacketPlayerSyncScNotify; +import emu.lunarcore.util.Utils; @Command(label = "avatar", aliases = {"a"}, permission = "player.avatar", desc = "/avatar lv(level) p(ascension) r(eidolon) s(skill levels). Sets the current avatar's properties") public class AvatarCommand implements CommandHandler { @@ -37,6 +38,7 @@ public class AvatarCommand implements CommandHandler { // Try to set level if (args.getLevel() > 0) { avatar.setLevel(Math.min(args.getLevel(), 80)); + avatar.setPromotion(Utils.getMinPromotionForLevel(avatar.getLevel())); hasChanged = true; } diff --git a/src/main/java/emu/lunarcore/command/commands/GiveCommand.java b/src/main/java/emu/lunarcore/command/commands/GiveCommand.java index 2fb65e8..25f078f 100644 --- a/src/main/java/emu/lunarcore/command/commands/GiveCommand.java +++ b/src/main/java/emu/lunarcore/command/commands/GiveCommand.java @@ -45,6 +45,7 @@ public class GiveCommand implements CommandHandler { // Try to set level if (args.getLevel() > 0) { avatar.setLevel(Math.min(args.getLevel(), 80)); + avatar.setPromotion(Utils.getMinPromotionForLevel(avatar.getLevel())); } // Try to set promotion @@ -65,6 +66,7 @@ public class GiveCommand implements CommandHandler { // Try to set level if (args.getLevel() > 0) { item.setLevel(Math.min(args.getLevel(), 80)); + item.setPromotion(Utils.getMinPromotionForLevel(item.getLevel())); } // Try to set promotion diff --git a/src/main/java/emu/lunarcore/util/Utils.java b/src/main/java/emu/lunarcore/util/Utils.java index 403f047..0a13543 100644 --- a/src/main/java/emu/lunarcore/util/Utils.java +++ b/src/main/java/emu/lunarcore/util/Utils.java @@ -1,13 +1,11 @@ package emu.lunarcore.util; import java.io.File; -import java.security.SecureRandom; import java.util.Base64; import java.util.List; import java.util.concurrent.ThreadLocalRandom; public class Utils { - private static final SecureRandom secureRandom = new SecureRandom(); private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray(); public static final Object EMPTY_OBJECT = new Object(); @@ -77,15 +75,9 @@ public class Utils { public static long getCurrentSeconds() { return Math.floorDiv(System.currentTimeMillis(), 1000); } - - public static byte[] generateRandomBytes(int length) { - byte[] bytes = new byte[length]; - secureRandom.nextBytes(bytes); - return bytes; - } - - public static String generateRandomString(int length) { - return bytesToHex(generateRandomBytes(length)); + + public static int getMinPromotionForLevel(int level) { + return Math.max(Math.min((int) ((level - 11) / 10D), 6), 0); } public static int parseSafeInt(String s) {