From 0234e0d2e0f7f9132494552e18102a1638ebcc0b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 3 Jan 2021 15:18:00 +0100 Subject: [PATCH 01/81] Add Hover to Check Reminder and Reminder on Connection --- src/de/steamwar/bungeecore/commands/CheckCommand.java | 10 +++++++++- .../bungeecore/listeners/ConnectionListener.java | 5 ++++- src/de/steamwar/messages/BungeeCore.properties | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 9aaed51..7ee3024 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -68,9 +68,17 @@ public class CheckCommand extends BasicCommand { ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { List schematics = getSchemsToCheck(); if(schematics.size() != currentCheckers.size()) - Message.team("CHECK_REMINDER", schematics.size() - currentCheckers.size()); + for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ + if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) + BungeeCore.send(player, Message.parse("CHECK_REMINDER", player, schematics.size() - currentCheckers.size()), Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list")); + } }, 10, 10, TimeUnit.MINUTES); } + public static void sendReminder(ProxiedPlayer player) { + List schematics = getSchemsToCheck(); + if(schematics.size() != currentCheckers.size()) + BungeeCore.send(player, Message.parse("CHECK_REMINDER", player, schematics.size() - currentCheckers.size()), Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list")); + } @Override public void execute(CommandSender sender, String[] args) { diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 0deb468..b872730 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.commands.ChallengeCommand; +import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.commands.MsgCommand; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserGroup; @@ -65,8 +66,10 @@ public class ConnectionListener extends BasicListener { if(user.getUserGroup().isAdminGroup()) player.addGroups(ADMIN_GROUP); - if(user.getUserGroup().isTeamGroup()) + if(user.getUserGroup().isTeamGroup()) { player.addGroups(TEAM_GROUP); + CheckCommand.sendReminder(player); + } if(user.getUserGroup().isCheckSchematics()) player.setPermission(CHECK_PERMISSION, true); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 0b11312..aeca89b 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -122,6 +122,7 @@ BAU_DELETE_GUI_DELETE=§aLöschen #CheckCommand CHECK_REMINDER=§7Es sind §e{0} §7Schematics zu prüfen§8! +CHECK_REMINDER_HOVER=§eZuprüfende Schematics CHECK_NOT_CHECKING=§cDu prüfst derzeit nicht. CHECK_HELP_LIST=§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics CHECK_HELP_NEXT=§8/§echeck next §8- §7Nächste Prüffrage§8/§7freigeben From 3ea273767d5d6193ec2268803d1677da3deead8f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 4 Mar 2021 21:14:19 +0100 Subject: [PATCH 02/81] Add Static Server Fabric Check --- src/de/steamwar/bungeecore/BungeeCore.java | 3 +++ .../bungeecore/listeners/mods/ModLoaderBlocker.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 23b5e2e..6ca3220 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -263,6 +263,9 @@ public class BungeeCore extends Plugin { serverPermissions.get(serverName), cmds.toArray(new String[0]) ); + if(server.getBoolean("modchecked", false)) { + ModLoaderBlocker.addServer(serverName); + } } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index 11e8d87..281830c 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -29,9 +29,13 @@ import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.event.EventHandler; import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; public class ModLoaderBlocker extends BasicListener { + private static final Set BLOCKED_SERVER = new HashSet<>(); + @EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ Connection sender = e.getSender(); @@ -79,8 +83,9 @@ public class ModLoaderBlocker extends BasicListener { @EventHandler public void onServerSwitch(ServerSwitchEvent event) { - if(Subserver.getSubserver(event.getPlayer()) != null - && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA + if(((Subserver.getSubserver(event.getPlayer()) != null + && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA) + || BLOCKED_SERVER.contains(event.getPlayer().getServer().getInfo().getName())) && isFabric(event.getPlayer())) { event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER)); Message.send("MODLOADER_DENIED", event.getPlayer()); @@ -90,4 +95,8 @@ public class ModLoaderBlocker extends BasicListener { public static boolean isFabric(ProxiedPlayer player) { return Storage.fabricPlayers.contains(player); } + + public static void addServer(String server) { + BLOCKED_SERVER.add(server); + } } From a079b25c14813a39fa330dbd34762827f0b2681d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 19:08:09 +0200 Subject: [PATCH 03/81] Adjust config for new fight system Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 21 ++++++++++++++----- .../steamwar/bungeecore/SubserverSystem.java | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index c007a86..19652ab 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -73,22 +73,29 @@ public class ArenaMode { private final String internalName; private final String displayName; + private final String folder; private final List chatNames; private final String serverJar; 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; - this.displayName = config.getString("displayName"); + this.folder = config.getString("folder"); this.serverJar = config.getString("serverJar"); - this.chatNames = config.getStringList("chatNames"); this.maps = config.getStringList("maps"); + this.displayName = config.getString("displayName", internalName); + if(config.contains("chatNames")) + this.chatNames = config.getStringList("chatNames"); + else + this.chatNames = Collections.emptyList(); this.historic = config.getBoolean("historic", false); + this.schemType = config.getString("schemType", "").toLowerCase(); + this.ranked = config.getBoolean("ranked", false); - this.schemType = config.getString("schemType", null); allModes.add(this); byInternal.put(internalName, this); @@ -96,8 +103,8 @@ public class ArenaMode { byChat.put(name.toLowerCase(), this); } - if(config.contains("checkSchemType")) - byCheckSchemType.put(config.getString("checkSchemType").toLowerCase(), this); + if(!this.schemType.equals("")) + byCheckSchemType.put(this.schemType, this); } public String getInternalName() { @@ -120,6 +127,10 @@ public class ArenaMode { return null; } + public String getFolder() { + return folder; + } + public String getRandomMap(){ return maps.get(random.nextInt(maps.size())); } diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 50d5552..3613feb 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -108,7 +108,7 @@ public class SubserverSystem { //Copy world try { - new ProcessBuilder("cp", "-r", SERVER_PATH + modus.getInternalName() + "/" + map, worldDir + mapName).start().waitFor(); + new ProcessBuilder("cp", "-r", SERVER_PATH + modus.getFolder() + "/" + map, worldDir + mapName).start().waitFor(); } catch (IOException | InterruptedException e) { throw new SecurityException("Could not copy folder", e); } From 5424a739d9d02eec74d4e03d53c267d5e47d5a1d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 19:12:00 +0200 Subject: [PATCH 04/81] Adjust config for new fight system Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 8 ++------ src/de/steamwar/bungeecore/SubserverSystem.java | 4 ++-- src/de/steamwar/bungeecore/commands/FightCommand.java | 2 +- src/de/steamwar/bungeecore/commands/RankedCommand.java | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 19652ab..68a27a4 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -107,10 +107,6 @@ public class ArenaMode { byCheckSchemType.put(this.schemType, this); } - public String getInternalName() { - return internalName; - } - public String getDisplayName() { return displayName; } @@ -143,8 +139,8 @@ public class ArenaMode { return chatNames.get(0); } - public boolean hasChatName(){ - return !chatNames.isEmpty(); + public boolean withoutChatName(){ + return chatNames.isEmpty(); } public boolean isHistoric(){ diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 3613feb..5751f6e 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -108,7 +108,7 @@ public class SubserverSystem { //Copy world try { - new ProcessBuilder("cp", "-r", SERVER_PATH + modus.getFolder() + "/" + map, worldDir + mapName).start().waitFor(); + new ProcessBuilder("cp", "-r", SERVER_PATH + modus.getFolder() + "/arenas/" + map, worldDir + mapName).start().waitFor(); } catch (IOException | InterruptedException e) { throw new SecurityException("Could not copy folder", e); } @@ -128,7 +128,7 @@ public class SubserverSystem { //Start server ProcessBuilder process = new ProcessBuilder(cmd); - process.directory(new File(SERVER_PATH, modus.getInternalName())); + process.directory(new File(SERVER_PATH, modus.getFolder())); String finalMapName = mapName; if(eventFightID == -1) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 44e9cf1..93292de 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -69,7 +69,7 @@ public class FightCommand extends BasicCommand { TextComponent start = new TextComponent(); TextComponent current = start; for(ArenaMode mode : ArenaMode.getAllModes()){ - if(!mode.hasChatName() || mode.isHistoric() != historic) + if(mode.withoutChatName() || mode.isHistoric() != historic) continue; String command = precommand + mode.getChatName(); current.setBold(true); diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index c70fff9..5825b48 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -81,7 +81,7 @@ public class RankedCommand extends BasicCommand { TextComponent start = new TextComponent(); TextComponent current = start; for(ArenaMode mode : ArenaMode.getAllModes()){ - if(!mode.hasChatName() || !mode.isRanked()) + if(mode.withoutChatName() || !mode.isRanked()) continue; String command = precommand + mode.getChatName(); current.setBold(true); From 5ee46a2ca32a38205e7d1adfd74221b2013789a0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 19:13:35 +0200 Subject: [PATCH 05/81] Adjust config for new fight system Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 68a27a4..1e33cce 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -71,7 +71,6 @@ public class ArenaMode { return allModes; } - private final String internalName; private final String displayName; private final String folder; private final List chatNames; @@ -83,7 +82,6 @@ public class ArenaMode { private final String schemType; private ArenaMode(String internalName, Configuration config){ - this.internalName = internalName; this.folder = config.getString("folder"); this.serverJar = config.getString("serverJar"); this.maps = config.getStringList("maps"); From 4c2f4fdbcd121dc2b564272587b5046260c8a11e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 19:47:34 +0200 Subject: [PATCH 06/81] Implement prepare Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 17 ++++----- .../steamwar/bungeecore/SubserverSystem.java | 15 ++++---- .../bungeecore/commands/BauCommand.java | 36 ++++++++++--------- .../bungeecore/commands/ChallengeCommand.java | 2 +- .../bungeecore/commands/CheckCommand.java | 11 ++---- .../bungeecore/commands/FightCommand.java | 2 +- .../bungeecore/commands/HistoricCommand.java | 2 +- .../bungeecore/commands/RankedCommand.java | 2 +- .../bungeecore/comms/PacketIdManager.java | 1 + .../bungeecore/comms/SpigotReceiver.java | 2 ++ .../comms/handlers/PrepareSchemHandler.java | 23 ++++++++++++ 11 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 1e33cce..b675b8e 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -19,17 +19,18 @@ package de.steamwar.bungeecore; +import de.steamwar.bungeecore.sql.SchematicType; import net.md_5.bungee.config.Configuration; import java.util.*; public class ArenaMode { - private static Map byChat = new HashMap<>(); - private static Map byInternal = new HashMap<>(); - private static Map byCheckSchemType = new HashMap<>(); - private static List allModes = new LinkedList<>(); - private static Random random = new Random(); + private static final Map byChat = new HashMap<>(); + private static final Map byInternal = new HashMap<>(); + private static final Map bySchemType = new HashMap<>(); + private static final List allModes = new LinkedList<>(); + private static final Random random = new Random(); static void init(Configuration config){ for(String internalName : config.getKeys()){ @@ -63,8 +64,8 @@ public class ArenaMode { return chatNames; } - public static ArenaMode getByCheckSchemType(String checkSchemType){ - return byCheckSchemType.get(checkSchemType); + public static ArenaMode getBySchemType(SchematicType schemType){ + return bySchemType.get(schemType); } public static List getAllModes(){ @@ -102,7 +103,7 @@ public class ArenaMode { } if(!this.schemType.equals("")) - byCheckSchemType.put(this.schemType, this); + bySchemType.put(SchematicType.fromDB(this.schemType), this); } public String getDisplayName() { diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 5751f6e..4898548 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -87,7 +87,7 @@ public class SubserverSystem { * @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, boolean ranked){ + public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, int prepareSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){ //Generate missing parameters int port = freePort(firstArenaPort); @@ -123,6 +123,7 @@ public class SubserverSystem { "fightID=" + eventFightID, "ranked=" + ranked, "checkSchemID=" + checkSchemID, + "prepareSchemID=" + prepareSchemID, player1 != null && eventFightID != -1 ? "blueLeader=" + player1.toString() : null, player2 != null ? "redLeader=" + player2.toString() : null); @@ -152,24 +153,22 @@ 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 startEventArena(EventFight eventFight, String serverName){ return startArena( eventFight.getSpielmodus(), eventFight.getMap(), eventFight.getFightID(), 0, + 0, serverName, serverName.replace(' ', '_') + eventFight.getStartTime().toLocalDateTime().format(DateTimeFormatter.ISO_TIME), null, - null); + null, + false); } - public static void startTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId){ - startArena(m, map, -1, checkSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null).sendPlayer(p); + public static void startTestServer(ProxiedPlayer p, ArenaMode m, String map, int checkSchemId, int prepareSchemId){ + startArena(m, map, -1, checkSchemId, prepareSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null, false).sendPlayer(p); } public static void sendToBauServer(ProxiedPlayer p, UUID owner){ diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index a0d120f..355a82f 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -266,24 +266,28 @@ public class BauCommand { }); } + public static void stopBauserver(ProxiedPlayer p){ + for (Subserver subserver : Subserver.getServerList()) { + if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) { + if(subserver.getServer().getPlayers().isEmpty()){ + Message.send("BAU_START_ALREADY", p); + return; + } + subserver.stop(); + try { + Thread.sleep(200); // Wait until possible testarena-World has been deleted + } catch (InterruptedException e) { + throw new SecurityException("Subserver stop interrupted", e); + } + break; + } + } + } + private static void testarena(ProxiedPlayer p, String[] command){ FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { - for (Subserver subserver : Subserver.getServerList()) { - if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) { - if(subserver.getServer().getPlayers().isEmpty()){ - Message.send("BAU_START_ALREADY", p); - return; - } - subserver.stop(); - try { - Thread.sleep(200); // Wait until possible testarena-World has been deleted - } catch (InterruptedException e) { - throw new SecurityException("Subserver stop interrupted", e); - } - break; - } - } - SubserverSystem.startTestServer(p, mode, map, 0); + stopBauserver(p); + SubserverSystem.startTestServer(p, mode, map, 0, 0); })); } diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index 2c3d657..3d4150d 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -75,7 +75,7 @@ public class ChallengeCommand extends BasicCommand { challenges.remove(target); challenges.remove(player); - Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), target.getUniqueId()); + Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), target.getUniqueId(), false); arena.sendPlayer(player); arena.sendPlayer(target); diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 9aaed51..b121fe9 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -223,15 +223,10 @@ public class CheckCommand extends BasicCommand { this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator(); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { - for (Subserver subserver : Subserver.getServerList()) { - if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) { - subserver.stop(); - break; - } - } + BauCommand.stopBauserver(checker); - ArenaMode mode = ArenaMode.getByCheckSchemType(schematic.getSchemType().toDB()); - SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID()); + ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemType().fightType()); + SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID(), 0); currentCheckers.put(checker.getUniqueId(), this); currentSchems.put(schematic.getSchemID(), this); for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic.getSchemName(), schematic.getSchemOwner())) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 93292de..984bc06 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -164,7 +164,7 @@ public class FightCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> { - Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), null); + Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false); arena.sendPlayer(player); Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER" , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), mode.getDisplayName(), player.getName()); diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java index c7d64de..ebf9312 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 void execute(CommandSender sender, String[] args) { FightCommand.createArena(sender, "/historic ", args, 0, true, (player, mode, map) -> { - Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, null, null, player.getUniqueId(), null); + Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false); arena.sendPlayer(player); Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER" , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), mode.getDisplayName(), player.getName()); diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index 5825b48..1a978b5 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -165,7 +165,7 @@ public class RankedCommand extends BasicCommand { removeFromAll(wp1.player); removeFromAll(wp2.player); - Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, null, null, wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); + Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, 0, null, null, wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); arena.sendPlayer(wp1.player); arena.sendPlayer(wp2.player); diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java index ae86d70..8376d59 100644 --- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java +++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java @@ -24,6 +24,7 @@ public class PacketIdManager { //0x0(X) Standalone Packets public static final byte PING_PACKET = 0x01; public static final byte TABLIST_NAME = 0x02; + public static final byte PREPARE_SCHEM = 0x03; //0x1(X) Bungee Inventory public static final byte INVENTORY_PACKET = 0x10; diff --git a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java index b18b3a0..f87646f 100644 --- a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java +++ b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.comms; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import de.steamwar.bungeecore.comms.handlers.InventoryCallbackHandler; +import de.steamwar.bungeecore.comms.handlers.PrepareSchemHandler; import de.steamwar.bungeecore.comms.handlers.TablistNameHandler; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.event.PluginMessageEvent; @@ -55,5 +56,6 @@ public class SpigotReceiver extends BasicListener { static { registerHandler(PacketIdManager.INVENTORY_CALLBACK_PACKET, new InventoryCallbackHandler()); registerHandler(PacketIdManager.TABLIST_NAME, new TablistNameHandler()); + registerHandler(PacketIdManager.PREPARE_SCHEM, new PrepareSchemHandler()); } } diff --git a/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java b/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java new file mode 100644 index 0000000..40880a0 --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java @@ -0,0 +1,23 @@ +package de.steamwar.bungeecore.comms.handlers; + +import com.google.common.io.ByteArrayDataInput; +import de.steamwar.bungeecore.ArenaMode; +import de.steamwar.bungeecore.SubserverSystem; +import de.steamwar.bungeecore.commands.BauCommand; +import de.steamwar.bungeecore.comms.SpigotHandler; +import de.steamwar.bungeecore.sql.SchematicType; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class PrepareSchemHandler implements SpigotHandler { + @Override + public void handle(ByteArrayDataInput byteArrayDataInput) { + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUuid()); + int schematicID = byteArrayDataInput.readInt(); + ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(byteArrayDataInput.readUTF())); + + BauCommand.stopBauserver(player); + SubserverSystem.startTestServer(player, mode, mode.getRandomMap(), 0, schematicID); + } +} From 1824dda8575280925e314e208628bfc5049c5541 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 19:48:51 +0200 Subject: [PATCH 07/81] Fix license header Signed-off-by: Lixfel --- .../comms/handlers/PrepareSchemHandler.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java b/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java index 40880a0..46d1a03 100644 --- a/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java +++ b/src/de/steamwar/bungeecore/comms/handlers/PrepareSchemHandler.java @@ -1,3 +1,22 @@ +/* + 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.comms.handlers; import com.google.common.io.ByteArrayDataInput; From 0dcb831142f9068bd26654fc0335f174626dc264 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 30 Mar 2021 20:03:56 +0200 Subject: [PATCH 08/81] Fix missing config Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ArenaMode.java | 6 ++++++ src/de/steamwar/bungeecore/SubserverSystem.java | 1 + 2 files changed, 7 insertions(+) diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index b675b8e..4d5a868 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -76,6 +76,7 @@ public class ArenaMode { private final String folder; private final List chatNames; private final String serverJar; + private final String config; private final List maps; private final boolean historic; @@ -85,6 +86,7 @@ public class ArenaMode { private ArenaMode(String internalName, Configuration config){ this.folder = config.getString("folder"); this.serverJar = config.getString("serverJar"); + this.config = config.getString("config"); this.maps = config.getStringList("maps"); this.displayName = config.getString("displayName", internalName); if(config.contains("chatNames")) @@ -114,6 +116,10 @@ public class ArenaMode { return serverJar; } + public String getConfig(){ + return config; + } + public String hasMap(String map){ for(String m : maps){ if(m.equalsIgnoreCase(map)) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 4898548..8295642 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -120,6 +120,7 @@ public class SubserverSystem { port, "2G", "logPath=" + mapName, + "config="+modus.getConfig(), "fightID=" + eventFightID, "ranked=" + ranked, "checkSchemID=" + checkSchemID, From 29c5dc34075ae41317c8de745f0be1be17ce8814 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 3 Apr 2021 09:06:00 +0200 Subject: [PATCH 09/81] Fix wait for termination Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ConnectionListener.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 7f0f88f..309db1b 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -30,9 +30,6 @@ import de.steamwar.bungeecore.sql.UserGroup; import net.md_5.bungee.api.AbstractReconnectHandler; 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.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; @@ -139,6 +136,6 @@ public class ConnectionListener extends BasicListener { ProxiedPlayer player = e.getPlayer(); Collection players = server.getPlayers(); if(players.isEmpty() || (players.size() == 1 && players.contains(player))) - ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::stop); + ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination); } } From 56b6e9d94b44eac7cdcc19d1abd3ccca3b84940c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 4 Apr 2021 17:52:13 +0200 Subject: [PATCH 10/81] Remove BauweltMember.build --- .../bungeecore/commands/BauCommand.java | 18 +++-------- .../bungeecore/sql/BauweltMember.java | 31 ++++++------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 8f39327..bb891ae 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -79,11 +79,10 @@ public class BauCommand { case "teleport": teleport(p, command); break; - case "togglebuild": - if(ownBau && command.length > 2) + case "info": + if (bau != null) { e.setCancelled(false); - else - togglebuild(p, command); + } break; case "togglewe": if(ownBau && command.length > 2) @@ -131,7 +130,7 @@ public class BauCommand { return; } - new BauweltMember(p.getUniqueId(), target.getUuid(), true, false, false); + new BauweltMember(p.getUniqueId(), target.getUuid(), true, false); BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§aDer Spieler wurde zu deiner Welt hinzugefügt"); ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid()); @@ -185,15 +184,6 @@ public class BauCommand { } } - private static void togglebuild(ProxiedPlayer p, String[] command){ - BauweltMember target = toggle(p, command, "togglebuild"); - if(target == null) - return; - - target.setBuild(!target.isBuild()); - isAllowedTo(target.isBuild(), p, target, "bauen"); - } - private static void togglewe(ProxiedPlayer p, String[] command){ BauweltMember target = toggle(p, command, "togglewe"); if(target == null) diff --git a/src/de/steamwar/bungeecore/sql/BauweltMember.java b/src/de/steamwar/bungeecore/sql/BauweltMember.java index e35f0e5..f05cab2 100644 --- a/src/de/steamwar/bungeecore/sql/BauweltMember.java +++ b/src/de/steamwar/bungeecore/sql/BauweltMember.java @@ -30,27 +30,25 @@ import java.util.UUID; public class BauweltMember{ private final int bauweltID; private final int memberID; - private boolean build; private boolean worldEdit; private boolean world; - private BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world, boolean updateDB){ + private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world, boolean updateDB){ bauweltID = ownerID; this.memberID = memberID; - this.build = build; this.worldEdit = worldEdit; this.world = world; if(updateDB) updateDB(); } - public BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world){ - this(ownerID, memberID, build, worldEdit, world, true); + public BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world){ + this(ownerID, memberID, worldEdit, world, true); } - public BauweltMember(UUID ownerID, UUID memberID, boolean build, boolean worldEdit, boolean world){ - this(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId(), build, worldEdit, world); + public BauweltMember(UUID ownerID, UUID memberID, boolean worldEdit, boolean world){ + this(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId(), worldEdit, world); } public void remove(){ @@ -58,8 +56,8 @@ public class BauweltMember{ } private void updateDB(){ - SQL.update("INSERT INTO BauweltMember (BauweltID, MemberID, Build, WorldEdit, World) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Build = VALUES(Build), WorldEdit = VALUES(WorldEdit), World = VALUES(World)", - bauweltID, memberID, build, worldEdit, world); + SQL.update("INSERT INTO BauweltMember (BauweltID, MemberID, WorldEdit, World) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE WorldEdit = VALUES(WorldEdit), World = VALUES(World)", + bauweltID, memberID, worldEdit, world); } public static BauweltMember getBauMember(UUID ownerID, UUID memberID){ @@ -72,10 +70,9 @@ public class BauweltMember{ if(member == null || !member.next()){ return null; } - boolean build = member.getBoolean("Build"); boolean worldEdit = member.getBoolean("WorldEdit"); boolean world = member.getBoolean("World"); - return new BauweltMember(ownerID, memberID, build, worldEdit, world, false); + return new BauweltMember(ownerID, memberID, worldEdit, world, false); } catch (SQLException e) { BungeeCore.log("Could not load BauweltMember", e); } @@ -92,10 +89,9 @@ public class BauweltMember{ List members = new ArrayList<>(); while(memberlist.next()){ int memberID = memberlist.getInt("MemberID"); - boolean build = memberlist.getBoolean("Build"); boolean worldEdit = memberlist.getBoolean("WorldEdit"); boolean world = memberlist.getBoolean("World"); - members.add(new BauweltMember(bauweltID, memberID, build, worldEdit, world, false)); + members.add(new BauweltMember(bauweltID, memberID, worldEdit, world, false)); } return members; }catch(SQLException e){ @@ -112,15 +108,6 @@ public class BauweltMember{ return memberID; } - public boolean isBuild() { - return build; - } - - public void setBuild(boolean build) { - this.build = build; - updateDB(); - } - public boolean isWorldEdit() { return worldEdit; } From d5648d9d0bb3c2724500d6450387f09ec3bc7351 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 4 Apr 2021 18:09:21 +0200 Subject: [PATCH 11/81] Remove BungeeCore.properties BAU_HELP MESSAGE --- src/de/steamwar/bungeecore/commands/HelpCommand.java | 1 - src/de/steamwar/messages/BungeeCore.properties | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java index 7394036..d2febdc 100644 --- a/src/de/steamwar/bungeecore/commands/HelpCommand.java +++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java @@ -99,7 +99,6 @@ public class HelpCommand extends BasicCommand { Message.send("HELP_BAU_TP", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TP_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau tp ")); Message.send("HELP_BAU_ADDMEMBER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_ADDMEMBER_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau addmember ")); Message.send("HELP_BAU_DELMEMBER", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_DELMEMBER_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delmember ")); - Message.send("HELP_BAU_TOGGLEBUILD", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TOGGLEBUILD_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau togglebuild ")); Message.send("HELP_BAU_TOGGLEWE", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TOGGLEWE_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau togglewe ")); Message.send("HELP_BAU_TOGGLEWORLD", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_TOGGLEWORLD_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau toggleworld ")); Message.send("HELP_BAU_DELETE", true, p, ChatMessageType.SYSTEM, Message.parse("HELP_BAU_DELETE_HOVER", p), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delete ")); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 71ff3ca..5f62c71 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -79,8 +79,6 @@ HELP_BAU_ADDMEMBER=§8/§ebau addmember §8- §7Fügt einen Freund hinzu HELP_BAU_ADDMEMBER_HOVER=§eFüge einen Freund hinzu HELP_BAU_DELMEMBER=§8/§ebau delmember §8- §7Entfernt einen Spieler HELP_BAU_DELMEMBER_HOVER=§eEntfernt einen Spieler -HELP_BAU_TOGGLEBUILD=§8/§ebau togglebuild §8- §7Berechtigung zum Bauen, /tp, /gm -HELP_BAU_TOGGLEBUILD_HOVER=§eStellt Spielerberechtigungen ein HELP_BAU_TOGGLEWE=§8/§ebau togglewe §8- §7Berechtigung für WorldEdit, /testblock HELP_BAU_TOGGLEWE_HOVER=§eStellt Spielerberechtigungen ein HELP_BAU_TOGGLEWORLD=§8/§ebau toggleworld §8- §7/reset, /trace, /fire, /tnt From 1773d3df66b1ed8d1bc60a9e6b13364657c09e2e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 4 Apr 2021 18:35:28 +0200 Subject: [PATCH 12/81] Improve @Ping a lot --- .../commands/ServerTeamchatCommand.java | 3 +- .../bungeecore/commands/TeamchatCommand.java | 3 +- .../bungeecore/listeners/ChatListener.java | 49 ++++++++++++++----- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java index 90a6139..0aca552 100644 --- a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.listeners.ChatListener; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -56,7 +57,7 @@ public class ServerTeamchatCommand extends BasicCommand { for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ if ((target.hasPermission("bungeecore.teamchat")) && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ - Message.sendPrefixless("STC_FORMAT", target, sender.getName(), message); + Message.sendPrefixless("STC_FORMAT", target, sender.getName(), ChatListener.parseAtMessage(message, "§r", target)); } } } diff --git a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java index f5d17f5..d85ac6e 100644 --- a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; @@ -59,7 +60,7 @@ public class TeamchatCommand extends BasicCommand { SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId()); if (targetuser.getTeam() == user.getTeam() && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ - Message.sendPrefixless("TC_FORMAT", target, player.getName(), msg); + Message.sendPrefixless("TC_FORMAT", target, player.getName(), ChatListener.parseAtMessage(msg, "§f", target)); } } } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 2a5e922..f31eb83 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -35,6 +35,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.TabCompleteEvent; import net.md_5.bungee.api.event.TabCompleteResponseEvent; +import net.md_5.bungee.api.event.TargetedEvent; import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; @@ -166,22 +167,11 @@ public class ChatListener extends BasicListener { msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg; } - String[] msgSplits = msg.split(" "); - StringBuilder builder = new StringBuilder(); - for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue; - for (String curr : msgSplits) { - if(curr.equalsIgnoreCase("@" + target.getName())) { - builder.append("§e@").append(target.getName()).append(chatcolor).append(" "); - new PingPacket(SteamwarUser.get(target).getId()).send(target); - }else { - builder.append(curr).append(" "); - } - } - BungeeCore.send(target, ChatMessageType.CHAT, builder.toString()); - builder = new StringBuilder(); + + BungeeCore.send(target, ChatMessageType.CHAT, parseAtMessage(msg, chatcolor, target)); } BungeeCore.log(sender.getServer().getInfo(), msg); } @@ -211,6 +201,28 @@ public class ChatListener extends BasicListener { e.setMessage(e.getMessage().substring(command[0].length() + 1)); } + public static String parseAtMessage(String message, String returnColor, ProxiedPlayer player) { + if(!message.contains("@")) { + return message; + } + + StringBuilder builder = new StringBuilder(); + for (String curr : message.split(" ")) { + if(curr.toLowerCase().startsWith("@" + player.getName().toLowerCase())) { + new PingPacket(SteamwarUser.get(player).getId()).send(player); + builder.append("§e@") + .append(player.getName()) + .append(returnColor) + .append(curr.substring(player.getName().length() + 1)) + .append(" "); + }else { + builder.append(curr) + .append(" "); + } + } + return builder.toString(); + } + @EventHandler public void onTabCompleteEvent(TabCompleteEvent e){ List suggestions = e.getSuggestions(); @@ -226,6 +238,17 @@ public class ChatListener extends BasicListener { suggestions.add(name); } } + + if(last.startsWith("@")) { + String plrName = last.replace("@", ""); + for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ + String name = player.getName(); + if ((plrName.isEmpty() || name.startsWith(plrName)) && !plrName.equalsIgnoreCase(name)) { + suggestions.add("@" + name); + } + } + } + if(e.getSender() instanceof ProxiedPlayer && cursor.length == 1 && cursor[0].startsWith("/")){ ProxiedPlayer player = (ProxiedPlayer) e.getSender(); for(String cmd : BungeeCore.commands.keySet()){ From d0422fc4537569336be790f09e1a23149d45777c Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 4 Apr 2021 18:36:24 +0200 Subject: [PATCH 13/81] Remove Unused Import --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index f31eb83..b41ea78 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -35,7 +35,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.TabCompleteEvent; import net.md_5.bungee.api.event.TabCompleteResponseEvent; -import net.md_5.bungee.api.event.TargetedEvent; import net.md_5.bungee.api.scheduler.TaskScheduler; import net.md_5.bungee.event.EventHandler; From f3a6269331ff3d86c34e549ef061ca8def4e5b5e Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 11 Apr 2021 15:45:35 +0200 Subject: [PATCH 14/81] Added Multi Leader Feature --- .../bungeecore/commands/TeamCommand.java | 71 +++++++++++++------ .../steamwar/bungeecore/sql/SteamwarUser.java | 12 ++++ src/de/steamwar/bungeecore/sql/Team.java | 21 ++---- .../steamwar/messages/BungeeCore.properties | 12 ++-- 4 files changed, 74 insertions(+), 42 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index a1ca995..abebce2 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -38,6 +38,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; import static de.steamwar.bungeecore.Storage.teamInvitations; @@ -90,13 +91,14 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_HELP_LEAVE", sender); Team team = Team.get(user.getTeam()); - if(team.getTeamLeader() == user.getId()){ + if(user.isLeader()){ Message.send("TEAM_HELP_INVITE", sender); Message.send("TEAM_HELP_REMOVE", sender); Message.send("TEAM_HELP_KUERZEL", sender); Message.send("TEAM_HELP_NAME", sender); Message.send("TEAM_HELP_COLOR", sender); Message.send("TEAM_HELP_LEADER", sender); + Message.send("TEAM_HELP_STEP_BACK", sender); } } } @@ -122,6 +124,9 @@ public class TeamCommand extends BasicCommand { case "join": join(player, user, args); break; + case "stepback": + stepBack(player,user,team); + break; case "leave": leave(player, user, team); break; @@ -137,8 +142,8 @@ public class TeamCommand extends BasicCommand { case "changename": changename(player, user, team, args); break; - case "changeleader": - changeleader(player, user, team, args); + case "promote": + promote(player, user, team, args); break; case "changecolor": changeColor(player, user, team); @@ -225,18 +230,31 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName()); } + private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) { + if(notLeader(player, user, team)) + return; + + if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){ + Message.send("TEAM_OTHER_LEADER_REQUIRED", player); + return; + } + + user.setLeader(false); + Message.send("TEAM_STEP_BACK", player); + } + private void leave(ProxiedPlayer player, SteamwarUser user, Team team){ if(notInTeam(player, user)) return; - if(team.getTeamLeader() == user.getId() && team.size() > 1){ - Message.send("TEAM_LEAVE_OTHER_LEADER", player); + if(team.size() > 1 && user.isLeader() && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){ + Message.send("TEAM_OTHER_LEADER_REQUIRED", player); return; } user.setTeam(0); - if(team.getTeamLeader() == user.getId()){ + if(user.isLeader() && team.size() > 0){ team.disband(); } @@ -296,7 +314,7 @@ public class TeamCommand extends BasicCommand { return; } - if (team.getTeamLeader() == target.getId()) { + if (user.isLeader()) { Message.send("TEAM_REMOVE_NOT_LEADER", player); return; } @@ -363,7 +381,7 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_NAME_CHANGED", player); } - private void changeleader(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ if(notLeader(player, user, team)) return; @@ -386,8 +404,8 @@ public class TeamCommand extends BasicCommand { return; } - team.setTeamLeader(target.getId()); - Message.send("TEAM_LEADER_CHANGED", player, args[1]); + target.setLeader(true); + Message.send("TEAM_LEADER_PROMOTED", player, args[1]); } private String playerName(SteamwarUser user){ @@ -408,17 +426,15 @@ public class TeamCommand extends BasicCommand { } Message.sendPrefixless("TEAM_INFO_TEAM", player, team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel()); - Message.sendPrefixless("TEAM_INFO_LEADER", player, playerName(SteamwarUser.get(team.getTeamLeader()))); - if(team.getMembers().size() > 1) { - StringBuilder sb = new StringBuilder(); - List members = team.getMembers(); - for (int i : members) { - if (i == team.getTeamLeader()) - continue; - sb.append(playerName(SteamwarUser.get(i))).append(" "); - } - Message.sendPrefixless("TEAM_INFO_MEMBER", player, sb.toString()); + List users = team.getMembers().stream().map(userId -> SteamwarUser.get(userId)).collect(Collectors.toList()); + + Message.sendPrefixless("TEAM_INFO_LEADER", player, getMemberList(users, true)); + + String members = getMemberList(users, false); + + if(members.length() > 0) { + Message.sendPrefixless("TEAM_INFO_MEMBER", player, members); } Set events = TeamTeilnahme.getEvents(team.getTeamId()); @@ -430,6 +446,16 @@ public class TeamCommand extends BasicCommand { } } + private String getMemberList(List users, boolean leaders) { + StringBuilder sb = new StringBuilder(); + for(SteamwarUser user : users) { + if(user.isLeader() == leaders) { + sb.append(playerName(user)).append(" "); + } + } + return sb.toString(); + } + private void list(ProxiedPlayer player, String[] args){ final int TEAMS_PER_PAGE = 10; @@ -458,7 +484,7 @@ public class TeamCommand extends BasicCommand { Team tm = all.get(i); Message.sendPrefixless("TEAM_LIST_TEAM", player, Message.parse("TEAM_LIST_TEAM_HOVER", player), - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName(), SteamwarUser.get(tm.getTeamLeader()).getUserName()); + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName()); } TextComponent beforePage = new TextComponent("««"); @@ -593,7 +619,7 @@ public class TeamCommand extends BasicCommand { private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){ if(notInTeam(player, user)) return true; - if(team.getTeamLeader() != user.getId()){ + if(!user.isLeader()){ Message.send("TEAM_NOT_LEADER", player); return true; } @@ -615,6 +641,7 @@ public class TeamCommand extends BasicCommand { tab.add("create"); tab.add("join"); tab.add("invite"); + tab.add("stepback"); tab.add("leave"); tab.add("info"); tab.add("remove"); diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 1a1aefd..bf11939 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -44,6 +44,7 @@ public class SteamwarUser { private String userName; private UserGroup userGroup; private int team; + private boolean leader; private Map punishments; private static final Map usersByName = new HashMap<>(); @@ -66,6 +67,7 @@ public class SteamwarUser { userName = rs.getString("UserName"); userGroup = UserGroup.getUsergroup(rs.getString("UserGroup")); team = rs.getInt("Team"); + leader = rs.getBoolean("Leader"); usersById.put(id, this); usersByName.put(userName.toLowerCase(), this); usersByUUID.put(uuid, this); @@ -127,6 +129,7 @@ public class SteamwarUser { public void setTeam(int team){ this.team = team; SQL.update("Update UserData SET Team = ? WHERE id = ?", team, id); + setLeader(false); } public int getId() { @@ -261,4 +264,13 @@ public class SteamwarUser { throw new SecurityException("Could not load First Join"); } } + + public boolean isLeader() { + return leader; + } + + public void setLeader(boolean leader) { + this.leader = leader; + SQL.update("Update UserData SET Leader = ? WHERE id = ?", leader, id); + } } diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 1285547..3fd3eab 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -33,17 +33,15 @@ public class Team { private final int teamId; private String teamKuerzel; private String teamName; - private int teamLeader; private String teamColor; private static final List teamCache = new LinkedList<>(); - private static final Team pub = new Team(0, "PUB", "Öffentlich", 0, "8"); + private static final Team pub = new Team(0, "PUB", "Öffentlich", "8"); - private Team(int id, String kuerzel, String name, int leader, String color){ + private Team(int id, String kuerzel, String name, String color){ teamId = id; teamKuerzel = kuerzel; teamName = name; - teamLeader = leader; teamColor = color; if (id != 0) { teamCache.add(this); @@ -51,7 +49,7 @@ public class Team { } private Team(ResultSet rs) throws SQLException { - this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getInt("TeamLeader"), rs.getString("TeamColor")); + this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getString("TeamColor")); } public static void create(String kuerzel, String name, int leader){ @@ -60,7 +58,7 @@ public class Team { public static Team get(int id){ if(id == -1) - return new Team(-1, "?", "?", 0, "8"); + return new Team(-1, "?", "?", "8"); if(id == 0) return pub; for(Team team : teamCache) @@ -110,7 +108,7 @@ public class Team { } private void updateDB(){ - SQL.update("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamLeader, TeamColor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamLeader = VALUES(TeamLeader), TeamColor = VALUES(TeamColor)", teamId, teamKuerzel, teamName, teamLeader, teamColor); + SQL.update("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamColor) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamColor = VALUES(TeamColor)", teamId, teamKuerzel, teamName, teamColor); } public int getTeamId() { @@ -135,15 +133,6 @@ public class Team { updateDB(); } - public int getTeamLeader() { - return teamLeader; - } - - public void setTeamLeader(int teamLeader) { - this.teamLeader = teamLeader; - updateDB(); - } - public String getTeamColor() { return teamColor; } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 5f62c71..f1275fd 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -324,7 +324,8 @@ TEAM_HELP_REMOVE=§8/§7team remove §8- §7Entferne jemanden aus deinem Team. TEAM_HELP_KUERZEL=§8/§7team changekuerzel §8- §7Ändere dein Teamkürzel. TEAM_HELP_NAME=§8/§7team changename §8- §7Ändere deinen Teamnamen. TEAM_HELP_COLOR=§8/§7eteam changecolor §8- §7Ändere deine Teamfarbe. -TEAM_HELP_LEADER=§8/§7eteam changeleader §8- §7Ernenne jemanden zum Teamleader. +TEAM_HELP_LEADER=§8/§7eteam promote §8- §7Ernenne jemanden zum Teamleader. +TEAM_HELP_STEP_BACK=§8/§7eteam stepback §8- §7Tritt als Leader zurück. #Team Create TEAM_CREATE_USAGE=§8/§7team create §8[§eTeamkürzel§8] §8[§eTeamname§8] @@ -338,9 +339,12 @@ TEAM_JOIN_NOT_BY_TEAM=§cVon diesem Team wurdest du nicht eingeladen. TEAM_JOIN_JOINED=§7Du bist dem Team §e{0} §7beigetreten! #Team Leave -TEAM_LEAVE_OTHER_LEADER=§cBitte ernenne zunächst ein anderes Teammitglied zum Leader! +TEAM_OTHER_LEADER_REQUIRED=§cBitte ernenne zunächst ein anderes Teammitglied zum Leader! TEAM_LEAVE_LEFT=§7Du hast dein Team verlassen! +#Team Step Back +TEAM_STEP_BACK=§7Du hast deinen Posten als Teamleader abgegeben§8! + #Team Invite TEAM_INVITE_USAGE=§8/§7team invite §8[§eSpieler§8] TEAM_INVITE_NO_PLAYER=§cDiesen Spieler gibt es nicht. @@ -375,7 +379,7 @@ TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen. TEAM_LEADER_USAGE=§8/§7team changeleader §8[§eMember§8] TEAM_LEADER_NOT_USER=§cDen Spieler {0} gibt es nicht. TEAM_LEADER_NOT_MEMBER=§cDer Spieler ist nicht in deinem Team. -TEAM_LEADER_CHANGED=§7Du hast den Spieler §e{0} §7zum Leader gemacht! +TEAM_LEADER_PROMOTED=§7Du hast den Spieler §e{0} §7zum Leader gemacht! #Team Info TEAM_INFO_USAGE=§8/§7team info §8[§eTeamname§8] @@ -388,7 +392,7 @@ TEAM_INFO_EVENTS=§7Events§8: §e{0} TEAM_LIST_NOT_PAGE=§cKeine Seitenzahl angegeben TEAM_LIST_UNKNOWN_PAGE=§cUngültige Seitenzahl angegeben TEAM_LIST_HEADER=§7§lTeamliste §7{0}§8/§7{1} -TEAM_LIST_TEAM=§{0}{1} §e{2} §8[§7{3}§8] +TEAM_LIST_TEAM=§{0}{1} §e{2} TEAM_LIST_TEAM_HOVER=§7Teaminfo TEAM_LIST_PAGE=Seite TEAM_LIST_NEXT=§eNächste Seite From bc39e6f3077f6e969a33b8dd5988f5b6c75428a2 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 12 Apr 2021 12:32:05 +0200 Subject: [PATCH 15/81] Fixed Formating of Code --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index abebce2..503590f 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -448,7 +448,7 @@ public class TeamCommand extends BasicCommand { private String getMemberList(List users, boolean leaders) { StringBuilder sb = new StringBuilder(); - for(SteamwarUser user : users) { + for(SteamwarUser user : users) { if(user.isLeader() == leaders) { sb.append(playerName(user)).append(" "); } From 2bbcb283b4eb8b4a670881d5cea905e4a3590837 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 12 Apr 2021 12:33:10 +0200 Subject: [PATCH 16/81] Used Lambda --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 503590f..825b3b6 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -427,7 +427,7 @@ public class TeamCommand extends BasicCommand { Message.sendPrefixless("TEAM_INFO_TEAM", player, team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel()); - List users = team.getMembers().stream().map(userId -> SteamwarUser.get(userId)).collect(Collectors.toList()); + List users = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList()); Message.sendPrefixless("TEAM_INFO_LEADER", player, getMemberList(users, true)); From dc49ddff4dcb4530908d2fcc8109dacf744e6dfc Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 13 Apr 2021 07:22:57 +0200 Subject: [PATCH 17/81] Fixed team remove command --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 825b3b6..082496e 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -314,7 +314,7 @@ public class TeamCommand extends BasicCommand { return; } - if (user.isLeader()) { + if (target.isLeader() && user.isLeader()) { Message.send("TEAM_REMOVE_NOT_LEADER", player); return; } From f59350bab7473757357a3ce1e97f6c6b1174f59c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 13 Apr 2021 07:25:32 +0200 Subject: [PATCH 18/81] Fix leader Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 082496e..0b78c38 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -314,7 +314,7 @@ public class TeamCommand extends BasicCommand { return; } - if (target.isLeader() && user.isLeader()) { + if (target.isLeader()) { Message.send("TEAM_REMOVE_NOT_LEADER", player); return; } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index f1275fd..058573e 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -356,7 +356,7 @@ TEAM_INVITE_INVITED_TARGET=§7Du wurdest in das Team §{0}{1} §7eingeladen! #Team Remove TEAM_REMOVE_USAGE=§8/§7team remove §8[§eSpieler§8] TEAM_REMOVE_NOT_PLAYER=§cDiesen Spieler gibt es nicht. -TEAM_REMOVE_NOT_LEADER=§cLeader entfernen sich nicht selbst. +TEAM_REMOVE_NOT_LEADER=§cLeader können nicht rausgeworfen werden. TEAM_REMOVE_INVITE=§7Die Einladung wurde zurückgezogen. TEAM_REMOVE_NO_INVITE=§cDieser Spieler hat keine Einladung erhalten. TEAM_REMOVE_NOT_IN_TEAM=§cDieser Spieler ist nicht in deinem Team. From 073ed4c4360400ceadc614e3a72171ac99539822 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 13 Apr 2021 07:32:27 +0200 Subject: [PATCH 19/81] Fix msgs Signed-off-by: Lixfel --- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 058573e..dee8873 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -323,9 +323,9 @@ TEAM_HELP_INVITE=§8/§7team invite §8- §7Lade jemanden in dein Team ein. TEAM_HELP_REMOVE=§8/§7team remove §8- §7Entferne jemanden aus deinem Team. TEAM_HELP_KUERZEL=§8/§7team changekuerzel §8- §7Ändere dein Teamkürzel. TEAM_HELP_NAME=§8/§7team changename §8- §7Ändere deinen Teamnamen. -TEAM_HELP_COLOR=§8/§7eteam changecolor §8- §7Ändere deine Teamfarbe. -TEAM_HELP_LEADER=§8/§7eteam promote §8- §7Ernenne jemanden zum Teamleader. -TEAM_HELP_STEP_BACK=§8/§7eteam stepback §8- §7Tritt als Leader zurück. +TEAM_HELP_COLOR=§8/§7team changecolor §8- §7Ändere deine Teamfarbe. +TEAM_HELP_LEADER=§8/§7team promote §8- §7Ernenne jemanden zum Teamleader. +TEAM_HELP_STEP_BACK=§8/§7team stepback §8- §7Tritt als Leader zurück. #Team Create TEAM_CREATE_USAGE=§8/§7team create §8[§eTeamkürzel§8] §8[§eTeamname§8] From 555997055209100b9b3c0f11c6a2fbb765118749 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 13 Apr 2021 07:37:31 +0200 Subject: [PATCH 20/81] Fix msgs Signed-off-by: Lixfel --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index dee8873..911b24d 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -376,7 +376,7 @@ TEAM_NAME_LENGHT=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen. TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen. #Team Leader -TEAM_LEADER_USAGE=§8/§7team changeleader §8[§eMember§8] +TEAM_LEADER_USAGE=§8/§7team promote §8[§eMember§8] TEAM_LEADER_NOT_USER=§cDen Spieler {0} gibt es nicht. TEAM_LEADER_NOT_MEMBER=§cDer Spieler ist nicht in deinem Team. TEAM_LEADER_PROMOTED=§7Du hast den Spieler §e{0} §7zum Leader gemacht! From 3ec2e103b594492c75d2f684d6fb8be009170a02 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 13 Apr 2021 14:53:41 +0200 Subject: [PATCH 21/81] Fixed Schem Alert --- src/de/steamwar/bungeecore/Message.java | 7 +++++++ src/de/steamwar/bungeecore/commands/CheckCommand.java | 7 ++----- src/de/steamwar/messages/BungeeCore.properties | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 65f1dec..5239bd8 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -129,4 +129,11 @@ public class Message { sendPrefixless(message, player, type, params); } } + + public static void team(String message, String onHover, ClickEvent onClick, Object... params){ + for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ + if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) + sendPrefixless(message, player, Message.parse(onHover, player, params), onClick, params); + } + } } \ No newline at end of file diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 7ee3024..74dbbb8 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -68,16 +68,13 @@ public class CheckCommand extends BasicCommand { ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { List schematics = getSchemsToCheck(); if(schematics.size() != currentCheckers.size()) - for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ - if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) - BungeeCore.send(player, Message.parse("CHECK_REMINDER", player, schematics.size() - currentCheckers.size()), Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list")); - } + Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size()); }, 10, 10, TimeUnit.MINUTES); } public static void sendReminder(ProxiedPlayer player) { List schematics = getSchemsToCheck(); if(schematics.size() != currentCheckers.size()) - BungeeCore.send(player, Message.parse("CHECK_REMINDER", player, schematics.size() - currentCheckers.size()), Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list")); + Message.send("CHECK_REMINDER", player, "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size()); } @Override diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index aeca89b..25babec 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -122,7 +122,7 @@ BAU_DELETE_GUI_DELETE=§aLöschen #CheckCommand CHECK_REMINDER=§7Es sind §e{0} §7Schematics zu prüfen§8! -CHECK_REMINDER_HOVER=§eZuprüfende Schematics +CHECK_REMINDER_HOVER=§eZu prüfende Schematics CHECK_NOT_CHECKING=§cDu prüfst derzeit nicht. CHECK_HELP_LIST=§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics CHECK_HELP_NEXT=§8/§echeck next §8- §7Nächste Prüffrage§8/§7freigeben @@ -146,4 +146,4 @@ CHECK_RANK_HOVER=§aMit diesem Rang freigeben CHECK_ACCEPTED=§aDein §e{0} {1} §ewurde freigegeben§8! CHECK_ACCEPTED_TEAM=§7Die Schematic §e{0} §7von §e{1} §7ist nun freigegeben! CHECK_DECLINED=§cDein §e{0} {1} §cwurde abgelehnt§8: §c{2} -CHECK_DECLINED_TEAM=§7Die Schematic §e{0} §7von §e{1} §awurde aufgrund von §e{2} §7abgelehnt! \ No newline at end of file +CHECK_DECLINED_TEAM=§7Die Schematic §e{0} §7von §e{1} §7wurde aufgrund von §e{2} §7abgelehnt! \ No newline at end of file From 2a16c8c66b93cda224d472730e5c993d2814a519 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 14 Apr 2021 14:23:06 +0200 Subject: [PATCH 22/81] Fixed Team Leader is Member --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- src/de/steamwar/bungeecore/sql/Team.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 082496e..0fad2f1 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -177,7 +177,7 @@ public class TeamCommand extends BasicCommand { if(checkTeamName(player, team, args[2])) return; - Team.create(args[1], args[2], user.getId()); + Team.create(args[1], args[2], user); user.setTeam(Team.get(args[1]).getTeamId()); Message.send("TEAM_CREATE_CREATED", player, args[2]); } diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 3fd3eab..1256a1a 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -52,8 +52,9 @@ public class Team { this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getString("TeamColor")); } - public static void create(String kuerzel, String name, int leader){ - SQL.update("INSERT INTO Team (TeamKuerzel, TeamName, TeamLeader) VALUES (?, ?, ?)", kuerzel, name, leader); + public static void create(String kuerzel, String name, SteamwarUser user){ + user.setLeader(true); + SQL.update("INSERT INTO Team (TeamKuerzel, TeamName) VALUES (?, ?)", kuerzel, name); } public static Team get(int id){ From 3676051e40627741cc9db2d1bdadf41d3c991434 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 14 Apr 2021 20:24:35 +0200 Subject: [PATCH 23/81] Allow paper bau + small code cleanup Signed-off-by: Lixfel --- .../steamwar/bungeecore/SubserverSystem.java | 101 +++++++++--------- .../bungeecore/commands/BauCommand.java | 23 +--- 2 files changed, 52 insertions(+), 72 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 8295642..2812eb3 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -28,8 +28,10 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.io.File; import java.io.IOException; +import java.net.InetSocketAddress; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.logging.Level; public class SubserverSystem { private SubserverSystem(){} @@ -41,13 +43,13 @@ public class SubserverSystem { private static final String SERVER_PATH = BACKBONE + "server/"; private static final String EVENT_PATH = BACKBONE + "event/"; - private static final int firstArenaPort; + private static final int FIRST_ARENA_PORT; static { if(BungeeCore.EVENT_MODE) - firstArenaPort = 6000; + FIRST_ARENA_PORT = 6000; else - firstArenaPort = 2500; + FIRST_ARENA_PORT = 2500; } /** @@ -89,13 +91,13 @@ public class SubserverSystem { */ public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, int prepareSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){ //Generate missing parameters - int port = freePort(firstArenaPort); + int port = freePort(FIRST_ARENA_PORT); if(serverName == null){ if(ranked) - serverName = "Ranked" + (port - firstArenaPort); + serverName = "Ranked" + (port - FIRST_ARENA_PORT); else - serverName = modus.getDisplayName() + (port - firstArenaPort); + serverName = modus.getDisplayName() + (port - FIRST_ARENA_PORT); } if(mapName == null) mapName = serverName; @@ -109,8 +111,11 @@ public class SubserverSystem { //Copy world try { new ProcessBuilder("cp", "-r", SERVER_PATH + modus.getFolder() + "/arenas/" + map, worldDir + mapName).start().waitFor(); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { throw new SecurityException("Could not copy folder", e); + } catch (InterruptedException e) { + ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Interrupted while copying folder", e); + Thread.currentThread().interrupt(); } List cmd = serverStartCommand( @@ -125,8 +130,8 @@ public class SubserverSystem { "ranked=" + ranked, "checkSchemID=" + checkSchemID, "prepareSchemID=" + prepareSchemID, - player1 != null && eventFightID != -1 ? "blueLeader=" + player1.toString() : null, - player2 != null ? "redLeader=" + player2.toString() : null); + player1 != null && eventFightID != -1 ? "blueLeader=" + player1 : null, + player2 != null ? "redLeader=" + player2 : null); //Start server ProcessBuilder process = new ProcessBuilder(cmd); @@ -134,26 +139,26 @@ public class SubserverSystem { String finalMapName = mapName; if(eventFightID == -1) - return new Bauserver(serverName, player1, port, process, () -> { - try { - new ProcessBuilder("rm", "-r", ARENA_PATH + finalMapName).start().waitFor(); - } catch (IOException | InterruptedException e) { - throw new SecurityException("Could not clean up folder", e); - } - }); + return new Bauserver(serverName, player1, port, process, () -> deleteFolder(ARENA_PATH + finalMapName)); else return new Subserver(Servertype.ARENA, serverName, port, process, () -> { if(eventFightID > 0) return; - - try { - new ProcessBuilder("rm", "-r", ARENA_PATH + finalMapName).start().waitFor(); - } catch (IOException | InterruptedException e) { - throw new SecurityException("Could not clean up folder", e); - } + deleteFolder(ARENA_PATH + finalMapName); }); } + public static void deleteFolder(String worldName){ + try { + new ProcessBuilder("rm", "-r", worldName).start().waitFor(); + } catch (IOException e) { + throw new SecurityException("Could not clean up folder", e); + } catch (InterruptedException e) { + ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Interrupted while deleting folder", e); + Thread.currentThread().interrupt(); + } + } + public static Subserver startEventArena(EventFight eventFight, String serverName){ return startArena( eventFight.getSpielmodus(), @@ -172,50 +177,44 @@ public class SubserverSystem { startArena(m, map, -1, checkSchemId, prepareSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null, false).sendPlayer(p); } - public static void sendToBauServer(ProxiedPlayer p, UUID owner){ + private static void sendToBau(ProxiedPlayer p, UUID owner, String prototype, String worldFolder, String serverJar, String worldDir, String worldName, String xmx, String serverName){ if(bauRunning(p, owner)) return; SteamwarUser user = SteamwarUser.get(owner); - copyBauweltIfRequired(p, BungeeCore.BAUWELT_PROTOTYP, BungeeCore.WORLD_FOLDER + owner.toString()); + copyBauweltIfRequired(p, prototype, worldFolder + worldName); int port = freePort(4000); List cmd = serverStartCommand( - "spigot-1.12.2.jar", - "/home/minecraft/userworlds", - owner.toString(), + serverJar, + worldDir, + worldName, port, - "256M", - "logPath=" + owner.toString()); + xmx, + "logPath=" + worldName); //Start server ProcessBuilder process = new ProcessBuilder(cmd); - process.directory(new File(SERVER_PATH, "UserBau")); + process.directory(new File(SERVER_PATH, serverName)); new Bauserver(user.getUserName() + "s Bau", owner, port, process, () -> {}).sendPlayer(p); } - public static void sendToBau15(ProxiedPlayer p, UUID owner){ - if(bauRunning(p, owner)) - return; + public static void sendToBauServer(ProxiedPlayer p, UUID owner){ + sendToBau(p, owner, BungeeCore.BAUWELT_PROTOTYP, BungeeCore.WORLD_FOLDER, "spigot-1.12.2.jar", "/home/minecraft/userworlds", owner.toString(), "256M", "UserBau"); + } + private static void sendToBau15(ProxiedPlayer p, UUID owner, String serverJar){ SteamwarUser user = SteamwarUser.get(owner); - copyBauweltIfRequired(p, BungeeCore.BAUWELT15, BungeeCore.USERWORLDS15 + user.getId()); - int port = freePort(4000); + sendToBau(p, owner, BungeeCore.BAUWELT15, BungeeCore.USERWORLDS15, serverJar, "/home/minecraft/userworlds15", String.valueOf(user.getId()), "512M", "Bau15"); + } - List cmd = serverStartCommand( - "spigot-1.15.2.jar", - "/home/minecraft/userworlds15", - String.valueOf(user.getId()), - port, - "512M", - "logPath=" + user.getId()); + public static void sendToBau15(ProxiedPlayer p, UUID owner){ + sendToBau15(p, owner, "spigot-1.15.2.jar"); + } - //Start server - ProcessBuilder process = new ProcessBuilder(cmd); - process.directory(new File(SERVER_PATH, "Bau15")); - - new Bauserver(user.getUserName() + "s Bau", owner, port, process, () -> {}).sendPlayer(p); + public static void sendToBau15paper(ProxiedPlayer p, UUID owner){ + sendToBau15(p, owner, "paper-1.15.2.jar"); } public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){ @@ -274,11 +273,7 @@ public class SubserverSystem { File w = new File(targetPath); if (!w.exists() || !w.isDirectory()){ try { - Process pr; - ProcessBuilder pb = new ProcessBuilder( - "cp", "-r", sourcePath, targetPath); - pr = pb.start(); - pr.waitFor(); + new ProcessBuilder("cp", "-r", sourcePath, targetPath).start().waitFor(); } catch (IOException e) { Message.send("SERVER_WORLD_ERROR", p); throw new SecurityException("Could not create Bauwelt", e); @@ -298,7 +293,7 @@ public class SubserverSystem { port++; isFree = true; for(Subserver server : Subserver.getServerList()){ - if(server.getServer().getAddress().getPort() == port){ + if(((InetSocketAddress)server.getServer().getSocketAddress()).getPort() == port){ isFree = false; break; } diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 7f2052b..590ef93 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -28,8 +28,6 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; -import java.io.File; - public class BauCommand { private BauCommand(){} @@ -70,6 +68,9 @@ public class BauCommand { case "1.15": SubserverSystem.sendToBau15(p, p.getUniqueId()); break; + case "paper": + SubserverSystem.sendToBau15paper(p, p.getUniqueId()); + break; case "addmember": addmember(p, command); break; @@ -251,8 +252,7 @@ public class BauCommand { break; } } - File directory = new File(world); - del(directory); + SubserverSystem.deleteFolder(world); }); } @@ -318,19 +318,4 @@ public class BauCommand { Message.send("BAU_MEMBER_TOGGLE_OFF", p, what); } } - - private static void del(File dir){ - if (dir.isDirectory()){ - String[] entries = dir.list(); - assert entries != null; - for (String entry : entries) { - File aktFile = new File(dir.getPath(), entry); - del(aktFile); - } - dir.delete(); - } - else{ - dir.delete(); - } - } } From 93d463365a7eab4c54939146445298a211c491ff Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 15 Apr 2021 18:54:21 +0200 Subject: [PATCH 24/81] Fixed Empty Team --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- src/de/steamwar/bungeecore/sql/Team.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 0fad2f1..e8405eb 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -255,7 +255,7 @@ public class TeamCommand extends BasicCommand { user.setTeam(0); if(user.isLeader() && team.size() > 0){ - team.disband(); + team.disband(user); } Message.send("TEAM_LEAVE_LEFT", player); diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 1256a1a..6df9073 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -154,8 +154,9 @@ public class Team { } } - public void disband(){ - SQL.update("UPDATE Team SET TeamDeleted = 1, TeamLeader = NULL WHERE TeamID = ?", teamId); + public void disband(SteamwarUser user){ + user.setLeader(false); + SQL.update("UPDATE Team SET TeamDeleted = 1", teamId); teamCache.remove(this); } From 956339faf6321962f150ef2433b86befce5c16dd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 23 Apr 2021 18:44:38 +0200 Subject: [PATCH 25/81] Hotfix team creation Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 1 + src/de/steamwar/bungeecore/sql/Team.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index b85aeb7..16c9873 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -179,6 +179,7 @@ public class TeamCommand extends BasicCommand { Team.create(args[1], args[2], user); user.setTeam(Team.get(args[1]).getTeamId()); + user.setLeader(true); Message.send("TEAM_CREATE_CREATED", player, args[2]); } diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 6df9073..7eee1e2 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -53,7 +53,6 @@ public class Team { } public static void create(String kuerzel, String name, SteamwarUser user){ - user.setLeader(true); SQL.update("INSERT INTO Team (TeamKuerzel, TeamName) VALUES (?, ?)", kuerzel, name); } From c7402b34eef66e6586a1798eeb8e62609c2379b2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Mon, 26 Apr 2021 20:24:56 +0200 Subject: [PATCH 26/81] You can now ban and mute Users who never joined the server, HOOZAH --- .../bungeecore/commands/BanCommand.java | 2 +- .../bungeecore/commands/BasicCommand.java | 9 +++- .../bungeecore/commands/MuteCommand.java | 2 +- .../bungeecore/commands/UnbanCommand.java | 2 +- .../steamwar/bungeecore/sql/SteamwarUser.java | 46 ++++++++++++++++++- 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BanCommand.java b/src/de/steamwar/bungeecore/commands/BanCommand.java index 293b3f1..6b3bcea 100644 --- a/src/de/steamwar/bungeecore/commands/BanCommand.java +++ b/src/de/steamwar/bungeecore/commands/BanCommand.java @@ -42,7 +42,7 @@ public class BanCommand extends BasicCommand { return; } - SteamwarUser target = user(sender, args[0]); + SteamwarUser target = unsafeUser(sender, args[0]); if(target == null) return; diff --git a/src/de/steamwar/bungeecore/commands/BasicCommand.java b/src/de/steamwar/bungeecore/commands/BasicCommand.java index 9cdf19a..d4b9c0a 100644 --- a/src/de/steamwar/bungeecore/commands/BasicCommand.java +++ b/src/de/steamwar/bungeecore/commands/BasicCommand.java @@ -53,10 +53,17 @@ abstract class BasicCommand extends Command implements TabExecutor { return new ArrayList<>(); } - protected SteamwarUser user(CommandSender sender, String arg){ + protected SteamwarUser existingUser(CommandSender sender, String arg){ SteamwarUser target = SteamwarUser.get(arg); if(target == null) Message.send("UNKNOWN_PLAYER", sender); return target; } + + protected SteamwarUser unsafeUser(CommandSender sender, String arg){ + SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg); + if(target == null) + Message.send("UNKNOWN_PLAYER", sender); + return target; + } } diff --git a/src/de/steamwar/bungeecore/commands/MuteCommand.java b/src/de/steamwar/bungeecore/commands/MuteCommand.java index ea77888..9ecfde1 100644 --- a/src/de/steamwar/bungeecore/commands/MuteCommand.java +++ b/src/de/steamwar/bungeecore/commands/MuteCommand.java @@ -38,7 +38,7 @@ public class MuteCommand extends BasicCommand { return; } - SteamwarUser target = user(sender, args[0]); + SteamwarUser target = unsafeUser(sender, args[0]); if(target == null) return; diff --git a/src/de/steamwar/bungeecore/commands/UnbanCommand.java b/src/de/steamwar/bungeecore/commands/UnbanCommand.java index 58c0a6f..176029a 100644 --- a/src/de/steamwar/bungeecore/commands/UnbanCommand.java +++ b/src/de/steamwar/bungeecore/commands/UnbanCommand.java @@ -39,7 +39,7 @@ public class UnbanCommand extends BasicCommand { return; } - SteamwarUser target = user(sender, args[0]); + SteamwarUser target = existingUser(sender, args[0]); if(target == null) return; diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index bf11939..d221c8b 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -19,10 +19,15 @@ package de.steamwar.bungeecore.sql; +import com.google.gson.JsonParser; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.WebregisterCommand; import de.steamwar.bungeecore.listeners.ConnectionListener; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Scanner; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; @@ -38,6 +43,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; + public class SteamwarUser { private final int id; private final UUID uuid; @@ -51,6 +57,8 @@ public class SteamwarUser { private static final Map usersByUUID = new HashMap<>(); private static final Map usersById = new HashMap<>(); private static final InetAddress LIXFEL_DE; + private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/"; + private static final JsonParser jsonParser = new JsonParser(); static { try { @@ -85,8 +93,7 @@ public class SteamwarUser { user.userName = userName; } }else{ - SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, 'Member')", connection.getUniqueId().toString(), connection.getName()); - user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString())); + user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName()); if(user == null) throw new SecurityException("user == null"); ConnectionListener.newPlayer(user.uuid); @@ -97,6 +104,25 @@ public class SteamwarUser { return user; } + public static SteamwarUser getOrCreateOfflinePlayer(String name){ + SteamwarUser user = SteamwarUser.get(name); + if (user != null) { + return user; + } + + UUID uuid = SteamwarUser.loadUUID(name); + if (uuid == null) { + return null; + } + + return SteamwarUser.createUserInDatabase(uuid, name); + } + + private static SteamwarUser createUserInDatabase(UUID uuid, String name) { + SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, 'Member')", uuid.toString(), name); + return dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", uuid.toString())); + } + public static SteamwarUser get(String userName){ userName = userName.toLowerCase(); if(usersByName.containsKey(userName)) @@ -126,6 +152,22 @@ public class SteamwarUser { usersByUUID.clear(); } + public static UUID loadUUID(String playerName) { + try { + final URL url = new URL(API_URL + playerName); + return getUniqueIdFromString(jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + private static UUID getUniqueIdFromString(String uuid) { + return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); + } + public void setTeam(int team){ this.team = team; SQL.update("Update UserData SET Team = ? WHERE id = ?", team, id); From ea9a98ec11f13719d52001679f11d563685bde65 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 27 Apr 2021 14:49:28 +0200 Subject: [PATCH 27/81] Add custom Branding for Bungee --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/listeners/BrandListener.java | 66 +++++++++++++++++++ .../steamwar/messages/BungeeCore.properties | 2 + 3 files changed, 69 insertions(+) create mode 100644 src/de/steamwar/bungeecore/listeners/BrandListener.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 6ca3220..2344d56 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -84,6 +84,7 @@ public class BungeeCore extends Plugin { new CheckListener(); new ModLoaderBlocker(); new WorldDownloader(); + new BrandListener(); commands.put("/b", null); commands.put("/gs", null); diff --git a/src/de/steamwar/bungeecore/listeners/BrandListener.java b/src/de/steamwar/bungeecore/listeners/BrandListener.java new file mode 100644 index 0000000..313476e --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/BrandListener.java @@ -0,0 +1,66 @@ +/* + 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.listeners; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.sql.SteamwarUser; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.event.EventHandler; +import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.ProtocolConstants; +import net.md_5.bungee.protocol.packet.PluginMessage; + +import java.util.concurrent.TimeUnit; + +public class BrandListener extends BasicListener { + + @EventHandler + public void onServerSwitch(PluginMessageEvent event) { + if(event.getTag().equals("minecraft:brand") || event.getTag().equals("MC|Brand")) { + return; + } + + if(event.getReceiver().getAddress().getHostName().contains("localhost")) { + return; + } + + BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> { + ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); + SteamwarUser user = SteamwarUser.get(player); + + String channel = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand"; + StringBuilder serverBrand = new StringBuilder(); + for (byte b:event.getData()) { + serverBrand.append((char) b); + } + + String brandString = Message.parse("STEAMWAR_BRAND", player, user.getUserGroup().getColorCode(), player.getName(), BungeeCore.get().getProxy().getName(), player.getServer().getInfo().getName(), serverBrand.substring(1)); + + ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); + DefinedPacket.writeString(brandString, brand); + player.sendData(channel, DefinedPacket.toArray(brand)); + brand.release(); + }, 50, TimeUnit.MILLISECONDS); + } +} diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 911b24d..2c72c5a 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -7,6 +7,8 @@ UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht. UNKNOWN_TEAM=§cDieses Team gibt es nicht. INVALID_TIME=§cUngültige Zeitangabe. +STEAMWAR_BRAND={0}{1} §r<- §eSteam§8War.de §7({2}) §r<- §e{3} §7({4})§r + #ModLoader blocker MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten. MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten. From ead209af0a68fdad987d7eb3ced147c7bed65823 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 28 Apr 2021 12:27:32 +0200 Subject: [PATCH 28/81] Reduce Brand Info --- src/de/steamwar/bungeecore/listeners/BrandListener.java | 3 +-- src/de/steamwar/messages/BungeeCore.properties | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/BrandListener.java b/src/de/steamwar/bungeecore/listeners/BrandListener.java index 313476e..b7bbe79 100644 --- a/src/de/steamwar/bungeecore/listeners/BrandListener.java +++ b/src/de/steamwar/bungeecore/listeners/BrandListener.java @@ -47,7 +47,6 @@ public class BrandListener extends BasicListener { BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> { ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); - SteamwarUser user = SteamwarUser.get(player); String channel = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand"; StringBuilder serverBrand = new StringBuilder(); @@ -55,7 +54,7 @@ public class BrandListener extends BasicListener { serverBrand.append((char) b); } - String brandString = Message.parse("STEAMWAR_BRAND", player, user.getUserGroup().getColorCode(), player.getName(), BungeeCore.get().getProxy().getName(), player.getServer().getInfo().getName(), serverBrand.substring(1)); + String brandString = Message.parse("STEAMWAR_BRAND", player, BungeeCore.get().getProxy().getName(), player.getServer().getInfo().getName(), serverBrand.substring(1)); ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); DefinedPacket.writeString(brandString, brand); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 2c72c5a..6b8e93c 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -7,7 +7,7 @@ UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht. UNKNOWN_TEAM=§cDieses Team gibt es nicht. INVALID_TIME=§cUngültige Zeitangabe. -STEAMWAR_BRAND={0}{1} §r<- §eSteam§8War.de §7({2}) §r<- §e{3} §7({4})§r +STEAMWAR_BRAND=§eSteam§8War.de §7({2}) §r<- §e{3} §7({4})§r #ModLoader blocker MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten. From a0f87e4916182b1ec1f1292cb1c82c93c342cccf Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 28 Apr 2021 12:28:10 +0200 Subject: [PATCH 29/81] Fix Params --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 6b8e93c..98f81c8 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -7,7 +7,7 @@ UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht. UNKNOWN_TEAM=§cDieses Team gibt es nicht. INVALID_TIME=§cUngültige Zeitangabe. -STEAMWAR_BRAND=§eSteam§8War.de §7({2}) §r<- §e{3} §7({4})§r +STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r #ModLoader blocker MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten. From 8567f920c4882a565b706a81b2e6ad03ebc93e5b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 10 May 2021 22:18:59 +0200 Subject: [PATCH 30/81] Fix BrandListener --- src/de/steamwar/bungeecore/listeners/BrandListener.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/BrandListener.java b/src/de/steamwar/bungeecore/listeners/BrandListener.java index b7bbe79..cbc16a4 100644 --- a/src/de/steamwar/bungeecore/listeners/BrandListener.java +++ b/src/de/steamwar/bungeecore/listeners/BrandListener.java @@ -21,7 +21,6 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -29,7 +28,6 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; -import net.md_5.bungee.protocol.packet.PluginMessage; import java.util.concurrent.TimeUnit; @@ -37,7 +35,7 @@ public class BrandListener extends BasicListener { @EventHandler public void onServerSwitch(PluginMessageEvent event) { - if(event.getTag().equals("minecraft:brand") || event.getTag().equals("MC|Brand")) { + if(!event.getTag().equals("minecraft:brand") || !event.getTag().equals("MC|Brand")) { return; } From ac08d7390b9458f316802c1328914400354477a7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 15 May 2021 19:29:56 +0200 Subject: [PATCH 31/81] See Security-Breach issue --- src/de/steamwar/bungeecore/commands/BauCommand.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 590ef93..c090a5b 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -24,6 +24,7 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; +import java.util.Collection; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; @@ -220,9 +221,10 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - Subserver server = Subserver.getSubserver(z); - if(server != null && server.getType() == Servertype.BAUSERVER && ((Bauserver)server).getOwner().equals(p.getUniqueId())) + Collection servers = Subserver.getAllServers(z); + if (!servers.isEmpty() && servers.stream().filter(server -> server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); + } } Message.send("BAU_DELMEMBER_DELETED", p); } From 83bcdd34bf9385da16ee4384bb6abf046e07c2c2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:08:25 +0200 Subject: [PATCH 32/81] rework in persistent bungeecore for said issue --- src/de/steamwar/bungeecore/commands/BauCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index c090a5b..8d63132 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,8 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - Collection servers = Subserver.getAllServers(z); - if (!servers.isEmpty() && servers.stream().filter(server -> server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().filter(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From d1b901be699b31fafc5a639d37eef981d244c4a7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:09:34 +0200 Subject: [PATCH 33/81] codestyle --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 8d63132..37ce439 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().filter(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER).anyMatch(server -> ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From 41a8ea316ff3749d6e18d6724767fb0e54445cae Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:10:25 +0200 Subject: [PATCH 34/81] me stupid --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 37ce439..04b33ff 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(z != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(p) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(z) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From fca4f736e8cb04bb4baf5a00d631526f2acad312 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 18:11:56 +0200 Subject: [PATCH 35/81] readability --- src/de/steamwar/bungeecore/commands/BauCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 04b33ff..3c0a364 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -218,11 +218,11 @@ public class BauCommand { } target.remove(); - ProxiedPlayer z = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); - if(z != null){ - Message.send("BAU_DELMEMBER_DELETED_TARGET", z, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(z) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { - z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); + ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); + if(toRemove != null){ + Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); + if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(toRemove) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } Message.send("BAU_DELMEMBER_DELETED", p); From 9874ab204edceeec1cb4afff4a4a0ad5e97075c2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:26:32 +0200 Subject: [PATCH 36/81] No changes on Persistent Bungeecore nescessary --- pom.xml | 1 + src/de/steamwar/bungeecore/commands/BauCommand.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbf2760..859b262 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ + clean verify -U src diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 3c0a364..2c79a26 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,8 @@ public class BauCommand { ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); if(toRemove != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); - if (Subserver.getServerList().stream().anyMatch(server -> server.onServer(toRemove) && server.getType() == Servertype.BAUSERVER && ((Bauserver) server).getOwner().equals(p.getUniqueId()))) { + Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo()); + if (currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From c0366c4daa0c577c062bb9e5a6bef55ee6bb1884 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:30:09 +0200 Subject: [PATCH 37/81] optimized imports --- pom.xml | 1 - src/de/steamwar/bungeecore/commands/BauCommand.java | 1 - 2 files changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index 859b262..dbf2760 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ - clean verify -U src diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 2c79a26..b736870 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -24,7 +24,6 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; -import java.util.Collection; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; From d1cb167039cee7d9a39e2f72c5f5b0a632a56117 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 18 May 2021 19:31:49 +0200 Subject: [PATCH 38/81] now currentServer != null --- src/de/steamwar/bungeecore/commands/BauCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index b736870..43944d7 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -221,7 +221,7 @@ public class BauCommand { if(toRemove != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo()); - if (currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { + if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) { toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER)); } } From 5715ea391c2998f69d5208ffcbe7aab19f61d8fe Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 24 May 2021 09:37:14 +0200 Subject: [PATCH 39/81] Fix disbanding teams Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 16c9873..af3a84b 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -248,14 +248,15 @@ public class TeamCommand extends BasicCommand { if(notInTeam(player, user)) return; - if(team.size() > 1 && user.isLeader() && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){ + int teamSize = team.size(); + if(teamSize > 1 && user.isLeader() && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){ Message.send("TEAM_OTHER_LEADER_REQUIRED", player); return; } user.setTeam(0); - if(user.isLeader() && team.size() > 0){ + if(teamSize == 1){ team.disband(user); } From 0e0a3606cef9ac5c4021d348a1cee0ee2cd15e3f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 28 May 2021 16:48:29 +0200 Subject: [PATCH 40/81] Hotfix team deletion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/Team.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 7eee1e2..b5c083b 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -155,7 +155,7 @@ public class Team { public void disband(SteamwarUser user){ user.setLeader(false); - SQL.update("UPDATE Team SET TeamDeleted = 1", teamId); + SQL.update("UPDATE Team SET TeamDeleted = 1 WHERE TeamID = ?", teamId); teamCache.remove(this); } From 72ee7c19c8966973a67f5b1c8e940fb8d893c322 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 20 Jun 2021 17:46:13 +0200 Subject: [PATCH 41/81] Untested remote start system Signed-off-by: Lixfel --- .../steamwar/bungeecore/LoadEvaluation.java | 92 +++++++++++++++++++ .../steamwar/bungeecore/SubserverSystem.java | 29 +++++- 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/bungeecore/LoadEvaluation.java diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java new file mode 100644 index 0000000..d1785af --- /dev/null +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -0,0 +1,92 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 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; + +import java.io.*; + +public class LoadEvaluation { + private LoadEvaluation(){} + + private static final File meminfo = new File("/proc/meminfo"); + + public static double getRamPercentage() { + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(meminfo)))) { + String memTotal = bufferedReader.readLine().replaceAll(" +", " "); + bufferedReader.readLine(); + String memAvailable = bufferedReader.readLine().replaceAll(" +", " "); + + long memTotalLong = getNumber(memTotal); + long memAvailableLong = getNumber(memAvailable); + return (memTotalLong - memAvailableLong) / (double) memTotalLong; + } catch (IOException e) { + return 1D; + } + } + + public static double getRemoteRamPercentage() { + try { + Process process = new ProcessBuilder("ssh lx cat /proc/meminfo").start(); + process.waitFor(); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String memTotal = bufferedReader.readLine().replaceAll(" +", " "); + bufferedReader.readLine(); + String memAvailable = bufferedReader.readLine().replaceAll(" +", " "); + + long memTotalLong = getNumber(memTotal); + long memAvailableLong = getNumber(memAvailable); + return (memTotalLong - memAvailableLong) / (double) memTotalLong; + } catch (IOException e) { + return 1D; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return 1D; + } + } + + public static double getCPULoad() { + try { + Process process = new ProcessBuilder("cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + process.waitFor(); + return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()); + } catch (IOException e) { + return 1D; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return 1D; + } + } + + public static double getRemoteCPULoad() { + try { + Process process = new ProcessBuilder("ssh lx cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + process.waitFor(); + return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()); + } catch (IOException e) { + return 1D; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return 1D; + } + } + + private static long getNumber(String s) { + return Long.parseLong(s.split(" ")[1]); + } +} diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 2812eb3..3498008 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -118,8 +118,10 @@ public class SubserverSystem { Thread.currentThread().interrupt(); } + File directory = new File(SERVER_PATH, modus.getFolder()); List cmd = serverStartCommand( modus.serverJar(), + directory, worldDir, mapName, port, @@ -135,7 +137,7 @@ public class SubserverSystem { //Start server ProcessBuilder process = new ProcessBuilder(cmd); - process.directory(new File(SERVER_PATH, modus.getFolder())); + process.directory(directory); String finalMapName = mapName; if(eventFightID == -1) @@ -185,8 +187,10 @@ public class SubserverSystem { copyBauweltIfRequired(p, prototype, worldFolder + worldName); int port = freePort(4000); + File directory = new File(SERVER_PATH, serverName); List cmd = serverStartCommand( serverJar, + directory, worldDir, worldName, port, @@ -195,7 +199,7 @@ public class SubserverSystem { //Start server ProcessBuilder process = new ProcessBuilder(cmd); - process.directory(new File(SERVER_PATH, serverName)); + process.directory(directory); new Bauserver(user.getUserName() + "s Bau", owner, port, process, () -> {}).sendPlayer(p); } @@ -231,9 +235,20 @@ public class SubserverSystem { new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName())); } - private static List serverStartCommand(String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams){ + private static List serverStartCommand(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams){ List cmd = new ArrayList<>(); boolean jdk11 = serverJar.contains("1.15.2"); + + if(!steamwarStartAvailible() && lixfelStartAvailible()){ + cmd.add("ssh"); + cmd.add("-L"); + cmd.add(port + ":localhost:" + port); + cmd.add("lx"); + cmd.add("cd"); + cmd.add(directory.getPath()); + cmd.add(";"); + } + if(jdk11) cmd.add("/usr/lib/jvm/java-11-openjdk-amd64/bin/java"); else @@ -259,6 +274,14 @@ public class SubserverSystem { return cmd; } + private static boolean steamwarStartAvailible(){ + return LoadEvaluation.getCPULoad() < 0.8 && LoadEvaluation.getRamPercentage() < 0.8; + } + + private static boolean lixfelStartAvailible(){ + return LoadEvaluation.getRemoteCPULoad() < 0.8 && LoadEvaluation.getRemoteRamPercentage() < 0.8; + } + private static boolean bauRunning(ProxiedPlayer p, UUID owner){ for(Subserver subserver : Subserver.getServerList()){ if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)){ From 85e129ada651dd376e90d9c1474ba325dab1fe2c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 18:03:41 +0200 Subject: [PATCH 42/81] Fix LoadEvaluation Fix naming --- src/de/steamwar/bungeecore/LoadEvaluation.java | 8 ++++---- src/de/steamwar/bungeecore/SubserverSystem.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index d1785af..d4acab0 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -40,9 +40,9 @@ public class LoadEvaluation { } } - public static double getRemoteRamPercentage() { + public static double getRemoteRamPercentage(String remote) { try { - Process process = new ProcessBuilder("ssh lx cat /proc/meminfo").start(); + Process process = new ProcessBuilder("ssh " + remote + " cat /proc/meminfo").start(); process.waitFor(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String memTotal = bufferedReader.readLine().replaceAll(" +", " "); @@ -73,9 +73,9 @@ public class LoadEvaluation { } } - public static double getRemoteCPULoad() { + public static double getRemoteCPULoad(String remote) { try { - Process process = new ProcessBuilder("ssh lx cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + Process process = new ProcessBuilder("ssh " + remote + " cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); process.waitFor(); return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()); } catch (IOException e) { diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 3498008..d002d2c 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -239,7 +239,7 @@ public class SubserverSystem { List cmd = new ArrayList<>(); boolean jdk11 = serverJar.contains("1.15.2"); - if(!steamwarStartAvailible() && lixfelStartAvailible()){ + if(!steamwarStartAvailable() && lixfelStartAvailable()){ cmd.add("ssh"); cmd.add("-L"); cmd.add(port + ":localhost:" + port); @@ -274,12 +274,12 @@ public class SubserverSystem { return cmd; } - private static boolean steamwarStartAvailible(){ + private static boolean steamwarStartAvailable(){ return LoadEvaluation.getCPULoad() < 0.8 && LoadEvaluation.getRamPercentage() < 0.8; } - private static boolean lixfelStartAvailible(){ - return LoadEvaluation.getRemoteCPULoad() < 0.8 && LoadEvaluation.getRemoteRamPercentage() < 0.8; + private static boolean lixfelStartAvailable(){ + return LoadEvaluation.getRemoteCPULoad("lx") < 0.8 && LoadEvaluation.getRemoteRamPercentage("lx") < 0.8; } private static boolean bauRunning(ProxiedPlayer p, UUID owner){ From 5aa973d3889cd20689ab58be6e1bdf459a843315 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 19:02:05 +0200 Subject: [PATCH 43/81] Fix LoadEvaluation --- src/de/steamwar/bungeecore/LoadEvaluation.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index d4acab0..0732d75 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -42,7 +42,9 @@ public class LoadEvaluation { public static double getRemoteRamPercentage(String remote) { try { - Process process = new ProcessBuilder("ssh " + remote + " cat /proc/meminfo").start(); + // Attention: + // memInfo.sh needs to contain: cat /proc/meminfo + Process process = new ProcessBuilder("ssh", remote, "\"./memInfo.sh\"").start(); process.waitFor(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String memTotal = bufferedReader.readLine().replaceAll(" +", " "); @@ -64,7 +66,7 @@ public class LoadEvaluation { try { Process process = new ProcessBuilder("cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); process.waitFor(); - return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()); + return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0; } catch (IOException e) { return 1D; } catch (InterruptedException e) { @@ -75,9 +77,11 @@ public class LoadEvaluation { public static double getRemoteCPULoad(String remote) { try { - Process process = new ProcessBuilder("ssh " + remote + " cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + // Attention: + // cpuLoad.sh needs to contain: cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{printf "%.2f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' + Process process = new ProcessBuilder("ssh", remote, "\"./cpuLoad.sh\"").start(); process.waitFor(); - return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()); + return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0; } catch (IOException e) { return 1D; } catch (InterruptedException e) { From f6a4c343a5d4d156e55b7c13dbf534f77ec7e4b0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 21:36:58 +0200 Subject: [PATCH 44/81] Add StatCommand Fix LoadEvaluation --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../steamwar/bungeecore/LoadEvaluation.java | 4 +- .../bungeecore/commands/StatCommand.java | 48 +++++++++++++++++++ .../steamwar/messages/BungeeCore.properties | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/bungeecore/commands/StatCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 2344d56..50cb205 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 StatCommand(); if(!EVENT_MODE){ new WebregisterCommand(); diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index 0732d75..b1f7a0d 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -64,12 +64,14 @@ public class LoadEvaluation { public static double getCPULoad() { try { - Process process = new ProcessBuilder("cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + Process process = new ProcessBuilder("bash", "-c", "cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); process.waitFor(); return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0; } catch (IOException e) { + e.printStackTrace(); return 1D; } catch (InterruptedException e) { + e.printStackTrace(); Thread.currentThread().interrupt(); return 1D; } diff --git a/src/de/steamwar/bungeecore/commands/StatCommand.java b/src/de/steamwar/bungeecore/commands/StatCommand.java new file mode 100644 index 0000000..e87eabd --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/StatCommand.java @@ -0,0 +1,48 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.LoadEvaluation; +import de.steamwar.bungeecore.Message; +import net.md_5.bungee.api.CommandSender; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class StatCommand extends BasicCommand { + + public StatCommand() { + super("stat", "bungeecore.softreload","stats"); + } + + @Override + public void execute(CommandSender sender, String[] args) { + try { + Process process = new ProcessBuilder("ps", "x").start(); + process.waitFor(); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + Map serverCounts = new HashMap<>(); + bufferedReader.lines().forEach(s -> { + if (!s.contains("--port") || s.contains("grep")) { + return; + } + String server = "SW"; + if (s.contains("ssh -L")) { + server = s.substring(s.indexOf("ssh -L") + 6).split(" ")[2]; + } + serverCounts.put(server, serverCounts.computeIfAbsent(server, s1 -> 0) + 1); + }); + serverCounts.forEach((s, integer) -> { + if (s.equals("SW")) { + Message.send("STAT_SERVER", sender, s, LoadEvaluation.getRamPercentage(), LoadEvaluation.getCPULoad(), integer); + } else { + Message.send("STAT_SERVER", sender, s.toUpperCase(), LoadEvaluation.getRemoteRamPercentage(s), LoadEvaluation.getRemoteCPULoad(s), integer); + } + }); + } catch (Exception e) { + throw new SecurityException(e.getMessage(), e); + } + } + +} diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index a92b7c5..025f2e4 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -104,6 +104,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War #Various commands ALERT=§f{0} +STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3} #Ban&Mute-Command BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4} From 4120e989ce87c690903fe0782d01ccc80823cf4d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 21:38:12 +0200 Subject: [PATCH 45/81] Add StatCommand Fix LoadEvaluation --- src/de/steamwar/bungeecore/LoadEvaluation.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index b1f7a0d..59fda6c 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -68,10 +68,8 @@ public class LoadEvaluation { process.waitFor(); return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0; } catch (IOException e) { - e.printStackTrace(); return 1D; } catch (InterruptedException e) { - e.printStackTrace(); Thread.currentThread().interrupt(); return 1D; } From 5959f8eb6f7ea1490a56cc271b47cfb0bb02e383 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 21:38:45 +0200 Subject: [PATCH 46/81] Add StatCommand Fix LoadEvaluation --- .../bungeecore/commands/StatCommand.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/StatCommand.java b/src/de/steamwar/bungeecore/commands/StatCommand.java index e87eabd..5422e63 100644 --- a/src/de/steamwar/bungeecore/commands/StatCommand.java +++ b/src/de/steamwar/bungeecore/commands/StatCommand.java @@ -1,3 +1,22 @@ +/* + 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.LoadEvaluation; @@ -6,14 +25,13 @@ import net.md_5.bungee.api.CommandSender; import java.io.BufferedReader; import java.io.InputStreamReader; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class StatCommand extends BasicCommand { public StatCommand() { - super("stat", "bungeecore.softreload","stats"); + super("stat", "bungeecore.softreload", "stats"); } @Override From 5d34cf323f67a1652e80e9a0b594457fc5466bf3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 21:40:41 +0200 Subject: [PATCH 47/81] Fix LoadEvaluation --- src/de/steamwar/bungeecore/LoadEvaluation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index 0732d75..59fda6c 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -64,7 +64,7 @@ public class LoadEvaluation { public static double getCPULoad() { try { - Process process = new ProcessBuilder("cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); + Process process = new ProcessBuilder("bash", "-c", "cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start(); process.waitFor(); return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0; } catch (IOException e) { From 4de062176a5caffcdb10315339be688a201d73db Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 21 Jun 2021 16:52:39 +0200 Subject: [PATCH 48/81] Better Tablist footer --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 8 +++----- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index c0b12fd..c25be00 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -131,15 +131,13 @@ public class TablistManager extends BasicListener { } private String calcHeader(ProxiedPlayer player){ - int phase = (seconds % 16) / 4; + int phase = (seconds % 16) / 3; switch(phase){ case 0: - return Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size()); + return Message.parse("TABLIST_PHASE_0", player); case 1: return Message.parse("TABLIST_PHASE_1", player); case 2: - return Message.parse("TABLIST_PHASE_2", player); - case 3: default: return Message.parse("TABLIST_PHASE_DEFAULT", player); } @@ -161,7 +159,7 @@ public class TablistManager extends BasicListener { try { ServerInfo currentServer = player.getServer().getInfo(); setHeader(calcHeader(player)); - setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms"); + setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); setSize(size, 20); int i = 0; diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index a92b7c5..8cee5b1 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -475,10 +475,10 @@ POLL_ANWSER=§7{0} POLL_ANWSER_HOVER=§e{0} §ewählen #TablistManager -TABLIST_PHASE_0=§8Spieler online: §e{0} -TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de -TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord +TABLIST_PHASE_0=§8Teamspeak: §eSteam§8War.de +TABLIST_PHASE_1=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de +TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_BAU=Bau #EventStarter From 2fc19bc92d1d67e766020ed3a4ed76e960edc613 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 21 Jun 2021 22:02:53 +0200 Subject: [PATCH 49/81] Add Node3 --- src/de/steamwar/bungeecore/SubserverSystem.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index d002d2c..e35a134 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -239,7 +239,8 @@ public class SubserverSystem { List cmd = new ArrayList<>(); boolean jdk11 = serverJar.contains("1.15.2"); - if(!steamwarStartAvailable() && lixfelStartAvailable()){ + boolean notSteamwarStart = !steamwarStartAvailable(); + if (notSteamwarStart && remoteStartAvailable("lx")) { cmd.add("ssh"); cmd.add("-L"); cmd.add(port + ":localhost:" + port); @@ -247,6 +248,14 @@ public class SubserverSystem { cmd.add("cd"); cmd.add(directory.getPath()); cmd.add(";"); + } else if (notSteamwarStart && remoteStartAvailable("az")) { + cmd.add("ssh"); + cmd.add("-L"); + cmd.add(port + ":localhost:" + port); + cmd.add("az"); + cmd.add("cd"); + cmd.add(directory.getPath()); + cmd.add(";"); } if(jdk11) @@ -278,8 +287,8 @@ public class SubserverSystem { return LoadEvaluation.getCPULoad() < 0.8 && LoadEvaluation.getRamPercentage() < 0.8; } - private static boolean lixfelStartAvailable(){ - return LoadEvaluation.getRemoteCPULoad("lx") < 0.8 && LoadEvaluation.getRemoteRamPercentage("lx") < 0.8; + private static boolean remoteStartAvailable(String remote) { + return LoadEvaluation.getRemoteCPULoad(remote) < 0.8 && LoadEvaluation.getRemoteRamPercentage(remote) < 0.8; } private static boolean bauRunning(ProxiedPlayer p, UUID owner){ From ed10fbd786b481c958050752f1fa0d0fbdb4ca88 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 21 Jun 2021 22:07:38 +0200 Subject: [PATCH 50/81] Add Node3 --- .../steamwar/bungeecore/SubserverSystem.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index e35a134..b44b331 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -239,24 +239,25 @@ public class SubserverSystem { List cmd = new ArrayList<>(); boolean jdk11 = serverJar.contains("1.15.2"); - boolean notSteamwarStart = !steamwarStartAvailable(); - if (notSteamwarStart && remoteStartAvailable("lx")) { + boolean fallback = false; + if (!steamwarStartAvailable()) { cmd.add("ssh"); cmd.add("-L"); cmd.add(port + ":localhost:" + port); - cmd.add("lx"); - cmd.add("cd"); - cmd.add(directory.getPath()); - cmd.add(";"); - } else if (notSteamwarStart && remoteStartAvailable("az")) { - cmd.add("ssh"); - cmd.add("-L"); - cmd.add(port + ":localhost:" + port); - cmd.add("az"); + if (remoteStartAvailable("lx")) { + cmd.add("lx"); + } else if (remoteStartAvailable("az")) { + cmd.add("az"); + } else { + fallback = true; + } cmd.add("cd"); cmd.add(directory.getPath()); cmd.add(";"); } + if (fallback) { + cmd.clear(); + } if(jdk11) cmd.add("/usr/lib/jvm/java-11-openjdk-amd64/bin/java"); From 66899e8df17a7ebafef1ff7cecf386ee0a7d834a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 22 Jun 2021 12:21:50 +0200 Subject: [PATCH 51/81] Update Tablist slim Mode! --- .../bungeecore/listeners/TablistManager.java | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index c25be00..6f6fe4f 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -41,6 +41,7 @@ import java.io.File; import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; public class TablistManager extends BasicListener { @@ -81,24 +82,19 @@ public class TablistManager extends BasicListener { private synchronized void updateCustomTablist(){ //Calculate server-player-map playerMap.clear(); - for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ + for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { Server pserver = player.getServer(); - if(pserver == null) //Happens temporarily + if (pserver == null) //Happens temporarily continue; ServerInfo server = pserver.getInfo(); String serverName = server.getName(); Subserver subserver = Subserver.getSubserver(server); - List players; - if(subserver != null && subserver.getType() == Servertype.BAUSERVER){ - players = playerMap.getOrDefault("Bau", new ArrayList<>()); - players.add(player); - playerMap.putIfAbsent("Bau", players); - }else{ - players = playerMap.getOrDefault(serverName, new ArrayList<>()); - players.add(player); - playerMap.putIfAbsent(serverName, players); + 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()))); @@ -155,13 +151,17 @@ public class TablistManager extends BasicListener { } private void refresh(){ + ServerInfo currentServer = player.getServer().getInfo(); + setHeader(calcHeader(player)); + setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); + setSize(size, 20); + + if (size >= 5) { + refreshSlim(currentServer); + return; + } try { - ServerInfo currentServer = player.getServer().getInfo(); - setHeader(calcHeader(player)); - setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); - setSize(size, 20); - int i = 0; for (String server : playerMap.navigableKeySet()) { if (i > 0){ @@ -189,6 +189,54 @@ public class TablistManager extends BasicListener { } } + private void refreshSlim(ServerInfo currentServer) { + try { + int i = 0; + boolean spacer = true; + for (String server : playerMap.navigableKeySet()) { + if (i > 0 && spacer) { + setSlot(i%20, i/20, darkGray, "", 1000); + i++; + } + spacer = true; + List players = playerMap.get(server) + .stream() + .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member) + .collect(Collectors.toList()); + 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); + } + int increment = playerMap.get(server).size() - players.size(); + if (players.isEmpty()) { + server += " §7(" + increment + ")"; + spacer = false; + } else if (increment != 0) { + server += " §7(+" + increment + ")"; + } + + 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), (sameServer ? 1 : 500)); + i++; + } + } + + while (i < size*20){ + setSlot(i%20, i/20, darkGray, "", 1000); + i++; + } + }catch(IndexOutOfBoundsException | NullPointerException e){ + //Ignore IndexOutOfBoundsException + //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting + } + } + private String getTablistName(ProxiedPlayer p, boolean sameServer) { Subserver server = Subserver.getSubserver(p); if(server != null){ From 8705e19aec7f04a1ead6706e37907173afcb0074 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Jun 2021 17:41:05 +0200 Subject: [PATCH 52/81] Update Tablist slim Mode! --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 7 ++++--- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 6f6fe4f..6a1d965 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -130,9 +130,9 @@ public class TablistManager extends BasicListener { int phase = (seconds % 16) / 3; switch(phase){ case 0: - return Message.parse("TABLIST_PHASE_0", player); - case 1: return Message.parse("TABLIST_PHASE_1", player); + case 1: + return Message.parse("TABLIST_PHASE_2", player); case 2: default: return Message.parse("TABLIST_PHASE_DEFAULT", player); @@ -153,7 +153,8 @@ public class TablistManager extends BasicListener { private void refresh(){ ServerInfo currentServer = player.getServer().getInfo(); setHeader(calcHeader(player)); - setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); + // TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} + setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms §eSpieler§8: §7" + ProxyServer.getInstance().getPlayers().size()); setSize(size, 20); if (size >= 5) { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 8cee5b1..a92b7c5 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -475,10 +475,10 @@ POLL_ANWSER=§7{0} POLL_ANWSER_HOVER=§e{0} §ewählen #TablistManager -TABLIST_PHASE_0=§8Teamspeak: §eSteam§8War.de -TABLIST_PHASE_1=§8Discord: §8https://§eSteam§8War.de/discord +TABLIST_PHASE_0=§8Spieler online: §e{0} +TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de +TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de -TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_BAU=Bau #EventStarter From 70359e1c9e9935d666130c695cb24abf3d01f04c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Jun 2021 19:42:54 +0200 Subject: [PATCH 53/81] Fix CPU usage threshold --- src/de/steamwar/bungeecore/SubserverSystem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index b44b331..b4ffbc4 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -285,11 +285,11 @@ public class SubserverSystem { } private static boolean steamwarStartAvailable(){ - return LoadEvaluation.getCPULoad() < 0.8 && LoadEvaluation.getRamPercentage() < 0.8; + return LoadEvaluation.getCPULoad() < 0.7 && LoadEvaluation.getRamPercentage() < 0.8; } private static boolean remoteStartAvailable(String remote) { - return LoadEvaluation.getRemoteCPULoad(remote) < 0.8 && LoadEvaluation.getRemoteRamPercentage(remote) < 0.8; + return LoadEvaluation.getRemoteCPULoad(remote) < 0.7 && LoadEvaluation.getRemoteRamPercentage(remote) < 0.8; } private static boolean bauRunning(ProxiedPlayer p, UUID owner){ From d11b4ba9ca56b7edc71c8238980aefd3a1cbd58a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 10:47:17 +0200 Subject: [PATCH 54/81] 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 55/81] 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 56/81] 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 57/81] 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 58/81] 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 59/81] 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 60/81] 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 61/81] 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 62/81] 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 c925aa41aca641a64aec47cab38936053004c338 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Jun 2021 18:28:21 +0200 Subject: [PATCH 63/81] Fix SubserverSystem concurrency and Thread safety --- src/de/steamwar/bungeecore/SubserverSystem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index b4ffbc4..d5e85b0 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -89,7 +89,7 @@ public class SubserverSystem { * @return * The new started subserver. */ - public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, int prepareSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){ + public static synchronized Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, int prepareSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){ //Generate missing parameters int port = freePort(FIRST_ARENA_PORT); @@ -179,7 +179,7 @@ public class SubserverSystem { startArena(m, map, -1, checkSchemId, prepareSchemId, p.getName() + "s Bau", p.getName(), p.getUniqueId(), null, false).sendPlayer(p); } - private static void sendToBau(ProxiedPlayer p, UUID owner, String prototype, String worldFolder, String serverJar, String worldDir, String worldName, String xmx, String serverName){ + private static synchronized void sendToBau(ProxiedPlayer p, UUID owner, String prototype, String worldFolder, String serverJar, String worldDir, String worldName, String xmx, String serverName){ if(bauRunning(p, owner)) return; From fa70a46b64e12c22c0e8b42115b81fbe9e80a455 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 08:09:23 +0200 Subject: [PATCH 64/81] Remove useless checks --- src/de/steamwar/bungeecore/commands/StatCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/StatCommand.java b/src/de/steamwar/bungeecore/commands/StatCommand.java index 5422e63..506ecab 100644 --- a/src/de/steamwar/bungeecore/commands/StatCommand.java +++ b/src/de/steamwar/bungeecore/commands/StatCommand.java @@ -42,7 +42,7 @@ public class StatCommand extends BasicCommand { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); Map serverCounts = new HashMap<>(); bufferedReader.lines().forEach(s -> { - if (!s.contains("--port") || s.contains("grep")) { + if (!s.contains("--port")) { return; } String server = "SW"; From e9297fab4741d66536e29722c041c8234f5ac891 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 10:22:55 +0200 Subject: [PATCH 65/81] Add ListCommand --- 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 ad054d2b06b476c72d990c842a4d42af83b221e7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 10:23:44 +0200 Subject: [PATCH 66/81] 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(", "))); - } - } -} From c253709f4ac074bf5f2413f6b8e011fbe5070920 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 10:27:59 +0200 Subject: [PATCH 67/81] Update ListCommand to multilang --- src/de/steamwar/bungeecore/commands/ListCommand.java | 6 +++++- src/de/steamwar/messages/BungeeCore.properties | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/ListCommand.java b/src/de/steamwar/bungeecore/commands/ListCommand.java index 6ab37f0..b5d2f2d 100644 --- a/src/de/steamwar/bungeecore/commands/ListCommand.java +++ b/src/de/steamwar/bungeecore/commands/ListCommand.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.commands; +import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; import net.md_5.bungee.api.CommandSender; @@ -65,7 +66,10 @@ public class ListCommand extends BasicCommand { 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(", "))); + if (server.equals("Bau")) { + server = Message.parse("TABLIST_BAU", commandSender); + } + Message.send("LIST_COMMAND", commandSender, server, playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", "))); } } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index a92b7c5..dd74cdb 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -480,6 +480,7 @@ TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de TABLIST_BAU=Bau +LIST_COMMAND=§e{0}§8: §7{1} #EventStarter EVENT_FIGHT_BROADCAST=§7Hier §eklicken §7für den Kampf §{0}{1} §8vs §{2}{3} From c750231b144a1bc7bef675766105cae7b1251e41 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Jun 2021 11:13:01 +0200 Subject: [PATCH 68/81] Add + to Local Chat --- .../bungeecore/listeners/ChatListener.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index b41ea78..9fd8061 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -19,10 +19,7 @@ package de.steamwar.bungeecore.listeners; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.Servertype; -import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.commands.BauCommand; import de.steamwar.bungeecore.commands.TpCommand; import de.steamwar.bungeecore.comms.packets.PingPacket; @@ -51,6 +48,8 @@ public class ChatListener extends BasicListener { sanitize7(e); if(e.getMessage().startsWith("/")) onCommand(e); + else if(e.getMessage().startsWith("+")) + onPlusMessage(e); else onChat(e); } @@ -116,6 +115,21 @@ public class ChatListener extends BasicListener { scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_4", sender)), 12, TimeUnit.SECONDS); } + private void onPlusMessage(ChatEvent e) { + ProxiedPlayer p = (ProxiedPlayer) e.getSender(); + Subserver subserver = Subserver.getSubserver(p); + if(/*subserver instanceof Bauserver*/true) { + String[] smolArgs = e.getMessage().split(" "); + String[] args = new String[smolArgs.length + 1]; + smolArgs[0] = smolArgs[0].substring(1); + args[0] = ""; + System.arraycopy(smolArgs, 0, args, 1, smolArgs.length); + localChat(e, args); + } else { + onChat(e); + } + } + private void onChat(ChatEvent e){ if(e.getSender() instanceof ProxiedPlayer){ ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); From 955cb8863a0e57259e490186da07c3fa0aed2993 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Jun 2021 11:14:13 +0200 Subject: [PATCH 69/81] Remove Debug --- 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 9fd8061..aeffc19 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -118,7 +118,7 @@ public class ChatListener extends BasicListener { private void onPlusMessage(ChatEvent e) { ProxiedPlayer p = (ProxiedPlayer) e.getSender(); Subserver subserver = Subserver.getSubserver(p); - if(/*subserver instanceof Bauserver*/true) { + if(subserver instanceof Bauserver) { String[] smolArgs = e.getMessage().split(" "); String[] args = new String[smolArgs.length + 1]; smolArgs[0] = smolArgs[0].substring(1); From 906be50771cd2ef488433d9a17ef596b4b048d3f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 27 Jun 2021 08:10:15 +0200 Subject: [PATCH 70/81] Compress ChatListener.onPlusMessage --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index aeffc19..12903c0 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -119,9 +119,8 @@ public class ChatListener extends BasicListener { ProxiedPlayer p = (ProxiedPlayer) e.getSender(); Subserver subserver = Subserver.getSubserver(p); if(subserver instanceof Bauserver) { - String[] smolArgs = e.getMessage().split(" "); + String[] smolArgs = e.getMessage().substring(1).split(" "); String[] args = new String[smolArgs.length + 1]; - smolArgs[0] = smolArgs[0].substring(1); args[0] = ""; System.arraycopy(smolArgs, 0, args, 1, smolArgs.length); localChat(e, args); From 5637311be5b0e1824c31919f7b12c9b704a1864a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 28 Jun 2021 17:06:00 +0200 Subject: [PATCH 71/81] Hotfix Tablist --- .../bungeecore/listeners/TablistManager.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index fd386a9..fd31ce2 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -69,15 +69,11 @@ public class TablistManager extends BasicListener { } } - private void calculateSize(){ + private void calculateSize() { size = -1; - for(Map.Entry> server : playerMap.entrySet()) - size += 2 + server.getValue().size(); - - size = (size+19)/20; - - if(size > 5) - size = 5; + size += playerMap.size() * 2 + ProxyServer.getInstance().getPlayers().size(); + size = (size + 19) / 20 + 1; + if(size > 5) size = 5; } private synchronized void updateCustomTablist(){ @@ -224,8 +220,6 @@ public class TablistManager extends BasicListener { i = update(currentServer, players, i); } - // Shrink Down - setSize(Math.min((i + 19) / 20, 4), 20); finish(i); }catch(IndexOutOfBoundsException | NullPointerException e){ //Ignore IndexOutOfBoundsException From 64c8af3064c5c568567e34ca583eb86b6b54bf4c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 28 Jun 2021 17:27:29 +0200 Subject: [PATCH 72/81] Fix TablistManager --- 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 fd31ce2..d69a1e8 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -72,7 +72,7 @@ public class TablistManager extends BasicListener { private void calculateSize() { size = -1; size += playerMap.size() * 2 + ProxyServer.getInstance().getPlayers().size(); - size = (size + 19) / 20 + 1; + size = (size + 19) / 20; if(size > 5) size = 5; } From 47711b746ea4c15e2c0e5c62b0fd7afcc319d9d0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Jul 2021 22:04:56 +0200 Subject: [PATCH 73/81] Add DevCommand --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/DevCommand.java | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/de/steamwar/bungeecore/commands/DevCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 2344d56..fe19b80 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -108,6 +108,7 @@ public class BungeeCore extends Plugin { new DenyCommand("watchcat", "wc"); new TeamCommand(); new ServerTeamchatCommand(); + new DevCommand(); new EventCommand(); new EventreloadCommand(); new EventRescheduleCommand(); diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java new file mode 100644 index 0000000..c266520 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/DevCommand.java @@ -0,0 +1,86 @@ +/* + * 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 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 java.io.File; +import java.net.InetSocketAddress; +import java.util.Arrays; +import java.util.Collections; +import java.util.stream.Collectors; + +public class DevCommand extends BasicCommand { + + private final File DevServerDir = new File("/configs/DevServer"); + + public DevCommand() { + super("dev", ""); + } + + @Override + public void execute(CommandSender sender, String[] args) { + if (!(sender instanceof ProxiedPlayer)) { + return; + } + String[] devSever = DevServerDir.list(); + if (devSever == null || devSever.length == 0) { + sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar."); + } else if (devSever.length == 1) { + String[] server = devSever[0].split("\\."); + sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); + } else { + if (args.length != 0) { + for (String s : devSever) { + String[] server = s.split("\\."); + if (args[0].equals(server[0])) { + sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); + return; + } + } + } + sender.sendMessage("§eSteam§8War§8» §cUnbekannter DevServer."); + } + } + + private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) { + InetSocketAddress address = new InetSocketAddress("127.0.0.1", port); + ServerInfo serverInfo = ProxyServer.getInstance().constructServerInfo("Dev-" + name, address, "SteamWar.de - Subserver", false); + proxiedPlayer.connect(serverInfo); + } + + @Override + public Iterable onTabComplete(CommandSender sender, String[] args) { + if (!(sender instanceof ProxiedPlayer)) { + return Collections.emptyList(); + } + String[] devSever = DevServerDir.list(); + if (devSever == null) { + return Collections.emptyList(); + } + if (args.length > 1) { + return Collections.emptyList(); + } + return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).collect(Collectors.toList()); + } +} From b16b258ba2659b902b0ed8a05c728209c7c6962b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Jul 2021 22:38:44 +0200 Subject: [PATCH 74/81] Add DevCommand --- .../bungeecore/commands/DevCommand.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java index c266520..baba06d 100644 --- a/src/de/steamwar/bungeecore/commands/DevCommand.java +++ b/src/de/steamwar/bungeecore/commands/DevCommand.java @@ -28,6 +28,7 @@ import java.io.File; import java.net.InetSocketAddress; import java.util.Arrays; import java.util.Collections; +import java.util.function.Predicate; import java.util.stream.Collectors; public class DevCommand extends BasicCommand { @@ -50,19 +51,25 @@ public class DevCommand extends BasicCommand { String[] server = devSever[0].split("\\."); sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); } else { - if (args.length != 0) { - for (String s : devSever) { - String[] server = s.split("\\."); - if (args[0].equals(server[0])) { - sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); - return; - } - } + if (args.length == 0) { + send(devSever, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> sender.sendMessage("§eSteam§8War§8» §cBitte gib einen DevServer an.")); + } else { + send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar.")); } - sender.sendMessage("§eSteam§8War§8» §cUnbekannter DevServer."); } } + private void send(String[] devServer, ProxiedPlayer sender, Predicate test, Runnable error) { + for (String s : devServer) { + String[] server = s.split("\\."); + if (test.test(server[0])) { + sendToServer(sender, server[0], Integer.parseInt(server[1])); + break; + } + } + error.run(); + } + private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) { InetSocketAddress address = new InetSocketAddress("127.0.0.1", port); ServerInfo serverInfo = ProxyServer.getInstance().constructServerInfo("Dev-" + name, address, "SteamWar.de - Subserver", false); @@ -81,6 +88,9 @@ public class DevCommand extends BasicCommand { if (args.length > 1) { return Collections.emptyList(); } - return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).collect(Collectors.toList()); + return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).filter(s -> { + if (args.length == 0) return true; + return s.startsWith(args[0]); + }).collect(Collectors.toList()); } } From 1879f74eadfa85618fb73d265b602fbd162436a6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Jul 2021 22:43:15 +0200 Subject: [PATCH 75/81] Add DevCommand --- src/de/steamwar/bungeecore/commands/DevCommand.java | 7 ++++--- src/de/steamwar/messages/BungeeCore.properties | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java index baba06d..5daa909 100644 --- a/src/de/steamwar/bungeecore/commands/DevCommand.java +++ b/src/de/steamwar/bungeecore/commands/DevCommand.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.commands; +import de.steamwar.bungeecore.Message; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; @@ -46,15 +47,15 @@ public class DevCommand extends BasicCommand { } String[] devSever = DevServerDir.list(); if (devSever == null || devSever.length == 0) { - sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar."); + Message.send("DEV_NO_SERVER", sender); } else if (devSever.length == 1) { String[] server = devSever[0].split("\\."); sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); } else { if (args.length == 0) { - send(devSever, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> sender.sendMessage("§eSteam§8War§8» §cBitte gib einen DevServer an.")); + send(devSever, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> Message.send("DEV_UNKNOWN_SERVER", sender)); } else { - send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar.")); + send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> Message.send("DEV_NO_SERVER", sender)); } } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index a92b7c5..06fdc7f 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -9,6 +9,9 @@ INVALID_TIME=§cUngültige Zeitangabe. STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r +DEV_NO_SERVER=§cDer Server ist derzeit nicht erreichbar. +DEV_UNKNOWN_SERVER=§cBitte gib einen DevServer an. + #ModLoader blocker MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten. MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten. From 86664ea399ab5dcc916d39b1dcb78d82997f6e98 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Jul 2021 08:24:54 +0200 Subject: [PATCH 76/81] Fix Typo --- src/de/steamwar/bungeecore/commands/DevCommand.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java index 5daa909..7e5ed2d 100644 --- a/src/de/steamwar/bungeecore/commands/DevCommand.java +++ b/src/de/steamwar/bungeecore/commands/DevCommand.java @@ -45,17 +45,17 @@ public class DevCommand extends BasicCommand { if (!(sender instanceof ProxiedPlayer)) { return; } - String[] devSever = DevServerDir.list(); - if (devSever == null || devSever.length == 0) { + String[] devServer = DevServerDir.list(); + if (devServer == null || devServer.length == 0) { Message.send("DEV_NO_SERVER", sender); - } else if (devSever.length == 1) { - String[] server = devSever[0].split("\\."); + } else if (devServer.length == 1) { + String[] server = devServer[0].split("\\."); sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); } else { if (args.length == 0) { - send(devSever, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> Message.send("DEV_UNKNOWN_SERVER", sender)); + send(devServer, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> Message.send("DEV_UNKNOWN_SERVER", sender)); } else { - send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> Message.send("DEV_NO_SERVER", sender)); + send(devServer, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> Message.send("DEV_NO_SERVER", sender)); } } } From c8bc438b0c96c0241211954692413cde0a674a57 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Jul 2021 13:02:30 +0200 Subject: [PATCH 77/81] Hotfix color codes for WGS winners --- 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 b41ea78..b850835 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -157,7 +157,7 @@ public class ChatListener extends BasicListener { String name = sender.getDisplayName(); String chatcolor = user.getUserGroup().getChatColorCode(); - if(user.getUserGroup() != UserGroup.Member) + if(user.getUserGroup() != UserGroup.Member || user.getTeam() == 12 || user.getTeam() == 285 || user.getTeam() == 54) message = ChatColor.translateAlternateColorCodes('&', message); String msg = name + "§7»" + chatcolor + " " + message; From 587395002a1ec2016bf32327211a17c8bad22f46 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Jul 2021 13:23:29 +0200 Subject: [PATCH 78/81] Better 7 sanitize --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index b850835..65b7e89 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -64,6 +64,10 @@ public class ChatListener extends BasicListener { e.setMessage("/" + e.getMessage().substring(1)); }else if(begin.startsWith("77") && begin.substring(2).matches("[A-Za-z]+")){ e.setMessage("//" + e.getMessage().substring(2)); + }else if(begin.startsWith("7/") && begin.substring(2).matches("[A-Za-z]+")){ + e.setMessage("//" + e.getMessage().substring(2)); + }else if(begin.startsWith("/7") && begin.substring(2).matches("[A-Za-z]+")){ + e.setMessage("//" + e.getMessage().substring(2)); } } From d1b764eb8856fdcf7f4997fefe7585297ca866c7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 12 Jul 2021 09:32:13 +0200 Subject: [PATCH 79/81] Hotfix StatCommand for no stats --- src/de/steamwar/bungeecore/commands/StatCommand.java | 3 +++ src/de/steamwar/messages/BungeeCore.properties | 1 + 2 files changed, 4 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/StatCommand.java b/src/de/steamwar/bungeecore/commands/StatCommand.java index 506ecab..1488dbf 100644 --- a/src/de/steamwar/bungeecore/commands/StatCommand.java +++ b/src/de/steamwar/bungeecore/commands/StatCommand.java @@ -58,6 +58,9 @@ public class StatCommand extends BasicCommand { Message.send("STAT_SERVER", sender, s.toUpperCase(), LoadEvaluation.getRemoteRamPercentage(s), LoadEvaluation.getRemoteCPULoad(s), integer); } }); + if (serverCounts.isEmpty()) { + Message.send("NO_STATS", sender); + } } catch (Exception e) { throw new SecurityException(e.getMessage(), e); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index eab98a5..9f3e701 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -108,6 +108,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War #Various commands ALERT=§f{0} STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3} +NO_STATS=§7Es gibt keine Statistiken, da keine Server online sind #Ban&Mute-Command BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4} From 73940661c92dde73958040e2dbc837434322d75b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 12 Jul 2021 09:32:58 +0200 Subject: [PATCH 80/81] Hotfix StatCommand for no stats --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 9f3e701..66acfd5 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -108,7 +108,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War #Various commands ALERT=§f{0} STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3} -NO_STATS=§7Es gibt keine Statistiken, da keine Server online sind +NO_STATS=§7Es gibt keine Statistiken, da keine Server gestartet sind #Ban&Mute-Command BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4} From 4a4f185c81875c917c3a59d699e21365890fda4d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 12 Jul 2021 09:33:54 +0200 Subject: [PATCH 81/81] Hotfix StatCommand for no stats --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 66acfd5..669ea67 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -108,7 +108,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War #Various commands ALERT=§f{0} STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3} -NO_STATS=§7Es gibt keine Statistiken, da keine Server gestartet sind +NO_STATS=§7Kein Bau oder Fight Server gestartet #Ban&Mute-Command BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}