From 7cd45601f709730ccb656782a04b5a5416225b67 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 16 Jul 2020 17:37:16 +0200 Subject: [PATCH 1/6] 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 6c27feb..5c1889e 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 85d43d7..d334823 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 8cfa08d..68ec022 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 3a5a979..5355b3c 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 b83cbe4..034de52 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 0000000..4658e6e --- /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 0000000..f8f9aa0 --- /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 0000000..8c693e5 --- /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 361e91997dc614f8dbcf646d0d64c29daa7bf982 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jul 2020 15:25:12 +0200 Subject: [PATCH 2/6] 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 5c1889e..3c895c9 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 6787ae2..b491417 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 4658e6e..c68cc98 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 f8f9aa0..6ef3999 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 3/6] 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 c68cc98..f745fde 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 8c693e5..450b07a 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 4/6] 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 f745fde..7f4f26e 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 5/6] 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 7f4f26e..4b44c62 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 6ef3999..2034ce2 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 6/6] 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 2034ce2..d64aeaf 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())); } } }