From 6869008bcc0d3d6c3f33aede5bbbab232362772a Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sun, 30 Apr 2023 20:53:23 -0400 Subject: [PATCH] Add quest debugging commands --- .../command/commands/QuestCommand.java | 156 +++++++++++------- src/main/resources/languages/en-US.json | 11 ++ src/main/resources/languages/es-ES.json | 11 ++ src/main/resources/languages/fr-FR.json | 11 ++ src/main/resources/languages/it-IT.json | 11 ++ src/main/resources/languages/ja-JP.json | 11 ++ src/main/resources/languages/ko-KR.json | 11 ++ src/main/resources/languages/pl-PL.json | 11 ++ src/main/resources/languages/ro-RO.json | 11 ++ src/main/resources/languages/ru-RU.json | 11 ++ src/main/resources/languages/zh-CN.json | 11 ++ src/main/resources/languages/zh-TW.json | 11 ++ 12 files changed, 213 insertions(+), 64 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/QuestCommand.java b/src/main/java/emu/grasscutter/command/commands/QuestCommand.java index 3325440d6..289e20536 100644 --- a/src/main/java/emu/grasscutter/command/commands/QuestCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/QuestCommand.java @@ -1,64 +1,92 @@ -package emu.grasscutter.command.commands; - -import static emu.grasscutter.utils.Language.translate; - -import emu.grasscutter.command.Command; -import emu.grasscutter.command.CommandHandler; -import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.quest.GameQuest; -import java.util.List; - -@Command( - label = "quest", - aliases = {"q"}, - usage = {"(add|finish) []"}, - permission = "player.quest", - permissionTargeted = "player.quest.others") -public final class QuestCommand implements CommandHandler { - - @Override - public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() != 2) { - sendUsageMessage(sender); - return; - } - - String cmd = args.get(0).toLowerCase(); - int questId; - - try { - questId = Integer.parseInt(args.get(1)); - } catch (Exception e) { - CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id")); - return; - } - - switch (cmd) { - case "add" -> { - GameQuest quest = targetPlayer.getQuestManager().addQuest(questId); - - if (quest != null) { - CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId)); - return; - } - - CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); - } - case "finish" -> { - GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId); - - if (quest == null) { - CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); - return; - } - - quest.finish(); - - CommandHandler.sendMessage(sender, translate(sender, "commands.quest.finished", questId)); - } - default -> { - sendUsageMessage(sender); - } - } - } -} +package emu.grasscutter.command.commands; + +import static emu.grasscutter.utils.Language.translate; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.quest.GameQuest; + +import java.util.List; + +@Command( + label = "quest", + aliases = {"q"}, + usage = {"(add|finish) []"}, + permission = "player.quest", + permissionTargeted = "player.quest.others") +public final class QuestCommand implements CommandHandler { + + @Override + public void execute(Player sender, Player targetPlayer, List args) { + if (args.size() != 2) { + sendUsageMessage(sender); + return; + } + + String cmd = args.get(0).toLowerCase(); + int questId; + + try { + questId = Integer.parseInt(args.get(1)); + } catch (Exception e) { + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id")); + return; + } + + switch (cmd) { + case "add" -> { + GameQuest quest = targetPlayer.getQuestManager().addQuest(questId); + + if (quest != null) { + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId)); + return; + } + + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); + } + case "finish" -> { + GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId); + + if (quest == null) { + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); + return; + } + + quest.finish(); + + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.finished", questId)); + } + case "running" -> { + var quest = targetPlayer.getQuestManager().getQuestById(questId); + if (quest == null) { + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); + return; + } + + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.running", + questId, translate(sender, switch(quest.state) { + case QUEST_STATE_NONE, NONE -> "commands.quest.state.none"; + case QUEST_STATE_UNSTARTED, UNSTARTED -> "commands.quest.state.unstarted"; + case QUEST_STATE_UNFINISHED, UNFINISHED -> "commands.quest.state.unfinished"; + case QUEST_STATE_FINISHED, FINISHED -> "commands.quest.state.finished"; + case QUEST_STATE_FAILED, FAILED -> "commands.quest.state.failed"; + }, quest.getState().getValue())) + ); + } + case "talking" -> { + var mainQuest = targetPlayer.getQuestManager().getMainQuestByTalkId(questId); + if (mainQuest == null) { + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found")); + return; + } + + var talk = mainQuest.getTalks().get(questId); + CommandHandler.sendMessage(sender, translate(sender, "commands.quest.talking", + questId, translate(sender, "commands.quest.state." + (talk == null ? "not_exists" : "exists")), + mainQuest.getParentQuestId(), mainQuest.getState().getValue())); + } + default -> this.sendUsageMessage(sender); + } + } +} diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index 6a1738004..3b5137dd8 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -239,6 +239,17 @@ "not_found": "Quest not found.", "invalid_id": "Invalid quest ID.", "description": "Add or finish quests", + "running": "Quest %s is %s (%s).", + "talking": "Talk %s is %s for main quest %s (%s).", + "state": { + "none": "unknown (none)", + "unstarted": "unfinished (not started, not completed)", + "unfinished": "unfinished (started, not completed)", + "finished": "finished (completed)", + "failed": "finished (completed, but failed)", + "exists": "found", + "not_exists": "not found" + }, "enabled": "Questing enabled." }, "group": { diff --git a/src/main/resources/languages/es-ES.json b/src/main/resources/languages/es-ES.json index 5f76ae1c9..3ff9cb62e 100644 --- a/src/main/resources/languages/es-ES.json +++ b/src/main/resources/languages/es-ES.json @@ -239,6 +239,17 @@ "not_found": "Misión no encontrada.", "invalid_id": "ID de misión inválido.", "description": "Añade o finaliza misiones", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/fr-FR.json b/src/main/resources/languages/fr-FR.json index d7fc5bb16..05db4bd7b 100644 --- a/src/main/resources/languages/fr-FR.json +++ b/src/main/resources/languages/fr-FR.json @@ -239,6 +239,17 @@ "not_found": "Quête introuvable.", "invalid_id": "ID de la quête invalide.", "description": "Ajoute ou termine une quête", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "Quêtes activées." }, "group": { diff --git a/src/main/resources/languages/it-IT.json b/src/main/resources/languages/it-IT.json index 0dc995857..abb6415bd 100644 --- a/src/main/resources/languages/it-IT.json +++ b/src/main/resources/languages/it-IT.json @@ -239,6 +239,17 @@ "not_found": "Missione non trovata.", "invalid_id": "ID missione non valido.", "description": "Aggiungi o completa missioni", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/ja-JP.json b/src/main/resources/languages/ja-JP.json index 6e9d5aa50..58494a81a 100644 --- a/src/main/resources/languages/ja-JP.json +++ b/src/main/resources/languages/ja-JP.json @@ -239,6 +239,17 @@ "not_found": "クエストが見つかりません。", "invalid_id": "クエストIDが無効です。", "description": "クエストを追加または終了します。", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/ko-KR.json b/src/main/resources/languages/ko-KR.json index 2779caf98..8b11582c8 100644 --- a/src/main/resources/languages/ko-KR.json +++ b/src/main/resources/languages/ko-KR.json @@ -239,6 +239,17 @@ "not_found": "퀘스트를 찾을 수 없습니다.", "invalid_id": "퀘스트ID를 찾을 수 없습니다.", "description": "퀘스트를 추가하거나 완료합니다.", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/pl-PL.json b/src/main/resources/languages/pl-PL.json index b70dcd0b8..01f96f410 100644 --- a/src/main/resources/languages/pl-PL.json +++ b/src/main/resources/languages/pl-PL.json @@ -239,6 +239,17 @@ "not_found": "Nie ma zadania o podanym ID.", "invalid_id": "Błędny format ID zadania.", "description": "Dodaj lub wykonaj wskazane zadanie.", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/ro-RO.json b/src/main/resources/languages/ro-RO.json index 740110b29..120d7c2b8 100644 --- a/src/main/resources/languages/ro-RO.json +++ b/src/main/resources/languages/ro-RO.json @@ -239,6 +239,17 @@ "not_found": "Misiunea nu a fost găsită.", "invalid_id": "ID-ul misiunii nu a fost găsit.", "description": "Adaugă sau termină misiuni", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/ru-RU.json b/src/main/resources/languages/ru-RU.json index 526a3427b..95d82e7c3 100644 --- a/src/main/resources/languages/ru-RU.json +++ b/src/main/resources/languages/ru-RU.json @@ -239,6 +239,17 @@ "not_found": "Квест не найден.", "invalid_id": "Некорректный ID квеста.", "description": "Добавляет (add) или завершает (finish) квесты", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/zh-CN.json b/src/main/resources/languages/zh-CN.json index 508a7436b..f0d2e8cab 100644 --- a/src/main/resources/languages/zh-CN.json +++ b/src/main/resources/languages/zh-CN.json @@ -239,6 +239,17 @@ "not_found": "任务不存在。", "invalid_id": "无效的任务ID。", "description": "添加或完成任务", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": { diff --git a/src/main/resources/languages/zh-TW.json b/src/main/resources/languages/zh-TW.json index df397a288..c95dda82f 100644 --- a/src/main/resources/languages/zh-TW.json +++ b/src/main/resources/languages/zh-TW.json @@ -239,6 +239,17 @@ "not_found": "未找到任務", "invalid_id": "無效的任務ID", "description": "添加或完成任務", + "running": "🇺🇸Quest %s is %s (%s).", + "talking": "🇺🇸Talk %s is %s for main quest %s (%s).", + "state": { + "none": "🇺🇸unknown (none)", + "unstarted": "🇺🇸unfinished (not started, not completed)", + "unfinished": "🇺🇸unfinished (started, not completed)", + "finished": "🇺🇸finished (completed)", + "failed": "🇺🇸finished (completed, but failed)", + "exists": "🇺🇸found", + "not_exists": "🇺🇸not found" + }, "enabled": "🇺🇸Questing enabled." }, "group": {