SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into moreMultiLingual

# Conflicts:
#	src/de/steamwar/messages/BungeeCore.properties
Dieser Commit ist enthalten in:
Lixfel 2020-11-27 23:50:09 +01:00
Commit b3fbce3c2b
10 geänderte Dateien mit 114 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.comms.SpigotReceiver; import de.steamwar.bungeecore.comms.SpigotReceiver;
import de.steamwar.bungeecore.listeners.*; 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.Forge;
import de.steamwar.bungeecore.listeners.mods.LabyMod; import de.steamwar.bungeecore.listeners.mods.LabyMod;
import de.steamwar.bungeecore.sql.SQL; import de.steamwar.bungeecore.sql.SQL;
@ -84,7 +84,7 @@ public class BungeeCore extends Plugin {
new ChatListener(); new ChatListener();
new BanListener(); new BanListener();
new CheckListener(); new CheckListener();
new Fabric(); new ModLoaderBlocker();
commands.put("/b", null); commands.put("/b", null);
commands.put("/gs", null); commands.put("/gs", null);
@ -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)));

Datei anzeigen

@ -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)));

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; 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 de.steamwar.bungeecore.sql.IgnoreSystem;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
@ -47,8 +47,8 @@ public class ChallengeCommand extends BasicCommand {
if (!(sender instanceof ProxiedPlayer)) if (!(sender instanceof ProxiedPlayer))
return; return;
if(Fabric.isFabric((ProxiedPlayer) sender)) { if(ModLoaderBlocker.isFabric((ProxiedPlayer) sender)) {
BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric nicht auf die Arenen darf?"); BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?");
return; return;
} }

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; 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.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
@ -128,8 +128,8 @@ public class FightCommand extends BasicCommand {
if(!(sender instanceof ProxiedPlayer)) if(!(sender instanceof ProxiedPlayer))
return; return;
if(Fabric.isFabric((ProxiedPlayer) sender) && !precommand.equals("/bau testarena")) { 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 nicht auf die Arenen darf?"); BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?");
return; return;
} }

Datei anzeigen

@ -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());
}
}
}

Datei anzeigen

@ -12,6 +12,9 @@ public class TablistNameHandler implements SpigotHandler {
@Override @Override
public void handle(ByteArrayDataInput byteArrayDataInput) { public void handle(ByteArrayDataInput byteArrayDataInput) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUuid()); 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());
} }
} }

Datei anzeigen

@ -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);
}
} }

Datei anzeigen

@ -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.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
public class Fabric extends BasicListener { public class ModLoaderBlocker extends BasicListener {
@EventHandler @EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){ public void onPluginMessageEvent(PluginMessageEvent e){
@ -46,6 +46,10 @@ public class Fabric extends BasicListener {
ProxiedPlayer p = (ProxiedPlayer) sender; ProxiedPlayer p = (ProxiedPlayer) sender;
Storage.fabricPlayers.add(p); Storage.fabricPlayers.add(p);
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast Fabric installiert. Mit Fabric kannst du nicht auf die Arenen"); 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 && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA
&& isFabric(event.getPlayer())) { && isFabric(event.getPlayer())) {
event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER)); 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");
} }
} }

Datei anzeigen

@ -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);
} }
} }

Datei anzeigen

@ -77,3 +77,8 @@ BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren? IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits. IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8. 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}