From 99c1aa1741cc7bfc9b0db3fadf044c2c0f7b4417 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 3 Jul 2020 22:06:51 +0200 Subject: [PATCH 01/20] Add option to change email + one line distance between selection options Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/CheckCommand.java | 4 +++- src/de/steamwar/bungeecore/commands/WebregisterCommand.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 34358c1f..ca1fed35 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -235,8 +235,10 @@ public class CheckCommand extends BasicCommand { }else if(ranks.containsKey(schematic.getSchemType())){ next = new TextComponent(); List 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, ""); + } }else{ next = new TextComponent("accept "); next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow")); diff --git a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java b/src/de/steamwar/bungeecore/commands/WebregisterCommand.java index 0eb502c3..54468f1e 100644 --- a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java +++ b/src/de/steamwar/bungeecore/commands/WebregisterCommand.java @@ -45,6 +45,9 @@ public class WebregisterCommand extends BasicCommand { case "invalid_email": BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c[E-Mail], nicht [Freitext]!"); break; + case "email_updated": + BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDeine E-Mail-Adresse wurde aktualisiert."); + break; default: 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); From 0a235e64ed127d0ab0c99da043357dc23e711ce4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 4 Jul 2020 08:46:17 +0200 Subject: [PATCH 02/20] Fix chat message recieving during arena change Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index c762a984..c94061f6 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -146,7 +146,7 @@ public class ChatListener extends BasicListener { } for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); - if(targetServer == null || targetServer.getType() != Servertype.ARENA){ + if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != sender.getServer().getInfo()){ BungeeCore.send(target, ChatMessageType.CHAT, msg); } } From 61c2a7f3a621086dc1a0202526653dbd6f3ed11a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 4 Jul 2020 18:10:30 +0200 Subject: [PATCH 03/20] Hotfix arena chat Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index c94061f6..bfcf1f06 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -146,7 +146,7 @@ public class ChatListener extends BasicListener { } for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); - if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != sender.getServer().getInfo()){ + if(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo()){ BungeeCore.send(target, ChatMessageType.CHAT, msg); } } From 45795512422430f78188ff10b78efe02aaca49de Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 5 Jul 2020 13:31:52 +0200 Subject: [PATCH 04/20] Change to bigger & better Tablist Signed-off-by: Lixfel --- .../bungeecore/listeners/TablistManager.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index e7fc6cae..7765ded2 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -74,8 +74,8 @@ public class TablistManager extends BasicListener { size = (size+19)/20; - if(size > 4) - size = 4; + if(size > 5) + size = 5; } private synchronized void updateCustomTablist(){ @@ -163,9 +163,9 @@ public class TablistManager extends BasicListener { i++; for (ProxiedPlayer p : playerMap.get(server)){ 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 - 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++; } } @@ -179,5 +179,22 @@ public class TablistManager extends BasicListener { //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(); + } } } From 4b48476d2f5645785857eefe2abd5ab9c3c7f088 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 11 Jul 2020 07:39:54 +0200 Subject: [PATCH 05/20] Extend help with new commands Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/HelpCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java index 493d7394..4f5edb54 100644 --- a/src/de/steamwar/bungeecore/commands/HelpCommand.java +++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java @@ -69,11 +69,13 @@ public class HelpCommand extends BasicCommand { sender.sendMessage("§8/§ereset §8- §7Setzt die derzeitige Region zurück"); sender.sendMessage("§8/§espeed §8- §7Ändert deine Fluggeschwindigkeit"); 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/§eloader §8- §7Nutze den automatischen Kanonenlader"); sender.sendMessage("§8/§eprotect §8- §7Schützt den Boden der (M)WG-Region"); sender.sendMessage("§8/§efreeze §8- §7Unterbindet Blockupdates"); 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/§ehelp bauserver §8- §7Hilfe zum Bauserver"); } From 7cd45601f709730ccb656782a04b5a5416225b67 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 16 Jul 2020 17:37:16 +0200 Subject: [PATCH 06/20] First ranked stub Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 11 +- src/de/steamwar/bungeecore/BungeeCore.java | 2 + .../bungeecore/commands/ChallengeCommand.java | 2 +- .../bungeecore/commands/FightCommand.java | 4 +- .../bungeecore/commands/HistoricCommand.java | 2 +- .../bungeecore/commands/RankCommand.java | 14 ++ .../bungeecore/commands/RankedCommand.java | 125 ++++++++++++++++++ src/de/steamwar/bungeecore/sql/Elo.java | 32 +++++ 8 files changed, 186 insertions(+), 6 deletions(-) create mode 100644 src/de/steamwar/bungeecore/commands/RankCommand.java create mode 100644 src/de/steamwar/bungeecore/commands/RankedCommand.java create mode 100644 src/de/steamwar/bungeecore/sql/Elo.java diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 6c27feb4..5c1889eb 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -26,10 +26,11 @@ public class ArenaMode { return byInternal.get(name); } - public static List getAllChatNames() { + public static List getAllChatNames(boolean historic) { List chatNames = new LinkedList<>(); for(ArenaMode mode : byInternal.values()){ - chatNames.addAll(mode.chatNames); + if(historic == mode.historic) + chatNames.addAll(mode.chatNames); } return chatNames; } @@ -48,6 +49,7 @@ public class ArenaMode { private final String serverJar; private final List maps; private final boolean historic; + private final boolean ranked; private ArenaMode(String internalName, Configuration config){ this.internalName = internalName; @@ -56,6 +58,7 @@ public class ArenaMode { this.chatNames = config.getStringList("chatNames"); this.maps = config.getStringList("maps"); this.historic = config.getBoolean("historic"); + this.ranked = config.getBoolean("ranked"); allModes.add(this); byInternal.put(internalName, this); @@ -106,4 +109,8 @@ public class ArenaMode { public boolean isHistoric(){ return historic; } + + public boolean isRanked() { + return ranked; + } } diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 85d43d7d..d334823c 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -95,6 +95,8 @@ public class BungeeCore extends Plugin { new RegelnCommand(); new HistoricCommand(); new CheckCommand(); + new RankedCommand(); + new RankCommand(); new EventStarter(); new Broadcaster(); diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index 8cfa08df..68ec0228 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -72,7 +72,7 @@ public class ChallengeCommand extends BasicCommand { @Override public Iterable onTabComplete(CommandSender commandSender, String[] args) { if(args.length == 2) - return ArenaMode.getAllChatNames(); + return ArenaMode.getAllChatNames(false); return new ArrayList<>(); } } diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 3a5a9795..5355b3ca 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -26,7 +26,7 @@ public class FightCommand extends BasicCommand { super("fight", "", "f"); } - private static ArenaMode getMode(CommandSender sender, String arg){ + static ArenaMode getMode(CommandSender sender, String arg){ ArenaMode mode = ArenaMode.getByChat(arg); if(mode != null) return mode; @@ -152,7 +152,7 @@ public class FightCommand extends BasicCommand { @Override public Iterable onTabComplete(CommandSender commandSender, String[] args) { if(args.length == 1){ - return ArenaMode.getAllChatNames(); + return ArenaMode.getAllChatNames(false); }else if(args.length == 2){ ArenaMode mode = ArenaMode.getByChat(args[1]); if(mode == null) diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java index b83cbe42..034de52a 100644 --- a/src/de/steamwar/bungeecore/commands/HistoricCommand.java +++ b/src/de/steamwar/bungeecore/commands/HistoricCommand.java @@ -33,7 +33,7 @@ public class HistoricCommand extends BasicCommand { @Override public Iterable onTabComplete(CommandSender commandSender, String[] args) { if(args.length == 1){ - return ArenaMode.getAllChatNames(); + return ArenaMode.getAllChatNames(true); }else if(args.length == 2){ ArenaMode mode = ArenaMode.getByChat(args[1]); if(mode == null) diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java new file mode 100644 index 00000000..4658e6eb --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -0,0 +1,14 @@ +package de.steamwar.bungeecore.commands; + +import net.md_5.bungee.api.CommandSender; + +public class RankCommand extends BasicCommand { + public RankCommand() { + super("rank", null); + } + + @Override + public void execute(CommandSender sender, String[] args) { + + } +} diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java new file mode 100644 index 00000000..f8f9aa0d --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -0,0 +1,125 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.ArenaMode; +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Servertype; +import de.steamwar.bungeecore.Subserver; +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.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class RankedCommand extends BasicCommand { + + private static Map 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, TimeUnit.SECONDS); + } + + @Override + public void execute(CommandSender sender, String[] args) { + if(args.length < 1){ + BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§7ranked §8[§eSpielmodus§8]"); + 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) + } + + private void checkForGames(){ + for(WaitingQueue queue : queues.values()){ + queue.checkForGames(); + } + } + + private static class WaitingQueue{ + + Set players = new HashSet<>(); + private final ArenaMode mode; + + private WaitingQueue(ArenaMode mode) { + this.mode = mode; + } + + private void addPlayer(ProxiedPlayer player){ + players.add(new WaitingPlayer(player, mode)); + } + + private void checkForGames(){ + players.removeIf(wp -> !wp.doesStillWait()); + for(WaitingPlayer wp1 : players){ + for(WaitingPlayer wp2 : players){ + if(wp1 == wp2) + continue; + + if(wp1.inRange(wp2)){ + //TODO: Open game opportunity + } + } + wp1.increment(); + } + } + } + + 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; + + //TODO: Check if has open match + + Subserver subserver = Subserver.getSubserver(player); + if(subserver == null) + return true; + if(subserver.getType() == Servertype.ARENA){ + BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cRanglistenspiel-Warteschlange abgebrochen"); + return false; + } + + return true; + } + } + + private static class OpenMatch{ + //TODO: Open matches + } +} diff --git a/src/de/steamwar/bungeecore/sql/Elo.java b/src/de/steamwar/bungeecore/sql/Elo.java new file mode 100644 index 00000000..8c693e56 --- /dev/null +++ b/src/de/steamwar/bungeecore/sql/Elo.java @@ -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()) + throw new SecurityException("Could not get place"); + + return rs.getInt("Place"); + }catch(SQLException e){ + throw new SecurityException("Could not get place", e); + } + } +} From e1c021a562d101ced76f89462cb01acd5502458d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 16 Jul 2020 18:04:16 +0200 Subject: [PATCH 07/20] Stopping usage of fabric mod launcher Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 2 ++ .../bungeecore/listeners/mods/Fabric.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/de/steamwar/bungeecore/listeners/mods/Fabric.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 85d43d7d..fcd6c40d 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -2,6 +2,7 @@ package de.steamwar.bungeecore; import de.steamwar.bungeecore.commands.*; 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.LabyMod; import de.steamwar.bungeecore.sql.SQL; @@ -56,6 +57,7 @@ public class BungeeCore extends Plugin { new ConnectionListener(); new Forge(); new LabyMod(); + new Fabric(); new ChatListener(); new BanListener(); new CheckListener(); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java new file mode 100644 index 00000000..a0e72beb --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -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.")); + } + } +} From 361e91997dc614f8dbcf646d0d64c29daa7bf982 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:25:12 +0200 Subject: [PATCH 08/20] First full ranked system implementation Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 19 ++- .../steamwar/bungeecore/SubserverSystem.java | 11 +- .../bungeecore/commands/RankCommand.java | 31 +++++ .../bungeecore/commands/RankedCommand.java | 109 ++++++++++++++---- 4 files changed, 145 insertions(+), 25 deletions(-) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 5c1889eb..3c895c91 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -35,6 +35,15 @@ public class ArenaMode { return chatNames; } + public static List getAllRankedChatNames(){ + List chatNames = new LinkedList<>(); + for(ArenaMode mode : byInternal.values()){ + if(mode.isRanked()) + chatNames.addAll(mode.chatNames); + } + return chatNames; + } + public static ArenaMode getByCheckSchemType(String checkSchemType){ return byCheckSchemType.get(checkSchemType); } @@ -50,6 +59,7 @@ public class ArenaMode { private final List maps; private final boolean historic; private final boolean ranked; + private final String schemType; private ArenaMode(String internalName, Configuration config){ this.internalName = internalName; @@ -57,8 +67,9 @@ public class ArenaMode { this.serverJar = config.getString("serverJar"); this.chatNames = config.getStringList("chatNames"); this.maps = config.getStringList("maps"); - this.historic = config.getBoolean("historic"); - this.ranked = config.getBoolean("ranked"); + this.historic = config.getBoolean("historic", false); + this.ranked = config.getBoolean("ranked", false); + this.schemType = config.getString("schemType", null); allModes.add(this); byInternal.put(internalName, this); @@ -113,4 +124,8 @@ public class ArenaMode { public boolean isRanked() { return ranked; } + + public String getSchemType() { + return schemType; + } } diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 6787ae2c..b4914172 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -62,10 +62,13 @@ public class SubserverSystem { * For event, test and normal arenas: The UUID of the designated leader for the red team * or null (no designated leader). * + * @param ranked + * If the game is a ranked game. + * * @return * 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 int port = freePort(2500); @@ -98,6 +101,8 @@ public class SubserverSystem { cmd.add("-DredLeader=" + player2.toString()); if(checkSchemID != 0) cmd.add("-DcheckSchemID=" + checkSchemID); + if(ranked) + cmd.add("-Dranked=true"); cmd.add("-Xmx2G"); cmd.addAll(JVM_ARGS); 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){ return startArena(modus, map, 0, 0, null, null, null, null); } diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java index 4658e6eb..c68cc98f 100644 --- a/src/de/steamwar/bungeecore/commands/RankCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -1,6 +1,14 @@ 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() { @@ -9,6 +17,29 @@ public class RankCommand extends BasicCommand { @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(user.getId(), mode.getSchemType()); + + BungeeCore.send(player, "§e" + placement + "§8. §7mit §e" + elo + " §7Elo§8."); + } + } + + @Override + public Iterable onTabComplete(CommandSender commandSender, String[] args) { + if(args.length > 1) + return new ArrayList<>(); + + List result = ArenaMode.getAllRankedChatNames(); + result.removeIf(name -> !name.startsWith(args[0])); + return result; } } diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index f8f9aa0d..6ef39997 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -1,13 +1,15 @@ package de.steamwar.bungeecore.commands; -import de.steamwar.bungeecore.ArenaMode; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Servertype; -import de.steamwar.bungeecore.Subserver; +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.*; @@ -15,7 +17,7 @@ import java.util.concurrent.TimeUnit; public class RankedCommand extends BasicCommand { - private static Map queues = new HashMap(); + private static Map queues = new HashMap<>(); public RankedCommand() { super("ranked", null); @@ -29,7 +31,7 @@ public class RankedCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { if(args.length < 1){ - BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§7ranked §8[§eSpielmodus§8]"); + getModes(sender, "/ranked"); return; }else if(!(sender instanceof ProxiedPlayer)) return; @@ -43,13 +45,42 @@ public class RankedCommand extends BasicCommand { } ProxiedPlayer player = (ProxiedPlayer) sender; - queues.get(mode) + queues.get(mode).togglePlayer(player); + } + + @Override + public Iterable onTabComplete(CommandSender commandSender, String[] args) { + if(args.length > 1) + return new ArrayList<>(); + + List 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()){ + for(WaitingQueue queue : queues.values()) queue.checkForGames(); - } } private static class WaitingQueue{ @@ -61,23 +92,63 @@ public class RankedCommand extends BasicCommand { this.mode = mode; } - private void addPlayer(ProxiedPlayer player){ - players.add(new WaitingPlayer(player, 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 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 inRange = new HashMap<>(); + + //Find games for(WaitingPlayer wp1 : players){ + if(inRange.containsValue(wp1)) + continue; + for(WaitingPlayer wp2 : players){ - if(wp1 == wp2) + if(wp1 == wp2 || inRange.containsKey(wp2) || inRange.containsValue(wp2)) continue; - if(wp1.inRange(wp2)){ - //TODO: Open game opportunity - } + if(wp1.inRange(wp2)) + inRange.putIfAbsent(wp1, wp2); } wp1.increment(); } + + for(Map.Entry 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(); + SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, serverName, serverName.replace(' ', '_'), wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); + } } } @@ -105,21 +176,15 @@ public class RankedCommand extends BasicCommand { if(!player.isConnected()) return false; - //TODO: Check if has open match - Subserver subserver = Subserver.getSubserver(player); if(subserver == null) return true; if(subserver.getType() == Servertype.ARENA){ - BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cRanglistenspiel-Warteschlange abgebrochen"); + BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cRanglistenspiel-Warteschlange verlassen"); return false; } return true; } } - - private static class OpenMatch{ - //TODO: Open matches - } } From 758e10baff1743e82ca54f54c612e663297825c8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:30:29 +0200 Subject: [PATCH 09/20] Fix unplaced Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/RankCommand.java | 5 ++++- src/de/steamwar/bungeecore/sql/Elo.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java index c68cc98f..f745fdee 100644 --- a/src/de/steamwar/bungeecore/commands/RankCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -29,7 +29,10 @@ public class RankCommand extends BasicCommand { int elo = Elo.getElo(user.getId(), mode.getSchemType()); int placement = Elo.getPlacement(user.getId(), mode.getSchemType()); - BungeeCore.send(player, "§e" + placement + "§8. §7mit §e" + elo + " §7Elo§8."); + 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."); } } diff --git a/src/de/steamwar/bungeecore/sql/Elo.java b/src/de/steamwar/bungeecore/sql/Elo.java index 8c693e56..450b07ad 100644 --- a/src/de/steamwar/bungeecore/sql/Elo.java +++ b/src/de/steamwar/bungeecore/sql/Elo.java @@ -22,7 +22,7 @@ public class Elo { ResultSet rs = SQL.select("SELECT COUNT(*) AS Place FROM Elo WHERE GameMode = ? AND Elo > ?", gameMode, elo); try{ if(!rs.next()) - throw new SecurityException("Could not get place"); + return -1; return rs.getInt("Place"); }catch(SQLException e){ From 7149602650cfd767e86f586fda2266d4d0438f33 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:31:10 +0200 Subject: [PATCH 10/20] Fix unplaced Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/RankCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java index f745fdee..7f4f26ef 100644 --- a/src/de/steamwar/bungeecore/commands/RankCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -27,7 +27,7 @@ public class RankCommand extends BasicCommand { if(!mode.isRanked()) continue; int elo = Elo.getElo(user.getId(), mode.getSchemType()); - int placement = Elo.getPlacement(user.getId(), mode.getSchemType()); + int placement = Elo.getPlacement(elo, mode.getSchemType()); if(placement == -1) BungeeCore.send(player, "§7" + mode.getChatName() + "§8: §eunplatziert"); From 0dc345e2c9bb1788b116d490546e71740037ca4d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:38:55 +0200 Subject: [PATCH 11/20] Fix nostart Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/RankCommand.java | 2 +- src/de/steamwar/bungeecore/commands/RankedCommand.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java index 7f4f26ef..4b44c624 100644 --- a/src/de/steamwar/bungeecore/commands/RankCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -32,7 +32,7 @@ public class RankCommand extends BasicCommand { 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."); + BungeeCore.send(player, "§7" + mode.getChatName() + "§8: §e" + ++placement + "§8. §7mit §e" + elo + " §7Elo§8."); } } diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index 6ef39997..2034ce28 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -25,7 +25,7 @@ public class RankedCommand extends BasicCommand { if(mode.isRanked()) queues.put(mode, new WaitingQueue(mode)); - ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::checkForGames, 1, TimeUnit.SECONDS); + ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::checkForGames, 1, 1, TimeUnit.SECONDS); } @Override From 74dbd92d7a9566e979adbd69d787df747fc6a750 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:44:59 +0200 Subject: [PATCH 12/20] Fix joining Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/RankedCommand.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index 2034ce28..d64aeaf1 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -147,7 +147,13 @@ public class RankedCommand extends BasicCommand { removeFromAll(wp2.player); String serverName = wp1.player.getName() + " vs " + wp2.player.getName(); - SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, serverName, serverName.replace(' ', '_'), wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); + 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())); } } } From 492dcff64d4633bf1f4390256e898c10653ea6b4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jul 2020 11:23:49 +0200 Subject: [PATCH 13/20] Fix double announcements + chat messages refinement Signed-off-by: Lixfel --- .../bungeecore/commands/MsgCommand.java | 2 +- .../bungeecore/commands/RCommand.java | 2 +- .../bungeecore/listeners/ChatListener.java | 1 + .../listeners/ConnectionListener.java | 20 +++++++++++++------ .../steamwar/bungeecore/sql/SteamwarUser.java | 3 ++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/MsgCommand.java b/src/de/steamwar/bungeecore/commands/MsgCommand.java index 33dd1940..b5f3bc6d 100644 --- a/src/de/steamwar/bungeecore/commands/MsgCommand.java +++ b/src/de/steamwar/bungeecore/commands/MsgCommand.java @@ -46,7 +46,7 @@ public class MsgCommand extends BasicCommand { } 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++){ msgBuilder.append(args[i]).append(" "); } diff --git a/src/de/steamwar/bungeecore/commands/RCommand.java b/src/de/steamwar/bungeecore/commands/RCommand.java index 2ff68d27..5e6a2b08 100644 --- a/src/de/steamwar/bungeecore/commands/RCommand.java +++ b/src/de/steamwar/bungeecore/commands/RCommand.java @@ -41,7 +41,7 @@ public class RCommand extends BasicCommand { } 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){ msgBuilder.append(arg).append(" "); } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index bfcf1f06..6780e947 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -126,6 +126,7 @@ public class ChatListener extends BasicListener { String name = sender.getDisplayName(); String chatsuffix = "§7» "; + message = message.replace('§', '&'); if(sender.hasPermission("bungeecore.group.admin")){ chatsuffix = "§7» §e"; message = ChatColor.translateAlternateColorCodes('&', message); diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 3d6e1df1..c36e9722 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -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.event.EventHandler; -import java.util.Collection; -import java.util.Iterator; +import java.util.*; public class ConnectionListener extends BasicListener { @@ -29,6 +28,12 @@ public class ConnectionListener extends BasicListener { public static final String CHECK_PERMISSION = "bungeecore.check"; private static final String YOUTUBER_MODS = "bungeecore.youtubermods"; + private static final Set newPlayers = new HashSet<>(); + + public static void newPlayer(UUID player){ + newPlayers.add(player); + } + @EventHandler public void onPostLogin(PostLoginEvent event) { ProxiedPlayer player = event.getPlayer(); @@ -38,28 +43,28 @@ public class ConnectionListener extends BasicListener { case "Admin": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.admin", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§4Admin " + player.getName() + "§r"); break; case "Developer": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.developer", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§3Developer " + player.getName() + "§r"); break; case "Moderator": player.addGroups(ADMIN_GROUP, TEAM_GROUP); player.setPermission("bungeecore.group.moderator", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§bModerator " + player.getName() + "§r"); break; case "Supporter": player.addGroups(TEAM_GROUP); player.setPermission("bungeecore.group.supporter", true); - player.setPermission("bungeecore.check", true); + player.setPermission(CHECK_PERMISSION, true); player.setPermission(YOUTUBER_MODS, true); player.setDisplayName("§1Supporter " + player.getName() + "§r"); break; @@ -91,6 +96,9 @@ 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!"); } /** To redirect players to the lobby in case of server closure. */ diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index e37255ad..74cad265 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -2,6 +2,7 @@ package de.steamwar.bungeecore.sql; import de.steamwar.bungeecore.BungeeCore; 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.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; @@ -62,7 +63,7 @@ public class SteamwarUser { user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString())); if(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); } return user; From a8a86b24578c98bed0d5e98bcd80ae1ad497d6c5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jul 2020 11:25:25 +0200 Subject: [PATCH 14/20] Fix build failure Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ConnectionListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index c36e9722..aa08609f 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -85,6 +85,7 @@ public class ConnectionListener extends BasicListener { break; } + for(Subserver subserver : Subserver.getServerList()){ if(subserver.getType() == Servertype.ARENA){ Iterator it = subserver.getServer().getPlayers().iterator(); From ef3c04a442ab8b58ef8ba7442cd228b5ca897bb5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 25 Jul 2020 11:39:55 +0200 Subject: [PATCH 15/20] Insert bedrock information Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 74cad265..1b62befd 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -8,6 +8,8 @@ import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; @@ -32,6 +34,16 @@ public class SteamwarUser { private static final Map usersByUUID = new HashMap<>(); private static final Map usersById = new HashMap<>(); 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 { id = rs.getInt("id"); @@ -66,6 +78,8 @@ public class SteamwarUser { 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; } From 54ed8924a631fab786978fddbe1c34c2196e46b8 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 26 Jul 2020 12:48:47 +0200 Subject: [PATCH 16/20] Add "YOYONOW" --- .../bungeecore/listeners/ChatListener.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 6780e947..edb7a4cd 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; 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 YOYONOW = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lYOYONOW")); @EventHandler public void onChatEvent(ChatEvent e){ @@ -75,7 +76,7 @@ public class ChatListener extends BasicListener { } } - private void lixfelAlert(ProxiedPlayer sender){ + private void lixfelAlert(ProxiedPlayer sender) { LIXFEL.send(sender); final String l = "§8Lixfel»" + sender.getName() + " §c"; BungeeCore.send(sender, ChatMessageType.ACTION_BAR, "§4§lTechnische Probleme?"); @@ -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); } + private void yoyonowAlert(ProxiedPlayer sender) { + YOYONOW.send(sender); + final String l = "§8YoyoNow»" + sender.getName() + " §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 \" 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){ if(e.getSender() instanceof ProxiedPlayer){ ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); - if(e.getMessage().contains("LIXFEL")) + if (e.getMessage().contains("LIXFEL")) lixfelAlert(sender); + if (e.getMessage().contains("YOYONOW")) + yoyonowAlert(sender); if(sender.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){ BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUm Chatnachrichten versenden zu können, musst du auch welche empfangen!"); From 82717dd9d49d1c5296fc1038e2baf50c45ce9180 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 28 Jul 2020 20:24:41 +0200 Subject: [PATCH 17/20] Hotfix repeated announcements Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ConnectionListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index aa08609f..d8db35a4 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -98,8 +98,10 @@ public class ConnectionListener extends BasicListener { } } - if(newPlayers.contains(player.getUniqueId())) + 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. */ From c5194ad5928b7f830ef1ad895eb043e58b15812f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 15 Aug 2020 17:42:27 +0200 Subject: [PATCH 18/20] Hotfix ranked pressing Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/RankedCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index d64aeaf1..7d77d556 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -31,7 +31,7 @@ public class RankedCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { if(args.length < 1){ - getModes(sender, "/ranked"); + getModes(sender, "/ranked "); return; }else if(!(sender instanceof ProxiedPlayer)) return; From 52286c0d88085aa2c7ec92b2573e5db7338b023a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 15 Aug 2020 18:18:22 +0200 Subject: [PATCH 19/20] Hotfix challenging yourself Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/ChallengeCommand.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index 68ec0228..96f71d11 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -27,6 +27,9 @@ public class ChallengeCommand extends BasicCommand { if(target == null){ BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer gewünschte Spieler ist nicht online."); return; + }else if(target == sender){ + BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cSchizophren?"); + return; } Subserver subserver = Subserver.getSubserver(target); From a63fdac5306b62bbf203be8e9cdcc8ba92a16ab6 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 16 Aug 2020 15:48:54 +0200 Subject: [PATCH 20/20] Fix Messages --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index edb7a4cd..a21dbce9 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -78,7 +78,7 @@ public class ChatListener extends BasicListener { private void lixfelAlert(ProxiedPlayer 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?"); TaskScheduler scheduler = ProxyServer.getInstance().getScheduler(); scheduler.schedule(BungeeCore.get(), () -> BungeeCore.send(sender, l + "Du hast mich gerufen!"), 3, TimeUnit.SECONDS); @@ -90,7 +90,7 @@ public class ChatListener extends BasicListener { private void yoyonowAlert(ProxiedPlayer sender) { YOYONOW.send(sender); - final String l = "§8YoyoNow»" + sender.getName() + " §c"; + 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);