Fixed can set avatar level more than 90 and cause game to freeze

Limit the avatar level given by "/givechar" command.
If avatar level >90, the game will freeze if open the character interface.
This commit is contained in:
JimWails 2022-05-01 23:02:18 +08:00 committed by Melledy
parent 1e166960d2
commit 2c0576f697

View File

@ -73,6 +73,12 @@ public final class GiveCharCommand implements CommandHandler {
return; return;
} }
// Check level.
if (level > 90) {
CommandHandler.sendMessage(sender, "Invalid avatar level.");
return;
}
// Calculate ascension level. // Calculate ascension level.
if (level <= 40) { if (level <= 40) {
ascension = (int) Math.ceil(level / 20f); ascension = (int) Math.ceil(level / 20f);
@ -88,6 +94,6 @@ public final class GiveCharCommand implements CommandHandler {
avatar.recalcStats(); avatar.recalcStats();
targetPlayer.addAvatar(avatar); targetPlayer.addAvatar(avatar);
CommandHandler.sendMessage(sender, String.format("Given %s to %s.", avatarId, target)); CommandHandler.sendMessage(sender, String.format("Given %s with level %s to %s.", avatarId, level, target));
} }
} }