From 9a78b99a758509c68d190a771142b4f890b5a3da Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 2 Dec 2025 16:39:16 +0100 Subject: [PATCH 1/2] Remove Poll-System Signed-off-by: Chaoscaot --- .../SQL/src/de/steamwar/sql/PollAnswer.kt | 78 ---------------- .../src/de/steamwar/velocitycore/Config.java | 7 -- .../steamwar/velocitycore/VelocityCore.java | 2 - .../velocitycore/commands/PollCommand.java | 66 -------------- .../commands/PollresultCommand.java | 52 ----------- .../velocitycore/listeners/PollSystem.java | 91 ------------------- 6 files changed, 296 deletions(-) delete mode 100644 CommonCore/SQL/src/de/steamwar/sql/PollAnswer.kt delete mode 100644 VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java delete mode 100644 VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java delete mode 100644 VelocityCore/src/de/steamwar/velocitycore/listeners/PollSystem.java diff --git a/CommonCore/SQL/src/de/steamwar/sql/PollAnswer.kt b/CommonCore/SQL/src/de/steamwar/sql/PollAnswer.kt deleted file mode 100644 index a4c20b26..00000000 --- a/CommonCore/SQL/src/de/steamwar/sql/PollAnswer.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.sql - -import de.steamwar.sql.internal.useDb -import org.jetbrains.exposed.v1.core.VarCharColumnType -import org.jetbrains.exposed.v1.core.and -import org.jetbrains.exposed.v1.core.dao.id.CompositeID -import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable -import org.jetbrains.exposed.v1.core.dao.id.EntityID -import org.jetbrains.exposed.v1.core.eq -import org.jetbrains.exposed.v1.dao.CompositeEntity -import org.jetbrains.exposed.v1.dao.CompositeEntityClass - -object PollAnswerTable: CompositeIdTable("PollAnswer") { - val userId = reference("UserID", SteamwarUserTable) - val question = varchar("Question", 150) - val answer = integer("Answer") -} - -class PollAnswer(id: EntityID): CompositeEntity(id) { - var userId by PollAnswerTable.userId - private set - var question by PollAnswerTable.question - private set - private var answerId by PollAnswerTable.answer - var answer: Int - get() = answerId - set(value) = useDb { - answerId = value - } - - companion object: CompositeEntityClass(PollAnswerTable) { - @JvmStatic - var currentPoll: String? = null - - @JvmStatic - fun get(userId: Int) = useDb { - find { (PollAnswerTable.userId eq userId) and (PollAnswerTable.question eq currentPoll!!) }.firstOrNull() - ?: new { - this.userId = EntityID(userId, SteamwarUserTable) - this.question = currentPoll!! - this.answerId = 0 - } - } - - @JvmStatic - fun getCurrentResults(): Map = useDb { - exec("SELECT Count(UserID) AS Times, Answer FROM PollAnswer WHERE Question = ? GROUP BY Answer ORDER BY Times ASC", - args = listOf(VarCharColumnType() to currentPoll!!)) { - val result = mutableMapOf() - while (it.next()) { - result[it.getInt("Answer")] = it.getInt("Times") - } - result - } ?: emptyMap() - } - } - - fun hasAnswered() = answerId != 0 -} \ No newline at end of file diff --git a/VelocityCore/src/de/steamwar/velocitycore/Config.java b/VelocityCore/src/de/steamwar/velocitycore/Config.java index 276c8310..95a06dc3 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/Config.java +++ b/VelocityCore/src/de/steamwar/velocitycore/Config.java @@ -68,18 +68,11 @@ public class Config { private boolean eventmode = false; private Map servers = Collections.emptyMap(); private List broadcasts = Collections.emptyList(); - private Poll poll = null; public RegisteredServer lobbyserver() { return VelocityCore.getProxy().getServer(lobbyserver).orElseThrow(); } - @Getter - public static class Poll { - private String question; - private List answers; - } - @Getter public static class Server { private int spectatePort = 0; diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index 74efe014..ed3f9ade 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -46,7 +46,6 @@ import de.steamwar.velocitycore.commands.TeamCommand; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.DiscordConfig; import de.steamwar.velocitycore.listeners.BasicListener; -import de.steamwar.velocitycore.listeners.PollSystem; import lombok.Getter; import lombok.NonNull; @@ -135,7 +134,6 @@ public class VelocityCore implements ReloadablePlugin { schedule(TabCompletionCache::invalidateOldEntries).repeat(1, TimeUnit.SECONDS).schedule(); initStaticServers(); - PollSystem.init(); local = new Node.LocalNode(); if(MAIN_SERVER) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java deleted file mode 100644 index 58b9c4ef..00000000 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PollCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.velocitycore.commands; - -import de.steamwar.linkage.Linked; -import de.steamwar.velocitycore.listeners.PollSystem; -import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; -import de.steamwar.messages.Chatter; -import de.steamwar.sql.PollAnswer; - -@Linked -public class PollCommand extends SWCommand { - - public PollCommand() { - super("poll"); - } - - @Register - public void genericCommand(@Validator Chatter sender) { - PollSystem.sendPoll(sender); - } - - @Register(noTabComplete = true) - public void answerPoll(@Validator Chatter sender, String answerString) { - int answer; - try { - answer = Integer.parseUnsignedInt(answerString); - if(answer < 1 || answer > PollSystem.answers()) - throw new NumberFormatException(); - }catch(NumberFormatException e){ - sender.system("POLL_NO_ANSWER"); - return; - } - - PollAnswer pollAnswer = PollAnswer.get(sender.user().getId()); - if(pollAnswer.hasAnswered()) - sender.system("POLL_ANSWER_REFRESH"); - else - sender.system("POLL_ANSWER_NEW"); - - pollAnswer.setAnswer(answer); - } - - @ClassValidator(value = Chatter.class, local = true) - public TypeValidator noPoll() { - return PollSystem.noPoll(); - } -} diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java deleted file mode 100644 index 6e685ef3..00000000 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/PollresultCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.velocitycore.commands; - -import de.steamwar.linkage.Linked; -import de.steamwar.velocitycore.listeners.PollSystem; -import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; -import de.steamwar.messages.Chatter; -import de.steamwar.sql.PollAnswer; -import de.steamwar.sql.UserPerm; - -import java.util.Map; - -@Linked -public class PollresultCommand extends SWCommand { - - public PollresultCommand() { - super("pollresult", UserPerm.MODERATION); - } - - @Register - public void genericCommand(@Validator Chatter sender) { - Map voted = PollAnswer.getCurrentResults(); - sender.system("POLLRESULT_HEADER", voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll()); - for (Map.Entry e: voted.entrySet()) { - sender.prefixless("POLLRESULT_LIST", PollSystem.getAnswer(e.getKey()), e.getValue()); - } - } - - @ClassValidator(value = Chatter.class, local = true) - public TypeValidator noPoll() { - return PollSystem.noPoll(); - } -} diff --git a/VelocityCore/src/de/steamwar/velocitycore/listeners/PollSystem.java b/VelocityCore/src/de/steamwar/velocitycore/listeners/PollSystem.java deleted file mode 100644 index 94910720..00000000 --- a/VelocityCore/src/de/steamwar/velocitycore/listeners/PollSystem.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.velocitycore.listeners; - -import com.velocitypowered.api.event.Subscribe; -import com.velocitypowered.api.event.connection.PostLoginEvent; -import de.steamwar.velocitycore.Config; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.command.TypeValidator; -import de.steamwar.messages.Chatter; -import de.steamwar.messages.Message; -import de.steamwar.sql.PollAnswer; -import net.kyori.adventure.text.event.ClickEvent; - -public class PollSystem extends BasicListener { - - public static void init() { - poll = VelocityCore.get().getConfig().getPoll(); - if(poll == null) - return; - - if(noCurrentPoll()) - return; - - PollAnswer.setCurrentPoll(poll.getQuestion()); - new PollSystem(); - } - - private static Config.Poll poll = null; - - - @Subscribe - public void onPostLogin(PostLoginEvent event){ - Chatter player = Chatter.of(event.getPlayer()); - - PollAnswer answer = PollAnswer.get(player.user().getId()); - if(answer.hasAnswered()) - return; - - sendPoll(player); - } - - public static void sendPoll(Chatter player) { - player.system("POLL_HEADER"); - player.prefixless("POLL_HEADER2"); - player.prefixless("POLL_QUESTION", poll.getQuestion()); - - for(int i = 1; i <= poll.getAnswers().size(); i++) { - player.prefixless("POLL_ANSWER", new Message("POLL_ANSWER_HOVER", poll.getAnswers().get(i-1)), ClickEvent.runCommand("/poll " + i), poll.getAnswers().get(i-1)); - } - } - - private static boolean noCurrentPoll(){ - return poll == null; - } - - public static TypeValidator noPoll() { - return (sender, value, messageSender) -> { - if (PollSystem.noCurrentPoll()) { - messageSender.send("POLL_NO_POLL"); - return false; - } - return true; - }; - } - - public static int answers(){ - return poll.getAnswers().size(); - } - - public static String getAnswer(int i) { - return poll.getAnswers().get(i); - } -} From 4df92f7e5f2114bdc2395dc1b8062a8d282308bd Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 2 Dec 2025 20:43:37 +0100 Subject: [PATCH 2/2] Remove Poll-System Signed-off-by: Chaoscaot --- .../de/steamwar/messages/BungeeCore.properties | 18 ------------------ .../steamwar/messages/BungeeCore_de.properties | 17 ----------------- 2 files changed, 35 deletions(-) diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index 9f9c2e03..898f313f 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -218,11 +218,6 @@ IGNORE_YOURSELF=§cHow are you going to ignore yourself? IGNORE_ALREADY=§cYou are already ignoring this player. IGNORE_MESSAGE=§7You are now ignoring §e{0}§8. -#PollresultCommand -POLLRESULT_NOPOLL=§cThere is currently no ongoing poll. -POLLRESULT_HEADER=§e{0} players have voted on the question: §7{1} -POLLRESULT_LIST=§e{0}§8: §7{1} - #BauCommand BAU_ADDMEMBER_USAGE=§8/§7build addmember §8[§eplayer§8] BAU_ADDMEMBER_SELFADD=§cYou don't have to add yourself! @@ -367,12 +362,6 @@ MSG_IGNORED=§cThis player has blocked you! #PingCommand PING_RESPONSE=§7Your ping is §c{0}§7 ms! -#PollCommand -POLL_NO_POLL=§cThere is no ongoing poll. -POLL_NO_ANSWER=§cThis is not an option -POLL_ANSWER_REFRESH=§aYour answer was updated. -POLL_ANSWER_NEW=§aYour answer was registered. - #RCommand R_USAGE=§8/§7r §8[§eanswer§8] @@ -597,13 +586,6 @@ JOIN_STREAMING=§5Streaming Mode§7 is still active§8.§7 Keep in mind that you #EventModeListener EVENTMODE_KICK=§cYou are not an event participant. -#PollSystem -POLL_HEADER=§e§lPoll -POLL_HEADER2=§7Click the answer you like! -POLL_QUESTION=§e{0} -POLL_ANSWER=§7{0} -POLL_ANSWER_HOVER=§eChoose {0} - #TablistManager TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de TABLIST_PHASE_DISCORD=§8Discord: https://§eSteam§8War.de/discord diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index e6a06d11..969c9c64 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -200,10 +200,6 @@ IGNORE_YOURSELF=§cWie willst du dich selber ignorieren? IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits. IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8. -#PollresultCommand -POLLRESULT_NOPOLL=§cDerzeit läuft keine Umfrage. -POLLRESULT_HEADER=§eEs haben {0} abgestimmt auf die Frage: §7{1} - #BauCommand BAU_ADDMEMBER_USAGE=§8/§7bau addmember §8[§eSpieler§8] BAU_ADDMEMBER_SELFADD=§cDu brauchst dich nicht selbst hinzufügen! @@ -345,12 +341,6 @@ MSG_IGNORED=§cDieser Spieler hat dich geblockt! #PingCommand PING_RESPONSE=§7Dein Ping beträgt §c{0}§7 ms! -#PollCommand -POLL_NO_POLL=§cDerzeit läuft keine Umfrage. -POLL_NO_ANSWER=§cDas ist keine Antwortmöglichkeit! -POLL_ANSWER_REFRESH=§aDeine Antwort wurde aktualisiert. -POLL_ANSWER_NEW=§aDeine Antwort wurde registriert. - #RCommand R_USAGE=§8/§7r §8[§eAntwort§8] @@ -569,13 +559,6 @@ JOIN_STREAMING=§5Streaming-Modus§7 ist weiterhin aktiv§8.§7 Beachten Sie, da #EventModeListener EVENTMODE_KICK=§cDu bist kein Eventteilnehmer. -#PollSystem -POLL_HEADER=§e§lUmfrage -POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt! -POLL_QUESTION=§e{0} -POLL_ANSWER=§7{0} -POLL_ANSWER_HOVER=§e{0} §ewählen - #TablistManager TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_BAU=§7§lBau