geforkt von SteamWar/BungeeCore
Merge branch 'master' into rework-BauServerHelp
# Conflicts: # src/de/steamwar/messages/BungeeCore.properties
Dieser Commit ist enthalten in:
Commit
ad2d48ccde
@ -119,6 +119,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new RankCommand();
|
new RankCommand();
|
||||||
new IgnoreCommand();
|
new IgnoreCommand();
|
||||||
new UnIgnoreCommand();
|
new UnIgnoreCommand();
|
||||||
|
new PollresultCommand();
|
||||||
|
|
||||||
if(!EVENT_MODE){
|
if(!EVENT_MODE){
|
||||||
new WebregisterCommand();
|
new WebregisterCommand();
|
||||||
@ -170,6 +171,8 @@ public class BungeeCore extends Plugin {
|
|||||||
send(player, ChatMessageType.SYSTEM, msg, onHover, onClick);
|
send(player, ChatMessageType.SYSTEM, msg, onHover, onClick);
|
||||||
}
|
}
|
||||||
public static void send(ProxiedPlayer player, ChatMessageType type, String msg, String onHover, ClickEvent onClick){
|
public static void send(ProxiedPlayer player, ChatMessageType type, String msg, String onHover, ClickEvent onClick){
|
||||||
|
if(type == ChatMessageType.CHAT && player.getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
||||||
|
return;
|
||||||
TextComponent message = stringToText(msg);
|
TextComponent message = stringToText(msg);
|
||||||
if(onHover != null)
|
if(onHover != null)
|
||||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||||
|
@ -88,6 +88,8 @@ public class Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
public static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||||
|
if(type == ChatMessageType.CHAT && sender instanceof ProxiedPlayer && ((ProxiedPlayer)sender).getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
||||||
|
return;
|
||||||
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
||||||
if(onHover != null)
|
if(onHover != null)
|
||||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||||
|
54
src/de/steamwar/bungeecore/commands/PollresultCommand.java
Normale Datei
54
src/de/steamwar/bungeecore/commands/PollresultCommand.java
Normale Datei
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 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.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PollresultCommand extends BasicCommand {
|
||||||
|
|
||||||
|
public PollresultCommand() {
|
||||||
|
super("pollresult", "bungeecore.pollresults");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] strings) {
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(PollSystem.noCurrentPoll()) {
|
||||||
|
Message.send("POLLRESULT_NOPOLL", sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
|
Map<String, Integer> voted = PollAnswer.getCurrentResults();
|
||||||
|
Message.send("POLLRESULT_HEADER", player, PollAnswer.getAllAnswered(), PollSystem.getQuestion());
|
||||||
|
for (Map.Entry<String, Integer> e: voted.entrySet()) {
|
||||||
|
Message.send("POLLRESULT_LIST", sender, e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -78,4 +78,8 @@ public class PollSystem extends BasicListener {
|
|||||||
public static int answers(){
|
public static int answers(){
|
||||||
return answers.size();
|
return answers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAnswer(int i) {
|
||||||
|
return answers.get(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ import de.steamwar.bungeecore.listeners.PollSystem;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PollAnswer {
|
public class PollAnswer {
|
||||||
|
|
||||||
@ -48,8 +50,31 @@ public class PollAnswer {
|
|||||||
return new PollAnswer(userID, PollSystem.getQuestion());
|
return new PollAnswer(userID, PollSystem.getQuestion());
|
||||||
return new PollAnswer(rs);
|
return new PollAnswer(rs);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
BungeeCore.log("Unable to get PollAnswer", e);
|
throw new SecurityException("Unable to get PollAnswer", e);
|
||||||
throw new SecurityException();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Integer> getCurrentResults() {
|
||||||
|
ResultSet set = SQL.select("SELECT Count(UserID) AS Times, Answer FROM PollAnswer WHERE Question = ? GROUP BY Answer ORDER BY `Times` ASC", PollSystem.getQuestion());
|
||||||
|
try {
|
||||||
|
Map<String, Integer> retMap = new HashMap<>();
|
||||||
|
while (set.next()) {
|
||||||
|
retMap.put(PollSystem.getAnswer(set.getInt("Answer")), set.getInt("Times"));
|
||||||
|
}
|
||||||
|
return retMap;
|
||||||
|
}catch (SQLException e) {
|
||||||
|
throw new SecurityException("Unable to get PollAnswer", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getAllAnswered() {
|
||||||
|
ResultSet set = SQL.select("SELECT Count(UserID) AS Times FROM PollAnswer WHERE Question = ?", PollSystem.getQuestion());
|
||||||
|
try {
|
||||||
|
if(!set.next())
|
||||||
|
throw new SecurityException("Could not get PollAnswers");
|
||||||
|
return set.getInt("Times");
|
||||||
|
}catch (SQLException e) {
|
||||||
|
throw new SecurityException("Unable to get PollAnswer", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,4 +79,9 @@ HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
|
|||||||
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
|
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
|
||||||
HELP_BAU_TESTARENA_HOVER=§eTestarena starten
|
HELP_BAU_TESTARENA_HOVER=§eTestarena starten
|
||||||
HELP_BAU_BAU=§8/§ehelp bau §8- §7Hilfe zu nützlichen Werkzeugen
|
HELP_BAU_BAU=§8/§ehelp bau §8- §7Hilfe zu nützlichen Werkzeugen
|
||||||
HELP_BAU_BAU_HOVER=§eNützliche Zusatzfunktionen
|
HELP_BAU_BAU_HOVER=§eNützliche Zusatzfunktionen
|
||||||
|
|
||||||
|
#PollresultCommand
|
||||||
|
POLLRESULT_NOPOLL=§cDerzeit läuft keine Umfrage.
|
||||||
|
POLLRESULT_HEADER=§eEs haben {0} abgestimmt auf die Frage: §7{1}
|
||||||
|
POLLRESULT_LIST=§e{0}§8: §7{1}
|
In neuem Issue referenzieren
Einen Benutzer sperren