Add quest debugging commands

This commit is contained in:
KingRainbow44 2023-04-30 20:53:23 -04:00
parent cf56d032de
commit 6869008bcc
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
12 changed files with 213 additions and 64 deletions

View File

@ -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) [<questId>]"},
permission = "player.quest",
permissionTargeted = "player.quest.others")
public final class QuestCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> 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) [<questId>]"},
permission = "player.quest",
permissionTargeted = "player.quest.others")
public final class QuestCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> 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);
}
}
}

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {