forked from SteamWar/SteamWar
Merge branch 'main' into VelocityCore/NoEvent
This commit is contained in:
@@ -226,11 +226,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!
|
||||
@@ -375,12 +370,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]
|
||||
|
||||
@@ -605,13 +594,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
|
||||
|
||||
@@ -208,10 +208,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!
|
||||
@@ -353,12 +349,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]
|
||||
|
||||
@@ -577,13 +567,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
|
||||
|
||||
@@ -68,18 +68,11 @@ public class Config {
|
||||
private boolean eventmode = false;
|
||||
private Map<String, Server> servers = Collections.emptyMap();
|
||||
private List<String> 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<String> answers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class Server {
|
||||
private int spectatePort = 0;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Chatter> noPoll() {
|
||||
return PollSystem.noPoll();
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
||||
sender.system("POLLRESULT_HEADER", voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
||||
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
||||
sender.prefixless("POLLRESULT_LIST", PollSystem.getAnswer(e.getKey()), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ClassValidator(value = Chatter.class, local = true)
|
||||
public TypeValidator<Chatter> noPoll() {
|
||||
return PollSystem.noPoll();
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Chatter> 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user