From b504866d844b86a8faedeb107f63f8bac7479530 Mon Sep 17 00:00:00 2001 From: ImmuState Date: Fri, 27 May 2022 11:26:37 -0700 Subject: [PATCH 1/4] Make sure energy drops are only processed for actual monsters. --- .../managers/EnergyManager/EnergyManager.java | 7 ++++++ .../resources/defaults/data/EnergyDrop.json | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/main/java/emu/grasscutter/game/managers/EnergyManager/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/EnergyManager/EnergyManager.java index b888c9aa5..e59aa56da 100644 --- a/src/main/java/emu/grasscutter/game/managers/EnergyManager/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/EnergyManager/EnergyManager.java @@ -303,6 +303,13 @@ public class EnergyManager { } } public void handleMonsterEnergyDrop(EntityMonster monster, float hpBeforeDamage, float hpAfterDamage) { + // Make sure this is actually a monster. + // Note that some wildlife also has that type, like boars or birds. + String type = monster.getMonsterData().getType(); + if (!type.equals("MONSTER_ORDINARY") && !type.equals("MONSTER_BOSS")) { + return; + } + // Calculate the HP tresholds for before and after the damage was taken. float maxHp = monster.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); float thresholdBefore = hpBeforeDamage / maxHp; diff --git a/src/main/resources/defaults/data/EnergyDrop.json b/src/main/resources/defaults/data/EnergyDrop.json index 2e3b72cf1..6cd7e8d85 100644 --- a/src/main/resources/defaults/data/EnergyDrop.json +++ b/src/main/resources/defaults/data/EnergyDrop.json @@ -156,5 +156,30 @@ "dropId": 22003100, "dropList": [ ] + }, + { + "dropId": 22001000, + "dropList": [ + ] + }, + { + "dropId": 22000100, + "dropList": [ + ] + }, + { + "dropId": 22003000, + "dropList": [ + ] + }, + { + "dropId": 22001100, + "dropList": [ + ] + }, + { + "dropId": 22000000, + "dropList": [ + ] } ] \ No newline at end of file From 2cb18e24575e0be2f2cebc8c4e151de9d7ea3cda Mon Sep 17 00:00:00 2001 From: Luke H-W Date: Sat, 28 May 2022 20:33:31 +0930 Subject: [PATCH 2/4] Fix setstats command feedback for targeting others (#1079) Co-authored-by: AnimeGitB --- .../java/emu/grasscutter/command/commands/SetStatsCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java index 957ca8b4f..643b313f8 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java @@ -215,7 +215,7 @@ public final class SetStatsCommand implements CommandHandler { CommandHandler.sendMessage(sender, translate(sender, "commands.setStats.set_self", stat.name, valueStr)); } else { String uidStr = targetPlayer.getAccount().getId(); - CommandHandler.sendMessage(sender, translate(sender, "commands.setStats.set_self", stat.name, uidStr, valueStr)); + CommandHandler.sendMessage(sender, translate(sender, "commands.setStats.set_for_uid", stat.name, uidStr, valueStr)); } } else { CommandHandler.sendMessage(sender, usage); From bcee25555437038aba34f252a784c2a110246072 Mon Sep 17 00:00:00 2001 From: tester233 <1804830236@qq.com> Date: Sat, 28 May 2022 17:59:45 +0800 Subject: [PATCH 3/4] Update translation keys --- .../grasscutter/command/commands/GiveCharCommand.java | 10 +++++----- src/main/resources/languages/en-US.json | 2 +- src/main/resources/languages/pl-PL.json | 2 +- src/main/resources/languages/zh-CN.json | 6 +++--- src/main/resources/languages/zh-TW.json | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java index fdb921fc9..a067e98bf 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCharCommand.java @@ -12,7 +12,7 @@ import java.util.List; import static emu.grasscutter.utils.Language.translate; -@Command(label = "givechar", usage = "givechar [level]", aliases = {"givec"}, permission = "player.givechar", permissionTargeted = "player.givechar.others", description = "commands.giveChar.description") +@Command(label = "givechar", usage = "givechar [level]", aliases = {"givec"}, permission = "player.givechar", permissionTargeted = "player.givechar.others", description = "commands.giveChar.description") public final class GiveCharCommand implements CommandHandler { @Override @@ -26,7 +26,7 @@ public final class GiveCharCommand implements CommandHandler { level = Integer.parseInt(args.get(1)); } catch (NumberFormatException ignored) { // TODO: Parse from avatar name using GM Handbook. - CommandHandler.sendMessage(sender, translate(sender, "commands.execution.invalid.avatarLevel")); + CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.avatarLevel")); return; } // Cheeky fall-through to parse first argument too case 1: @@ -34,7 +34,7 @@ public final class GiveCharCommand implements CommandHandler { avatarId = Integer.parseInt(args.get(0)); } catch (NumberFormatException ignored) { // TODO: Parse from avatar name using GM Handbook. - CommandHandler.sendMessage(sender, translate(sender, "commands.execution.invalid.avatarId")); + CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.avatarId")); return; } break; @@ -45,13 +45,13 @@ public final class GiveCharCommand implements CommandHandler { AvatarData avatarData = GameData.getAvatarDataMap().get(avatarId); if (avatarData == null) { - CommandHandler.sendMessage(sender, translate(sender, "commands.execution.invalid.avatarId")); + CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.avatarId")); return; } // Check level. if (level > 90) { - CommandHandler.sendMessage(sender, translate(sender, "commands.execution.invalid.avatarLevel")); + CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.avatarLevel")); return; } diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index d1551fdc5..29c2b1ede 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -159,7 +159,7 @@ "description": "Gives the player a specified artifact" }, "giveChar": { - "usage": "Usage: givechar [level]", + "usage": "Usage: givechar [level]", "given": "Given %s with level %s to %s.", "invalid_avatar_id": "Invalid avatar ID.", "invalid_avatar_level": "Invalid avatar level.", diff --git a/src/main/resources/languages/pl-PL.json b/src/main/resources/languages/pl-PL.json index 25a2cd733..92b18cb3c 100644 --- a/src/main/resources/languages/pl-PL.json +++ b/src/main/resources/languages/pl-PL.json @@ -146,7 +146,7 @@ "success": "Dano %s dla %s." }, "giveChar": { - "usage": "Użycie: givechar [ilość]", + "usage": "Użycie: givechar [ilość]", "given": "Dano %s z poziomem %s dla %s.", "invalid_avatar_id": "Błędne ID postaci.", "invalid_avatar_level": "Błędny poziom postaci.", diff --git a/src/main/resources/languages/zh-CN.json b/src/main/resources/languages/zh-CN.json index 03cc4881b..705720ea3 100644 --- a/src/main/resources/languages/zh-CN.json +++ b/src/main/resources/languages/zh-CN.json @@ -104,7 +104,7 @@ "modify": "修改用户账号", "invalid": "无效的UID。", "exists": "账号已存在。", - "create": "已创建账号,UID 为 %s。", + "create": "已创建 UID 为 %s 的账号。", "delete": "账号已删除。", "no_account": "账号不存在。", "command_usage": "用法:account <用户名> [UID]", @@ -163,7 +163,7 @@ "description": "给予指定圣遗物" }, "giveChar": { - "usage": "用法:givechar <玩家> <角色ID|角色名> [等级]", + "usage": "用法:givechar <玩家> <角色ID> [等级]", "given": "已将角色 %s [等级 %s] 给与 %s。", "invalid_avatar_id": "无效的角色ID。", "invalid_avatar_level": "无效的角色等级。", @@ -251,7 +251,7 @@ }, "sendMail": { "usage": "用法:sendmail <用户ID|all|help> [模板ID]", - "user_not_exist": "用户 %s 不存在。", + "user_not_exist": "用户 '%s' 不存在。", "start_composition": "开始撰写邮件。\n请使用 '/sendmail <标题>' 继续。\n你可以随时使用 '/sendmail stop' 停止。", "templates": "邮件模板尚未实装...", "invalid_arguments": "无效的参数。", diff --git a/src/main/resources/languages/zh-TW.json b/src/main/resources/languages/zh-TW.json index 5f6ed4ca7..3a172f19a 100644 --- a/src/main/resources/languages/zh-TW.json +++ b/src/main/resources/languages/zh-TW.json @@ -159,7 +159,7 @@ "description": "給予指定聖遺物。" }, "giveChar": { - "usage": "用法:givechar [level]", + "usage": "用法:givechar [level]", "given": "已將 %s 等級 %s 給予 %s。", "invalid_avatar_id": "無效的角色ID。", "invalid_avatar_level": "無效的角色等級。.", From ce07f56f9d10cc79c9b7104b66c2e4ff19cd4f53 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Sat, 28 May 2022 01:04:27 +0800 Subject: [PATCH 4/4] fix(database helper): fix player uid issues --- src/main/java/emu/grasscutter/database/DatabaseHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index 057b450cb..466cedc6b 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -97,7 +97,7 @@ public final class DatabaseHelper { } public static Account getAccountByPlayerId(int playerId) { - return DatabaseManager.getGameDatastore().find(Account.class).filter(Filters.eq("playerId", playerId)).first(); + return DatabaseManager.getGameDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first(); } public static void deleteAccount(Account target) {