From d11b4ba9ca56b7edc71c8238980aefd3a1cbd58a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 10:47:17 +0200 Subject: [PATCH 01/10] Fix TablistManager add Team visibility --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 6a1d965..d5da6f2 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -27,6 +27,7 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.UserGroup; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; @@ -200,9 +201,10 @@ public class TablistManager extends BasicListener { i++; } spacer = true; + Team team = getTeam(player); List players = playerMap.get(server) .stream() - .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member) + .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member || team == getTeam(p)) .collect(Collectors.toList()); if (server.equals("Bau")) { Subserver subserver = Subserver.getSubserver(player); @@ -238,6 +240,10 @@ public class TablistManager extends BasicListener { } } + private Team getTeam(ProxiedPlayer p) { + return Team.get(SteamwarUser.get(p).getTeam()); + } + private String getTablistName(ProxiedPlayer p, boolean sameServer) { Subserver server = Subserver.getSubserver(p); if(server != null){ From 80ec27b0c46b4055c04ac7525e013033e571f64e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 11:49:59 +0200 Subject: [PATCH 02/10] Fix TablistManager add Team visibility --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index d5da6f2..5daf583 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -241,7 +241,8 @@ public class TablistManager extends BasicListener { } private Team getTeam(ProxiedPlayer p) { - return Team.get(SteamwarUser.get(p).getTeam()); + Team team = Team.get(SteamwarUser.get(p).getTeam()); + return team.getTeamId() <= 0 ? null : team; } private String getTablistName(ProxiedPlayer p, boolean sameServer) { From f2ba19da712cfefa874721f63f2bc1b7a9f4ac09 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 12:33:07 +0200 Subject: [PATCH 03/10] Fix TablistManager add Team visibility --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 5daf583..fbfb330 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -204,7 +204,7 @@ public class TablistManager extends BasicListener { Team team = getTeam(player); List players = playerMap.get(server) .stream() - .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member || team == getTeam(p)) + .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member || (team != null && team == getTeam(p))) .collect(Collectors.toList()); if (server.equals("Bau")) { Subserver subserver = Subserver.getSubserver(player); From edbaddbee6d7e768a3924d36301fffb81cccd8b5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 15:31:29 +0200 Subject: [PATCH 04/10] Update TablistManager --- .../bungeecore/listeners/TablistManager.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index fbfb330..de2c98f 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -176,7 +176,7 @@ public class TablistManager extends BasicListener { i++; for (ProxiedPlayer p : playerMap.get(server)){ boolean sameServer = currentServer == p.getServer().getInfo(); - setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p, sameServer), (sameServer ? 1 : 500)); + setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500)); i++; } } @@ -225,7 +225,7 @@ public class TablistManager extends BasicListener { i++; for (ProxiedPlayer p : players){ boolean sameServer = currentServer == p.getServer().getInfo(); - setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p, sameServer), (sameServer ? 1 : 500)); + setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500)); i++; } } @@ -245,7 +245,7 @@ public class TablistManager extends BasicListener { return team.getTeamId() <= 0 ? null : team; } - private String getTablistName(ProxiedPlayer p, boolean sameServer) { + private String getTablistName(ProxiedPlayer p) { Subserver server = Subserver.getSubserver(p); if(server != null){ String tablistName = server.getTablistNames().get(p); @@ -256,13 +256,14 @@ public class TablistManager extends BasicListener { StringBuilder st = new StringBuilder(); UserGroup group = SteamwarUser.get(p).getUserGroup(); - //else st.append("§7"); - if(group == UserGroup.Member && sameServer) - st.append("§f"); - else + if (group == UserGroup.Member) { + Team team = getTeam(player); + if (team != null && team == getTeam(p)) st.append("§f"); + else st.append("§7"); + } else { st.append(group.getColorCode()); + } - // if (!sameServer) st.append("§o"); return st.append(p.getName()).toString(); } } From 71c206e59cad16474e0fdfbe1511742ce7fdcdf9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 15:41:26 +0200 Subject: [PATCH 05/10] Update TablistManager --- .../bungeecore/listeners/TablistManager.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index de2c98f..fc5ce7c 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -174,17 +174,10 @@ public class TablistManager extends BasicListener { server = Message.parse("TABLIST_BAU", player); setSlot(i%20, i/20, gray, "§7§l" + server, 1000); i++; - for (ProxiedPlayer p : playerMap.get(server)){ - boolean sameServer = currentServer == p.getServer().getInfo(); - setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500)); - i++; - } + i = update(currentServer, playerMap.get(server), i); } - while (i < size*20){ - setSlot(i%20, i/20, darkGray, "", 1000); - i++; - } + finish(i); }catch(IndexOutOfBoundsException | NullPointerException e){ //Ignore IndexOutOfBoundsException //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting @@ -223,23 +216,32 @@ public class TablistManager extends BasicListener { setSlot(i%20, i/20, gray, "§7§l" + server, 1000); i++; - for (ProxiedPlayer p : players){ - boolean sameServer = currentServer == p.getServer().getInfo(); - setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500)); - i++; - } + i = update(currentServer, players, i); } - while (i < size*20){ - setSlot(i%20, i/20, darkGray, "", 1000); - i++; - } + finish(i); }catch(IndexOutOfBoundsException | NullPointerException e){ //Ignore IndexOutOfBoundsException //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting } } + private int update(ServerInfo currentServer, List players, int i) { + for (ProxiedPlayer p : players){ + boolean sameServer = currentServer == p.getServer().getInfo(); + setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500)); + i++; + } + return i; + } + + private void finish(int i) { + while (i < size*20){ + setSlot(i%20, i/20, darkGray, "", 1000); + i++; + } + } + private Team getTeam(ProxiedPlayer p) { Team team = Team.get(SteamwarUser.get(p).getTeam()); return team.getTeamId() <= 0 ? null : team; From 4a94f453f6da1a832f6bebfa98af26b9c27d4bd9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 15:48:11 +0200 Subject: [PATCH 06/10] Add ListCommand for user --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/ListCommand.java | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/de/steamwar/bungeecore/commands/ListCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 2344d56..8b78cb6 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -121,6 +121,7 @@ public class BungeeCore extends Plugin { new UnIgnoreCommand(); new PollresultCommand(); new ResourcereloadCommand(); + new ListCommand(); if(!EVENT_MODE){ new WebregisterCommand(); diff --git a/src/de/steamwar/bungeecore/commands/ListCommand.java b/src/de/steamwar/bungeecore/commands/ListCommand.java new file mode 100644 index 0000000..6ab37f0 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/ListCommand.java @@ -0,0 +1,71 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.Servertype; +import de.steamwar.bungeecore.Subserver; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.connection.Server; + +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; +import java.util.stream.Collectors; + +public class ListCommand extends BasicCommand { + + public ListCommand() { + super("list", ""); + } + + private final TreeMap> playerMap = new TreeMap<>(); + + private synchronized void updateCustomTablist(){ + //Calculate server-player-map + playerMap.clear(); + for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { + Server pserver = player.getServer(); + if (pserver == null) //Happens temporarily + continue; + + ServerInfo server = pserver.getInfo(); + String serverName = server.getName(); + + Subserver subserver = Subserver.getSubserver(server); + if (subserver != null && subserver.getType() == Servertype.BAUSERVER) { + playerMap.computeIfAbsent("Bau", s -> new ArrayList<>()).add(player); + } else { + playerMap.computeIfAbsent(serverName, s -> new ArrayList<>()).add(player); + } + } + playerMap.forEach((server, players) -> players.sort((proxiedPlayer, t1) -> proxiedPlayer.getName().compareToIgnoreCase(t1.getName()))); + } + + @Override + public void execute(CommandSender commandSender, String[] strings) { + updateCustomTablist(); + for (String server : playerMap.navigableKeySet()) { + commandSender.sendMessage("§e" + server + "§8: §7" + playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", "))); + } + } +} From 1c9bd9fcfff0fe793527519ec88ded3f8de1a985 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 16:37:30 +0200 Subject: [PATCH 07/10] Fix TablistManager --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index fc5ce7c..c1e99d3 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -219,6 +219,7 @@ public class TablistManager extends BasicListener { i = update(currentServer, players, i); } + setSize(Math.max((i + 19) / 20, 5), 20); finish(i); }catch(IndexOutOfBoundsException | NullPointerException e){ //Ignore IndexOutOfBoundsException From 11f61f34cdfce718d47630a92c2ca0e84d088b40 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 16:41:43 +0200 Subject: [PATCH 08/10] Fix TablistManager --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index c1e99d3..7fade9c 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -219,7 +219,8 @@ public class TablistManager extends BasicListener { i = update(currentServer, players, i); } - setSize(Math.max((i + 19) / 20, 5), 20); + // Shrink Down + setSize(Math.min((i + 19) / 20, 4), 20); finish(i); }catch(IndexOutOfBoundsException | NullPointerException e){ //Ignore IndexOutOfBoundsException From 9e8a031230bda2ab597516891efd205e41e97d37 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 17:48:47 +0200 Subject: [PATCH 09/10] Make Fight Server with one Player more visible --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 7fade9c..fd386a9 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -199,13 +199,18 @@ public class TablistManager extends BasicListener { .stream() .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member || (team != null && team == getTeam(p))) .collect(Collectors.toList()); + + Subserver subserver = Subserver.getSubserver(player); if (server.equals("Bau")) { - Subserver subserver = Subserver.getSubserver(player); if (subserver != null && subserver.getType() == Servertype.BAUSERVER) { players = playerMap.get(server); } server = Message.parse("TABLIST_BAU", player); } + if (subserver != null && subserver.getType() == Servertype.ARENA && playerMap.get(server).size() == 1) { + players = playerMap.get(server); + } + int increment = playerMap.get(server).size() - players.size(); if (players.isEmpty()) { server += " §7(" + increment + ")"; From ad054d2b06b476c72d990c842a4d42af83b221e7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 10:23:44 +0200 Subject: [PATCH 10/10] Remove ListCommand --- src/de/steamwar/bungeecore/BungeeCore.java | 1 - .../bungeecore/commands/ListCommand.java | 71 ------------------- 2 files changed, 72 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/commands/ListCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 8b78cb6..2344d56 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -121,7 +121,6 @@ public class BungeeCore extends Plugin { new UnIgnoreCommand(); new PollresultCommand(); new ResourcereloadCommand(); - new ListCommand(); if(!EVENT_MODE){ new WebregisterCommand(); diff --git a/src/de/steamwar/bungeecore/commands/ListCommand.java b/src/de/steamwar/bungeecore/commands/ListCommand.java deleted file mode 100644 index 6ab37f0..0000000 --- a/src/de/steamwar/bungeecore/commands/ListCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bungeecore.commands; - -import de.steamwar.bungeecore.Servertype; -import de.steamwar.bungeecore.Subserver; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.config.ServerInfo; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.connection.Server; - -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; -import java.util.stream.Collectors; - -public class ListCommand extends BasicCommand { - - public ListCommand() { - super("list", ""); - } - - private final TreeMap> playerMap = new TreeMap<>(); - - private synchronized void updateCustomTablist(){ - //Calculate server-player-map - playerMap.clear(); - for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - Server pserver = player.getServer(); - if (pserver == null) //Happens temporarily - continue; - - ServerInfo server = pserver.getInfo(); - String serverName = server.getName(); - - Subserver subserver = Subserver.getSubserver(server); - if (subserver != null && subserver.getType() == Servertype.BAUSERVER) { - playerMap.computeIfAbsent("Bau", s -> new ArrayList<>()).add(player); - } else { - playerMap.computeIfAbsent(serverName, s -> new ArrayList<>()).add(player); - } - } - playerMap.forEach((server, players) -> players.sort((proxiedPlayer, t1) -> proxiedPlayer.getName().compareToIgnoreCase(t1.getName()))); - } - - @Override - public void execute(CommandSender commandSender, String[] strings) { - updateCustomTablist(); - for (String server : playerMap.navigableKeySet()) { - commandSender.sendMessage("§e" + server + "§8: §7" + playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", "))); - } - } -}