From d8fda4dd8e4dce4182a808647622410cf3f4e90d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 28 Oct 2022 10:33:29 +0200 Subject: [PATCH] Update some stuff --- .../commands/SlimTablistToggleCommand.java | 45 ------------------- .../steamwar/bungeecore/tablist/Tablist.java | 3 +- .../bungeecore/tablist/TablistBuild.java | 2 +- .../bungeecore/tablist/TablistGroup.java | 6 +-- .../bungeecore/tablist/TablistServer.java | 6 +-- 5 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/commands/SlimTablistToggleCommand.java diff --git a/src/de/steamwar/bungeecore/commands/SlimTablistToggleCommand.java b/src/de/steamwar/bungeecore/commands/SlimTablistToggleCommand.java deleted file mode 100644 index 2f451f0..0000000 --- a/src/de/steamwar/bungeecore/commands/SlimTablistToggleCommand.java +++ /dev/null @@ -1,45 +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.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.UserConfig; -import de.steamwar.command.SWCommand; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class SlimTablistToggleCommand extends SWCommand { - - public SlimTablistToggleCommand() { - super("toggleslimtablist", null, "toggleslim", "toggletablist", "toggleslimtab", "toggletab"); - } - - @Register(description = "SLIMTABLIST_USAGE") - public void toggle(ProxiedPlayer player) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - boolean alwaysSlim = Boolean.parseBoolean(UserConfig.getConfig(user.getId(), "slimTablist")); - UserConfig.updateUserConfig(user.getId(), "slimTablist", String.valueOf(!alwaysSlim)); - if (alwaysSlim) { - Message.send("SLIMTABLIST_DISABLED", player); - } else { - Message.send("SLIMTABLIST_ENABLED", player); - } - } -} diff --git a/src/de/steamwar/bungeecore/tablist/Tablist.java b/src/de/steamwar/bungeecore/tablist/Tablist.java index 1a2bc91..d949e73 100644 --- a/src/de/steamwar/bungeecore/tablist/Tablist.java +++ b/src/de/steamwar/bungeecore/tablist/Tablist.java @@ -77,8 +77,7 @@ public class Tablist extends MessageToMessageDecoder { List tablist = new ArrayList<>(); List direct = new ArrayList<>(); - boolean alwaysSlim = Boolean.parseBoolean(UserConfig.getConfig(viewer.user().getId(), "slimTablist")); - if (alwaysSlim || global.size(viewer, player) > 80) { + if (global.size(viewer, player) > 80) { global.slimPrint(viewer, player, tablist, direct); } else { global.print(viewer, player, tablist, direct); diff --git a/src/de/steamwar/bungeecore/tablist/TablistBuild.java b/src/de/steamwar/bungeecore/tablist/TablistBuild.java index c81ae40..63790b6 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistBuild.java +++ b/src/de/steamwar/bungeecore/tablist/TablistBuild.java @@ -86,7 +86,7 @@ public class TablistBuild implements TablistPart { if (toPrint.isEmpty()) return; int all = toPrint.size(); - toPrint = TablistServer.slimmify(viewer, toPrint); + toPrint = TablistServer.slimify(viewer, toPrint); if (tablist.isEmpty() || tablist.get(tablist.size() - 1).getDisplayName().equals("")) { tablist.add(new Item(null, "", TablistServer.GRAY)); diff --git a/src/de/steamwar/bungeecore/tablist/TablistGroup.java b/src/de/steamwar/bungeecore/tablist/TablistGroup.java index 4a654cc..24524dc 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistGroup.java +++ b/src/de/steamwar/bungeecore/tablist/TablistGroup.java @@ -38,11 +38,7 @@ public class TablistGroup implements TablistPart { @Override public int size(ChatSender viewer, ProxiedPlayer player) { - int size = 0; - for (TablistPart part : sublists) { - size += part.size(viewer, player); - } - return size; + return sublists.stream().mapToInt(sublist -> sublist.size(viewer, player)).sum(); } @Override diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java index 989dbd6..9a68d93 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistServer.java +++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java @@ -68,7 +68,7 @@ public class TablistServer implements TablistPart { @Override public int size(ChatSender viewer, ProxiedPlayer player) { - return (player.getServer().getInfo() == server ? 2 : 0) + players.size(); + return (player.getServer().getInfo() == server ? 0 : 2) + players.size(); } @Override @@ -91,7 +91,7 @@ public class TablistServer implements TablistPart { List toPrint = players; if (!onServer) { - toPrint = TablistServer.slimmify(viewer, players); + toPrint = TablistServer.slimify(viewer, players); if (tablist.isEmpty() || tablist.get(tablist.size() - 1).getDisplayName().equals("")) { items.add(new Item(null, "", GRAY)); @@ -128,7 +128,7 @@ public class TablistServer implements TablistPart { }); } - public static List slimmify(ChatSender viewer, List items) { + public static List slimify(ChatSender viewer, List items) { int team = viewer.user().getTeam(); return items.stream() .map(Item::getUuid)