From 2c0576f697a249ba028085af946a33576a0df7ec Mon Sep 17 00:00:00 2001 From: JimWails <1142247734@qq.com> Date: Sun, 1 May 2022 23:02:18 +0800 Subject: [PATCH] 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. --- .../emu/grasscutter/command/commands/GiveCharCommand.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java index a15a9b95c..70f051ef4 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java @@ -73,6 +73,12 @@ public final class GiveCharCommand implements CommandHandler { return; } + // Check level. + if (level > 90) { + CommandHandler.sendMessage(sender, "Invalid avatar level."); + return; + } + // Calculate ascension level. if (level <= 40) { ascension = (int) Math.ceil(level / 20f); @@ -88,6 +94,6 @@ public final class GiveCharCommand implements CommandHandler { avatar.recalcStats(); 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)); } }