diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java
index 25ccdf6..80881f3 100644
--- a/src/de/steamwar/bungeecore/BungeeCore.java
+++ b/src/de/steamwar/bungeecore/BungeeCore.java
@@ -22,7 +22,7 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.comms.SpigotReceiver;
import de.steamwar.bungeecore.listeners.*;
-import de.steamwar.bungeecore.listeners.mods.Fabric;
+import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.listeners.mods.Forge;
import de.steamwar.bungeecore.listeners.mods.LabyMod;
import de.steamwar.bungeecore.sql.SQL;
@@ -84,7 +84,7 @@ public class BungeeCore extends Plugin {
new ChatListener();
new BanListener();
new CheckListener();
- new Fabric();
+ new ModLoaderBlocker();
commands.put("/b", null);
commands.put("/gs", null);
@@ -119,6 +119,7 @@ public class BungeeCore extends Plugin {
new RankCommand();
new IgnoreCommand();
new UnIgnoreCommand();
+ new PollresultCommand();
if(!EVENT_MODE){
new WebregisterCommand();
@@ -170,6 +171,8 @@ public class BungeeCore extends Plugin {
send(player, ChatMessageType.SYSTEM, msg, onHover, 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);
if(onHover != null)
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java
index 2646045..1e5e0c0 100644
--- a/src/de/steamwar/bungeecore/Message.java
+++ b/src/de/steamwar/bungeecore/Message.java
@@ -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){
+ if(type == ChatMessageType.CHAT && sender instanceof ProxiedPlayer && ((ProxiedPlayer)sender).getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
+ return;
TextComponent msg = parseToComponent(message, prefixed, sender, params);
if(onHover != null)
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
index 4b07579..231081b 100644
--- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
+++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
@@ -20,7 +20,7 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
-import de.steamwar.bungeecore.listeners.mods.Fabric;
+import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.sql.IgnoreSystem;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@@ -47,8 +47,8 @@ public class ChallengeCommand extends BasicCommand {
if (!(sender instanceof ProxiedPlayer))
return;
- if(Fabric.isFabric((ProxiedPlayer) sender)) {
- BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric nicht auf die Arenen darf?");
+ if(ModLoaderBlocker.isFabric((ProxiedPlayer) sender)) {
+ BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?");
return;
}
diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java
index aa0485a..1c6cd2e 100644
--- a/src/de/steamwar/bungeecore/commands/FightCommand.java
+++ b/src/de/steamwar/bungeecore/commands/FightCommand.java
@@ -20,7 +20,7 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
-import de.steamwar.bungeecore.listeners.mods.Fabric;
+import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@@ -128,8 +128,8 @@ public class FightCommand extends BasicCommand {
if(!(sender instanceof ProxiedPlayer))
return;
- if(Fabric.isFabric((ProxiedPlayer) sender) && !precommand.equals("/bau testarena")) {
- BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric nicht auf die Arenen darf?");
+ if(ModLoaderBlocker.isFabric((ProxiedPlayer) sender) && !precommand.equals("/bau testarena")) {
+ BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?");
return;
}
diff --git a/src/de/steamwar/bungeecore/commands/PollresultCommand.java b/src/de/steamwar/bungeecore/commands/PollresultCommand.java
new file mode 100644
index 0000000..1d39e9e
--- /dev/null
+++ b/src/de/steamwar/bungeecore/commands/PollresultCommand.java
@@ -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 .
+ */
+
+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 voted = PollAnswer.getCurrentResults();
+ Message.send("POLLRESULT_HEADER", player, PollAnswer.getAllAnswered(), PollSystem.getQuestion());
+ for (Map.Entry e: voted.entrySet()) {
+ Message.send("POLLRESULT_LIST", sender, e.getKey(), e.getValue());
+ }
+ }
+}
diff --git a/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java b/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java
index 6f04943..678d930 100644
--- a/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java
+++ b/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java
@@ -12,6 +12,9 @@ public class TablistNameHandler implements SpigotHandler {
@Override
public void handle(ByteArrayDataInput byteArrayDataInput) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUuid());
- Subserver.getSubserver(player).getTablistNames().put(player, byteArrayDataInput.readUTF());
+ Subserver subserver = Subserver.getSubserver(player.getServer().getInfo());
+ if(subserver == null)
+ return;
+ subserver.getTablistNames().put(player, byteArrayDataInput.readUTF());
}
}
diff --git a/src/de/steamwar/bungeecore/listeners/PollSystem.java b/src/de/steamwar/bungeecore/listeners/PollSystem.java
index 4572e27..3dcca63 100644
--- a/src/de/steamwar/bungeecore/listeners/PollSystem.java
+++ b/src/de/steamwar/bungeecore/listeners/PollSystem.java
@@ -78,4 +78,8 @@ public class PollSystem extends BasicListener {
public static int answers(){
return answers.size();
}
+
+ public static String getAnswer(int i) {
+ return answers.get(i);
+ }
}
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
similarity index 86%
rename from src/de/steamwar/bungeecore/listeners/mods/Fabric.java
rename to src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
index 12ec282..af123d8 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
@@ -31,7 +31,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler;
-public class Fabric extends BasicListener {
+public class ModLoaderBlocker extends BasicListener {
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){
@@ -46,6 +46,10 @@ public class Fabric extends BasicListener {
ProxiedPlayer p = (ProxiedPlayer) sender;
Storage.fabricPlayers.add(p);
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast Fabric installiert. Mit Fabric kannst du nicht auf die Arenen");
+ }else if(new String(e.getData()).contains("LiteLoader")) {
+ ProxiedPlayer p = (ProxiedPlayer) sender;
+ Storage.fabricPlayers.add(p);
+ BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast LiteLoader installiert. Mit LiteLoader kannst du nicht auf die Arenen");
}
}
@@ -60,7 +64,7 @@ public class Fabric extends BasicListener {
&& Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA
&& isFabric(event.getPlayer())) {
event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER));
- BungeeCore.send(event.getPlayer(), BungeeCore.CHAT_PREFIX + "§cDu kannst nicht auf die Arena mit Fabric");
+ BungeeCore.send(event.getPlayer(), BungeeCore.CHAT_PREFIX + "§cMit Fabric und LiteLoader kannst du nicht auf die Arenen");
}
}
diff --git a/src/de/steamwar/bungeecore/sql/PollAnswer.java b/src/de/steamwar/bungeecore/sql/PollAnswer.java
index 043d1a6..62fcee0 100644
--- a/src/de/steamwar/bungeecore/sql/PollAnswer.java
+++ b/src/de/steamwar/bungeecore/sql/PollAnswer.java
@@ -24,6 +24,8 @@ import de.steamwar.bungeecore.listeners.PollSystem;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
public class PollAnswer {
@@ -48,8 +50,31 @@ public class PollAnswer {
return new PollAnswer(userID, PollSystem.getQuestion());
return new PollAnswer(rs);
} catch (SQLException e) {
- BungeeCore.log("Unable to get PollAnswer", e);
- throw new SecurityException();
+ throw new SecurityException("Unable to get PollAnswer", e);
+ }
+ }
+
+ public static Map 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 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);
}
}
diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties
index 82a71a4..2d5faee 100644
--- a/src/de/steamwar/messages/BungeeCore.properties
+++ b/src/de/steamwar/messages/BungeeCore.properties
@@ -76,4 +76,9 @@ BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
-IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
\ No newline at end of file
+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}
+POLLRESULT_LIST=§e{0}§8: §7{1}
\ No newline at end of file