Archiviert
1
0

Merge branch 'master' into IgnoreSystem

Dieser Commit ist enthalten in:
Lixfel 2020-08-25 06:23:32 +02:00
Commit 17e971f668
19 geänderte Dateien mit 431 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -26,10 +26,20 @@ public class ArenaMode {
return byInternal.get(name); return byInternal.get(name);
} }
public static List<String> getAllChatNames() { public static List<String> getAllChatNames(boolean historic) {
List<String> chatNames = new LinkedList<>(); List<String> chatNames = new LinkedList<>();
for(ArenaMode mode : byInternal.values()){ for(ArenaMode mode : byInternal.values()){
chatNames.addAll(mode.chatNames); if(historic == mode.historic)
chatNames.addAll(mode.chatNames);
}
return chatNames;
}
public static List<String> getAllRankedChatNames(){
List<String> chatNames = new LinkedList<>();
for(ArenaMode mode : byInternal.values()){
if(mode.isRanked())
chatNames.addAll(mode.chatNames);
} }
return chatNames; return chatNames;
} }
@ -48,6 +58,8 @@ public class ArenaMode {
private final String serverJar; private final String serverJar;
private final List<String> maps; private final List<String> maps;
private final boolean historic; private final boolean historic;
private final boolean ranked;
private final String schemType;
private ArenaMode(String internalName, Configuration config){ private ArenaMode(String internalName, Configuration config){
this.internalName = internalName; this.internalName = internalName;
@ -55,7 +67,9 @@ public class ArenaMode {
this.serverJar = config.getString("serverJar"); this.serverJar = config.getString("serverJar");
this.chatNames = config.getStringList("chatNames"); this.chatNames = config.getStringList("chatNames");
this.maps = config.getStringList("maps"); this.maps = config.getStringList("maps");
this.historic = config.getBoolean("historic"); this.historic = config.getBoolean("historic", false);
this.ranked = config.getBoolean("ranked", false);
this.schemType = config.getString("schemType", null);
allModes.add(this); allModes.add(this);
byInternal.put(internalName, this); byInternal.put(internalName, this);
@ -106,4 +120,12 @@ public class ArenaMode {
public boolean isHistoric(){ public boolean isHistoric(){
return historic; return historic;
} }
public boolean isRanked() {
return ranked;
}
public String getSchemType() {
return schemType;
}
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.listeners.*; import de.steamwar.bungeecore.listeners.*;
import de.steamwar.bungeecore.listeners.mods.Fabric;
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;
@ -56,6 +57,7 @@ public class BungeeCore extends Plugin {
new ConnectionListener(); new ConnectionListener();
new Forge(); new Forge();
new LabyMod(); new LabyMod();
new Fabric();
new ChatListener(); new ChatListener();
new BanListener(); new BanListener();
new CheckListener(); new CheckListener();
@ -95,6 +97,8 @@ public class BungeeCore extends Plugin {
new RegelnCommand(); new RegelnCommand();
new HistoricCommand(); new HistoricCommand();
new CheckCommand(); new CheckCommand();
new RankedCommand();
new RankCommand();
new EventStarter(); new EventStarter();
new Broadcaster(); new Broadcaster();

Datei anzeigen

@ -62,10 +62,13 @@ public class SubserverSystem {
* For event, test and normal arenas: The UUID of the designated leader for the red team * For event, test and normal arenas: The UUID of the designated leader for the red team
* or null (no designated leader). * or null (no designated leader).
* *
* @param ranked
* If the game is a ranked game.
*
* @return * @return
* The new started subserver. * The new started subserver.
*/ */
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2){ public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){
//Generate missing parameters //Generate missing parameters
int port = freePort(2500); int port = freePort(2500);
@ -98,6 +101,8 @@ public class SubserverSystem {
cmd.add("-DredLeader=" + player2.toString()); cmd.add("-DredLeader=" + player2.toString());
if(checkSchemID != 0) if(checkSchemID != 0)
cmd.add("-DcheckSchemID=" + checkSchemID); cmd.add("-DcheckSchemID=" + checkSchemID);
if(ranked)
cmd.add("-Dranked=true");
cmd.add("-Xmx2G"); cmd.add("-Xmx2G");
cmd.addAll(JVM_ARGS); cmd.addAll(JVM_ARGS);
cmd.add("-jar"); cmd.add("-jar");
@ -136,6 +141,10 @@ public class SubserverSystem {
}); });
} }
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2){
return startArena(modus, map, eventFightID, checkSchemID, serverName, mapName, player1, player2, false);
}
public static Subserver startArena(ArenaMode modus, String map){ public static Subserver startArena(ArenaMode modus, String map){
return startArena(modus, map, 0, 0, null, null, null, null); return startArena(modus, map, 0, 0, null, null, null, null);
} }

Datei anzeigen

@ -30,6 +30,9 @@ public class ChallengeCommand extends BasicCommand {
if(target == null){ if(target == null){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer gewünschte Spieler ist nicht online."); BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer gewünschte Spieler ist nicht online.");
return; return;
}else if(target == sender){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cSchizophren?");
return;
} }
if (IgnoreSystem.isIgnored(target.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) { if (IgnoreSystem.isIgnored(target.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
@ -80,7 +83,7 @@ public class ChallengeCommand extends BasicCommand {
@Override @Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 2) if(args.length == 2)
return ArenaMode.getAllChatNames(); return ArenaMode.getAllChatNames(false);
return new ArrayList<>(); return new ArrayList<>();
} }
} }

Datei anzeigen

@ -235,8 +235,10 @@ public class CheckCommand extends BasicCommand {
}else if(ranks.containsKey(schematic.getSchemType())){ }else if(ranks.containsKey(schematic.getSchemType())){
next = new TextComponent(); next = new TextComponent();
List<String> r = ranks.get(schematic.getSchemType()); List<String> r = ranks.get(schematic.getSchemType());
for(int i = 0; i < r.size(); i++) for(int i = 0; i < r.size(); i++){
BungeeCore.send(checker, "§aRang " + (i+1) + ": " + r.get(i), "§aMit diesem Rang freigeben", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow " + (i+1))); BungeeCore.send(checker, "§aRang " + (i+1) + ": " + r.get(i), "§aMit diesem Rang freigeben", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow " + (i+1)));
BungeeCore.send(checker, "");
}
}else{ }else{
next = new TextComponent("accept "); next = new TextComponent("accept ");
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow")); next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));

Datei anzeigen

@ -26,7 +26,7 @@ public class FightCommand extends BasicCommand {
super("fight", "", "f"); super("fight", "", "f");
} }
private static ArenaMode getMode(CommandSender sender, String arg){ static ArenaMode getMode(CommandSender sender, String arg){
ArenaMode mode = ArenaMode.getByChat(arg); ArenaMode mode = ArenaMode.getByChat(arg);
if(mode != null) if(mode != null)
return mode; return mode;
@ -152,7 +152,7 @@ public class FightCommand extends BasicCommand {
@Override @Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){ if(args.length == 1){
return ArenaMode.getAllChatNames(); return ArenaMode.getAllChatNames(false);
}else if(args.length == 2){ }else if(args.length == 2){
ArenaMode mode = ArenaMode.getByChat(args[1]); ArenaMode mode = ArenaMode.getByChat(args[1]);
if(mode == null) if(mode == null)

Datei anzeigen

@ -69,11 +69,13 @@ public class HelpCommand extends BasicCommand {
sender.sendMessage("§8/§ereset §8- §7Setzt die derzeitige Region zurück"); sender.sendMessage("§8/§ereset §8- §7Setzt die derzeitige Region zurück");
sender.sendMessage("§8/§espeed §8- §7Ändert deine Fluggeschwindigkeit"); sender.sendMessage("§8/§espeed §8- §7Ändert deine Fluggeschwindigkeit");
sender.sendMessage("§8/§env §8- §7(de)aktiviert Nachtsicht"); sender.sendMessage("§8/§env §8- §7(de)aktiviert Nachtsicht");
sender.sendMessage("§8/§ewv §8- §7(de)aktiviert Unterwassersicht");
sender.sendMessage("§8/§etrace §8- §7Gibt einen Überblick über den TNT-Tracer"); sender.sendMessage("§8/§etrace §8- §7Gibt einen Überblick über den TNT-Tracer");
sender.sendMessage("§8/§eloader §8- §7Nutze den automatischen Kanonenlader"); sender.sendMessage("§8/§eloader §8- §7Nutze den automatischen Kanonenlader");
sender.sendMessage("§8/§eprotect §8- §7Schützt den Boden der (M)WG-Region"); sender.sendMessage("§8/§eprotect §8- §7Schützt den Boden der (M)WG-Region");
sender.sendMessage("§8/§efreeze §8- §7Unterbindet Blockupdates"); sender.sendMessage("§8/§efreeze §8- §7Unterbindet Blockupdates");
sender.sendMessage("§8/§eskull §8- §7Gibt dir den Kopf eines Spielers"); sender.sendMessage("§8/§eskull §8- §7Gibt dir den Kopf eines Spielers");
sender.sendMessage("§8/§edebugstick §8- §7Gibt dir einen Debugstick (nur 1.15)");
sender.sendMessage("§8/§ebauinfo §8- §7Gibt dir Informationen über den Bauserver"); sender.sendMessage("§8/§ebauinfo §8- §7Gibt dir Informationen über den Bauserver");
sender.sendMessage("§8/§ehelp bauserver §8- §7Hilfe zum Bauserver"); sender.sendMessage("§8/§ehelp bauserver §8- §7Hilfe zum Bauserver");
} }

Datei anzeigen

@ -33,7 +33,7 @@ public class HistoricCommand extends BasicCommand {
@Override @Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){ if(args.length == 1){
return ArenaMode.getAllChatNames(); return ArenaMode.getAllChatNames(true);
}else if(args.length == 2){ }else if(args.length == 2){
ArenaMode mode = ArenaMode.getByChat(args[1]); ArenaMode mode = ArenaMode.getByChat(args[1]);
if(mode == null) if(mode == null)

Datei anzeigen

@ -50,7 +50,7 @@ public class MsgCommand extends BasicCommand {
} }
StringBuilder msgBuilder = new StringBuilder(); StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append("§8").append(player.getName()).append("»").append(target.getName()).append(" §r§7"); msgBuilder.append("§e").append(player.getName()).append("§8»§e").append(target.getName()).append(" §r§7");
for (int i = 1; i < args.length; i++){ for (int i = 1; i < args.length; i++){
msgBuilder.append(args[i]).append(" "); msgBuilder.append(args[i]).append(" ");
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class RCommand extends BasicCommand {
} }
StringBuilder msgBuilder = new StringBuilder(); StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append("§8").append(player.getName()).append("»").append(target.getName()).append(" §r§7"); msgBuilder.append("§e").append(player.getName()).append("§8»§e").append(target.getName()).append(" §r§7");
for (String arg : args){ for (String arg : args){
msgBuilder.append(arg).append(" "); msgBuilder.append(arg).append(" ");
} }

Datei anzeigen

@ -0,0 +1,48 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.Elo;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.List;
public class RankCommand extends BasicCommand {
public RankCommand() {
super("rank", null);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7§lPlatzierungen");
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
for(ArenaMode mode : ArenaMode.getAllModes()){
if(!mode.isRanked())
continue;
int elo = Elo.getElo(user.getId(), mode.getSchemType());
int placement = Elo.getPlacement(elo, mode.getSchemType());
if(placement == -1)
BungeeCore.send(player, "§7" + mode.getChatName() + "§8: §eunplatziert");
else
BungeeCore.send(player, "§7" + mode.getChatName() + "§8: §e" + ++placement + "§8. §7mit §e" + elo + " §7Elo§8.");
}
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length > 1)
return new ArrayList<>();
List<String> result = ArenaMode.getAllRankedChatNames();
result.removeIf(name -> !name.startsWith(args[0]));
return result;
}
}

Datei anzeigen

@ -0,0 +1,196 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.Elo;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class RankedCommand extends BasicCommand {
private static Map<ArenaMode, WaitingQueue> queues = new HashMap<>();
public RankedCommand() {
super("ranked", null);
for(ArenaMode mode : ArenaMode.getAllModes())
if(mode.isRanked())
queues.put(mode, new WaitingQueue(mode));
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::checkForGames, 1, 1, TimeUnit.SECONDS);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 1){
getModes(sender, "/ranked ");
return;
}else if(!(sender instanceof ProxiedPlayer))
return;
ArenaMode mode = FightCommand.getMode(sender, args[0]);
if(mode == null)
return;
else if(!mode.isRanked()){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDieser Spielmodus ist nicht für Ranglistenspiele freigeschalten");
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
queues.get(mode).togglePlayer(player);
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length > 1)
return new ArrayList<>();
List<String> result = ArenaMode.getAllRankedChatNames();
result.removeIf(name -> !name.startsWith(args[0]));
return result;
}
static void getModes(CommandSender sender, String precommand){
TextComponent start = new TextComponent();
TextComponent current = start;
for(ArenaMode mode : ArenaMode.getAllModes()){
if(!mode.hasChatName() || !mode.isRanked())
continue;
String command = precommand + mode.getChatName();
current.setBold(true);
current.setColor(ChatColor.GRAY);
current.setText(mode.getChatName() + " ");
current.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§e" + command).create()));
current.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
if(current != start)
start.addExtra(current);
current = new TextComponent();
}
sender.sendMessage(start);
}
private void checkForGames(){
for(WaitingQueue queue : queues.values())
queue.checkForGames();
}
private static class WaitingQueue{
Set<WaitingPlayer> players = new HashSet<>();
private final ArenaMode mode;
private WaitingQueue(ArenaMode mode) {
this.mode = mode;
}
private void togglePlayer(ProxiedPlayer player){
for(WaitingPlayer wp : players){
if(wp.player == player){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cRanglistenspiel-Warteschlange verlassen");
players.remove(wp);
return;
}
}
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aRanglistenspiel-Warteschlange betreten");
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Wiederhole den Befehl zum Verlassen der Warteschlange");
players.add(new WaitingPlayer(player, mode.getSchemType()));
}
private void removeFromAll(ProxiedPlayer player){
for(WaitingQueue queue : queues.values()){
Iterator<WaitingPlayer> it = queue.players.iterator();
while(it.hasNext()){
WaitingPlayer wp = it.next();
if(wp.player == player){
it.remove();
break;
}
}
}
}
private void checkForGames(){
players.removeIf(wp -> !wp.doesStillWait());
Map<WaitingPlayer, WaitingPlayer> inRange = new HashMap<>();
//Find games
for(WaitingPlayer wp1 : players){
if(inRange.containsValue(wp1))
continue;
for(WaitingPlayer wp2 : players){
if(wp1 == wp2 || inRange.containsKey(wp2) || inRange.containsValue(wp2))
continue;
if(wp1.inRange(wp2))
inRange.putIfAbsent(wp1, wp2);
}
wp1.increment();
}
for(Map.Entry<WaitingPlayer, WaitingPlayer> entry : inRange.entrySet()){
WaitingPlayer wp1 = entry.getKey();
WaitingPlayer wp2 = entry.getValue();
BungeeCore.send(wp1.player, BungeeCore.CHAT_PREFIX + "§eGegner gefunden! Ranglistenspiel startet.");
BungeeCore.send(wp2.player, BungeeCore.CHAT_PREFIX + "§eGegner gefunden! Ranglistenspiel startet.");
removeFromAll(wp1.player);
removeFromAll(wp2.player);
String serverName = wp1.player.getName() + " vs " + wp2.player.getName();
Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, serverName, serverName.replace(' ', '_'), wp1.player.getUniqueId(), wp2.player.getUniqueId(), true);
arena.sendPlayer(wp1.player);
arena.sendPlayer(wp2.player);
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7" + mode.getDisplayName() + "§8-§7Ranglistenspiel§8: §e" + serverName,
"§aZuschauen",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + wp1.player.getName()));
}
}
}
private static class WaitingPlayer{
private int currentRange;
private final int elo;
private final ProxiedPlayer player;
private WaitingPlayer(ProxiedPlayer player, String gameMode){
this.player = player;
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
elo = Elo.getElo(user.getId(), gameMode);
currentRange = 0;
}
private boolean inRange(WaitingPlayer player){
return Math.abs(elo - player.elo) <= this.currentRange;
}
private void increment(){
currentRange++;
}
private boolean doesStillWait(){
if(!player.isConnected())
return false;
Subserver subserver = Subserver.getSubserver(player);
if(subserver == null)
return true;
if(subserver.getType() == Servertype.ARENA){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cRanglistenspiel-Warteschlange verlassen");
return false;
}
return true;
}
}
}

Datei anzeigen

@ -45,6 +45,9 @@ public class WebregisterCommand extends BasicCommand {
case "invalid_email": case "invalid_email":
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c[E-Mail], nicht [Freitext]!"); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c[E-Mail], nicht [Freitext]!");
break; break;
case "email_updated":
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDeine E-Mail-Adresse wurde aktualisiert.");
break;
default: default:
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer."); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer.");
SWException.log("Bungee", "Unknown Wordpress User Creation Error", errorLine); SWException.log("Bungee", "Unknown Wordpress User Creation Error", errorLine);

Datei anzeigen

@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
public class ChatListener extends BasicListener { public class ChatListener extends BasicListener {
private static final Title LIXFEL = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lLIXFEL")); private static final Title LIXFEL = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lLIXFEL"));
private static final Title YOYONOW = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lYOYONOW"));
@EventHandler @EventHandler
public void onChatEvent(ChatEvent e){ public void onChatEvent(ChatEvent e){
@ -75,9 +76,9 @@ public class ChatListener extends BasicListener {
} }
} }
private void lixfelAlert(ProxiedPlayer sender){ private void lixfelAlert(ProxiedPlayer sender) {
LIXFEL.send(sender); LIXFEL.send(sender);
final String l = "§8Lixfel»" + sender.getName() + " §c"; final String l = "§eLixfel§8»§e" + sender.getName() + "§8» §c";
BungeeCore.send(sender, ChatMessageType.ACTION_BAR, "§4§lTechnische Probleme?"); BungeeCore.send(sender, ChatMessageType.ACTION_BAR, "§4§lTechnische Probleme?");
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler(); TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Du hast mich gerufen!"), 3, TimeUnit.SECONDS); scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Du hast mich gerufen!"), 3, TimeUnit.SECONDS);
@ -87,12 +88,25 @@ public class ChatListener extends BasicListener {
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis."), 15, TimeUnit.SECONDS); scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis."), 15, TimeUnit.SECONDS);
} }
private void yoyonowAlert(ProxiedPlayer sender) {
YOYONOW.send(sender);
final String l = "§eYoyoNow§8»§e" + sender.getName() + "§8» §c";
BungeeCore.send(sender, ChatMessageType.ACTION_BAR, "§4§lTechnische Probleme?");
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Du hast mich gerufen!"), 3, TimeUnit.SECONDS);
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Ich würde dir gerne den Befehl \"/bug <MESSAGE>\" ans Herz legen."), 10, TimeUnit.SECONDS);
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Vielen Dank."), 12, TimeUnit.SECONDS);
scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Ich wünsche dir noch weiterhin ein reibungsloses Spielerlebnis."), 15, TimeUnit.SECONDS);
}
private void onChat(ChatEvent e){ private void onChat(ChatEvent e){
if(e.getSender() instanceof ProxiedPlayer){ if(e.getSender() instanceof ProxiedPlayer){
ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
if(e.getMessage().contains("LIXFEL")) if (e.getMessage().contains("LIXFEL"))
lixfelAlert(sender); lixfelAlert(sender);
if (e.getMessage().contains("YOYONOW"))
yoyonowAlert(sender);
if(sender.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){ if(sender.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!"); BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!");
@ -126,6 +140,7 @@ public class ChatListener extends BasicListener {
String name = sender.getDisplayName(); String name = sender.getDisplayName();
String chatsuffix = "§7» "; String chatsuffix = "§7» ";
message = message.replace('§', '&');
if(sender.hasPermission("bungeecore.group.admin")){ if(sender.hasPermission("bungeecore.group.admin")){
chatsuffix = "§7» §e"; chatsuffix = "§7» §e";
message = ChatColor.translateAlternateColorCodes('&', message); message = ChatColor.translateAlternateColorCodes('&', message);
@ -146,7 +161,7 @@ public class ChatListener extends BasicListener {
} }
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
Subserver targetServer = Subserver.getSubserver(target); Subserver targetServer = Subserver.getSubserver(target);
if(targetServer == null || targetServer.getType() != Servertype.ARENA){ if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo()){
BungeeCore.send(target, ChatMessageType.CHAT, msg); BungeeCore.send(target, ChatMessageType.CHAT, msg);
} }
} }

Datei anzeigen

@ -19,8 +19,7 @@ import net.md_5.bungee.api.event.ServerDisconnectEvent;
import net.md_5.bungee.api.event.ServerKickEvent; import net.md_5.bungee.api.event.ServerKickEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import java.util.Collection; import java.util.*;
import java.util.Iterator;
public class ConnectionListener extends BasicListener { public class ConnectionListener extends BasicListener {
@ -29,6 +28,12 @@ public class ConnectionListener extends BasicListener {
public static final String CHECK_PERMISSION = "bungeecore.check"; public static final String CHECK_PERMISSION = "bungeecore.check";
private static final String YOUTUBER_MODS = "bungeecore.youtubermods"; private static final String YOUTUBER_MODS = "bungeecore.youtubermods";
private static final Set<UUID> newPlayers = new HashSet<>();
public static void newPlayer(UUID player){
newPlayers.add(player);
}
@EventHandler @EventHandler
public void onPostLogin(PostLoginEvent event) { public void onPostLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer(); ProxiedPlayer player = event.getPlayer();
@ -38,28 +43,28 @@ public class ConnectionListener extends BasicListener {
case "Admin": case "Admin":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.admin", true); player.setPermission("bungeecore.group.admin", true);
player.setPermission("bungeecore.check", true); player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true); player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§4Admin " + player.getName() + "§r"); player.setDisplayName("§4Admin " + player.getName() + "§r");
break; break;
case "Developer": case "Developer":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.developer", true); player.setPermission("bungeecore.group.developer", true);
player.setPermission("bungeecore.check", true); player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true); player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§3Developer " + player.getName() + "§r"); player.setDisplayName("§3Developer " + player.getName() + "§r");
break; break;
case "Moderator": case "Moderator":
player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.moderator", true); player.setPermission("bungeecore.group.moderator", true);
player.setPermission("bungeecore.check", true); player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true); player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§bModerator " + player.getName() + "§r"); player.setDisplayName("§bModerator " + player.getName() + "§r");
break; break;
case "Supporter": case "Supporter":
player.addGroups(TEAM_GROUP); player.addGroups(TEAM_GROUP);
player.setPermission("bungeecore.group.supporter", true); player.setPermission("bungeecore.group.supporter", true);
player.setPermission("bungeecore.check", true); player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true); player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§1Supporter " + player.getName() + "§r"); player.setDisplayName("§1Supporter " + player.getName() + "§r");
break; break;
@ -80,6 +85,7 @@ public class ConnectionListener extends BasicListener {
break; break;
} }
for(Subserver subserver : Subserver.getServerList()){ for(Subserver subserver : Subserver.getServerList()){
if(subserver.getType() == Servertype.ARENA){ if(subserver.getType() == Servertype.ARENA){
Iterator<ProxiedPlayer> it = subserver.getServer().getPlayers().iterator(); Iterator<ProxiedPlayer> it = subserver.getServer().getPlayers().iterator();
@ -91,6 +97,11 @@ public class ConnectionListener extends BasicListener {
} }
} }
} }
if(newPlayers.contains(player.getUniqueId())){
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Begrüßt alle mal §e" + player.getName() + " §7auf dem Server§8!");
newPlayers.remove(player.getUniqueId());
}
} }
/** To redirect players to the lobby in case of server closure. */ /** To redirect players to the lobby in case of server closure. */

Datei anzeigen

@ -74,8 +74,8 @@ public class TablistManager extends BasicListener {
size = (size+19)/20; size = (size+19)/20;
if(size > 4) if(size > 5)
size = 4; size = 5;
} }
private synchronized void updateCustomTablist(){ private synchronized void updateCustomTablist(){
@ -163,9 +163,9 @@ public class TablistManager extends BasicListener {
i++; i++;
for (ProxiedPlayer p : playerMap.get(server)){ for (ProxiedPlayer p : playerMap.get(server)){
if(currentServer == p.getServer().getInfo()) if(currentServer == p.getServer().getInfo())
setSlot(i%20, i/20, BungeeTabListPlusAPI.getIconFromPlayer(p), p.getDisplayName(), 1); setSlot(i%20, i/20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), 1);
else else
setSlot(i%20, i/20, BungeeTabListPlusAPI.getIconFromPlayer(p), "§7" + p.getDisplayName(), 500); setSlot(i%20, i/20, BungeeTabListPlusAPI.getIconFromPlayer(p), "§7" + getTablistName(p), 500);
i++; i++;
} }
} }
@ -179,5 +179,22 @@ public class TablistManager extends BasicListener {
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
} }
} }
private String getTablistName(ProxiedPlayer p){
if(p.hasPermission("bungeecore.group.admin"))
return "§4" + p.getName();
else if(p.hasPermission("bungeecore.group.developer"))
return "§3" + p.getName();
else if(p.hasPermission("bungeecore.group.moderator"))
return "§b" + p.getName();
else if(p.hasPermission("bungeecore.group.supporter"))
return "§1" + p.getName();
else if(p.hasPermission("bungeecore.group.builder"))
return "§2" + p.getName();
else if(p.hasPermission("bungeecore.group.youtuber"))
return "§5" + p.getName();
else
return p.getName();
}
} }
} }

Datei anzeigen

@ -0,0 +1,26 @@
package de.steamwar.bungeecore.listeners.mods;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.listeners.BasicListener;
import net.md_5.bungee.api.connection.Connection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;
public class Fabric extends BasicListener {
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){
Connection sender = e.getSender();
if(!(sender instanceof ProxiedPlayer))
return;
if(!e.getTag().equals("minecraft:brand"))
return;
if(new String(e.getData()).contains("fabric")){
ProxiedPlayer p = (ProxiedPlayer) sender;
p.disconnect(BungeeCore.stringToText("§7Die Verwendung von Fabric ist auf §eSteam§8War §7nicht gestattet."));
}
}
}

Datei anzeigen

@ -0,0 +1,32 @@
package de.steamwar.bungeecore.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Elo {
private Elo(){}
public static int getElo(int userID, String gameMode){
ResultSet rs = SQL.select("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ?", userID, gameMode);
int elo = 1000;
try {
if(rs.next())
elo = rs.getInt("Elo");
} catch (SQLException e) {
throw new SecurityException("Could not get Elo", e);
}
return elo;
}
public static int getPlacement(int elo, String gameMode){
ResultSet rs = SQL.select("SELECT COUNT(*) AS Place FROM Elo WHERE GameMode = ? AND Elo > ?", gameMode, elo);
try{
if(!rs.next())
return -1;
return rs.getInt("Place");
}catch(SQLException e){
throw new SecurityException("Could not get place", e);
}
}
}

Datei anzeigen

@ -2,11 +2,14 @@ package de.steamwar.bungeecore.sql;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.commands.WebregisterCommand; import de.steamwar.bungeecore.commands.WebregisterCommand;
import de.steamwar.bungeecore.listeners.ConnectionListener;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -31,6 +34,16 @@ public class SteamwarUser {
private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>(); private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>();
private static final Map<Integer, SteamwarUser> usersById = new HashMap<>(); private static final Map<Integer, SteamwarUser> usersById = new HashMap<>();
private static final Timestamp PERMA_BAN = Timestamp.from(Instant.ofEpochSecond(946684800)); private static final Timestamp PERMA_BAN = Timestamp.from(Instant.ofEpochSecond(946684800));
private static final InetAddress LIXFEL_DE;
static {
try {
LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43});
} catch (UnknownHostException e) {
ProxyServer.getInstance().stop();
throw new SecurityException("Could not initialise address!", e);
}
}
private SteamwarUser(ResultSet rs) throws SQLException { private SteamwarUser(ResultSet rs) throws SQLException {
id = rs.getInt("id"); id = rs.getInt("id");
@ -62,9 +75,11 @@ public class SteamwarUser {
user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString())); user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString()));
if(user == null) if(user == null)
throw new SecurityException("user == null"); throw new SecurityException("user == null");
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Begrüßt alle mal §e" + connection.getName() + " §7auf dem Server§8!"); ConnectionListener.newPlayer(user.uuid);
} }
boolean bedrock = connection.getAddress().getAddress().equals(LIXFEL_DE);
SQL.update("UPDATE UserData SET Bedrock = ? WHERE id = ?", bedrock, user.id);
return user; return user;
} }