From 5cc417c43c820c27c4a769ae6ca9b960f382ce32 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 5 Jun 2025 23:41:01 +0200 Subject: [PATCH] Add declined question handling in CheckCommand - Implemented tracking of declined questions during checks. - Updated messaging logic to display declined questions to users. - Added new translations for decline-related messages. --- .../steamwar/messages/BungeeCore.properties | 3 ++ .../messages/BungeeCore_de.properties | 2 + .../velocitycore/commands/CheckCommand.java | 42 +++++++++++++++++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index c46cd317..5b4b2400 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -325,12 +325,15 @@ CHECK_ABORT=§aThe test operation was canceled! CHECK_NEXT=Next question CHECK_ACCEPT=Accept CHECK_DECLINE=Decline +CHECK_MARK_DECLINE=Mark Decline CHECK_RANK=§aRank {0}: {1} CHECK_RANK_HOVER=§aAccept with given rank CHECK_ACCEPTED=§aYour §e{0} {1} §ewas accepted§8! CHECK_ACCEPTED_TEAM=§7The schematic §e{0} §7from §e{1} §7is now approved! CHECK_DECLINED=§cYour §e{0} {1} §cwas declined§8: §c{2} CHECK_DECLINED_TEAM=§7The schematic §e{0} §7from §e{1} §7is now declined because §e{2}§7! +CHECK_DECLINED_QUESTIONS=§fQuestions answered declined: +CHECK_DECLINED_QUESTION_FORMAT=§c{0}: {1} #HistoricCommand HISTORIC_BROADCAST=§7Historic §e{0} §7fight by §e{1}§8! diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index 51a47cc3..456d961a 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -307,12 +307,14 @@ CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen! CHECK_NEXT=Nächste Frage CHECK_ACCEPT=Annehmen CHECK_DECLINE=Ablehnen +CHECK_MARK_DECLINE=Ablehnen Markieren CHECK_RANK=§aRang {0}: {1} CHECK_RANK_HOVER=§aMit diesem Rang freigeben CHECK_ACCEPTED=§aDein §e{0} {1} §ewurde freigegeben§8! CHECK_ACCEPTED_TEAM=§7Die Schematic §e{0} §7von §e{1} §7ist nun freigegeben! CHECK_DECLINED=§cDein §e{0} {1} §cwurde abgelehnt§8: §c{2} CHECK_DECLINED_TEAM=§7Die Schematic §e{0} §7von §e{1} §7wurde aufgrund von §e{2} §7abgelehnt! +CHECK_DECLINED_QUESTIONS=§fAls abgelehnt markierte Fragen: #HistoricCommand HISTORIC_BROADCAST=§7Historischer §e{0}§8-§7Kampf von §e{1}§8! diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java index c678fa4c..2bff28bb 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/CheckCommand.java @@ -164,6 +164,14 @@ public class CheckCommand extends SWCommand { next(sender); } + @Register(value = "decline", description = "CHECK_HELP_DECLINE") + public void decline(PlayerChatter sender) { + if(notChecking(sender.getPlayer())) + return; + + currentCheckers.get(sender.getPlayer().getUniqueId()).markDeclined(); + } + @Register(value = "decline", description = "CHECK_HELP_DECLINE") public void decline(PlayerChatter sender, String... message) { if(notChecking(sender.getPlayer())) @@ -200,6 +208,8 @@ public class CheckCommand extends SWCommand { private final SchematicNode schematic; private final Timestamp startTime; private final ListIterator checkList; + private String currentQuestion; + private final List declinedQuestions = new ArrayList<>(); private CheckSession(PlayerChatter checker, SchematicNode schematic){ this.checker = checker; @@ -220,20 +230,44 @@ public class CheckCommand extends SWCommand { private void next() { if(!checkList.hasNext()){ - accept(); + if (declinedQuestions.isEmpty()) { + accept(); + } else { + checker.system("CHECK_DECLINED_QUESTIONS"); + int i = 1; + for (String s : declinedQuestions) { + checker.prefixless("CHECK_DECLINED_QUESTION_FORMAT", i++, s); + } + declinedQuestions.clear(); + checker.sendMessage(Component + .text(checker.parseToPlain("CHECK_ACCEPT")) + .color(NamedTextColor.GREEN) + .clickEvent(ClickEvent.suggestCommand("/check accept")) + .append(Component + .text(" " + checker.parseToPlain("CHECK_DECLINE")) + .color(NamedTextColor.RED) + .clickEvent(ClickEvent.suggestCommand("/check decline ")))); + } return; } - checker.prefixless("PLAIN_STRING", checkList.next()); + currentQuestion = checkList.next(); + + checker.prefixless("PLAIN_STRING", currentQuestion); checker.sendMessage(Component .text(checker.parseToPlain(checkList.hasNext() ? "CHECK_NEXT" : "CHECK_ACCEPT")) .color(NamedTextColor.GREEN) .clickEvent(ClickEvent.runCommand("/check next")) .append(Component - .text(" " + checker.parseToPlain("CHECK_DECLINE")) + .text(" " + checker.parseToPlain("CHECK_MARK_DECLINE")) .color(NamedTextColor.RED) - .clickEvent(ClickEvent.suggestCommand("/check decline ")))); + .clickEvent(ClickEvent.runCommand("/check decline")))); + } + + private void markDeclined() { + declinedQuestions.add(currentQuestion); + next(); } private void accept(){