From d72c8e612f9164d5d8538eb0e13b1aef40b46996 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 11:16:29 +0100 Subject: [PATCH 01/56] Command implementation --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/PlaytimeCommand.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/de/steamwar/bungeecore/commands/PlaytimeCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 72da98ac..fdc019e4 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -129,6 +129,7 @@ public class BungeeCore extends Plugin { new StatCommand(); new VerifyCommand(); new GDPRQuery(); + new PlaytimeCommand(); // Punishment Commands: new PunishmentCommand("ban", Punishment.PunishmentType.Ban); diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java new file mode 100644 index 00000000..003f3dcf --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -0,0 +1,21 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +import java.text.DecimalFormat; + +public class PlaytimeCommand extends BasicCommand{ + + public PlaytimeCommand() { + super("playtime", null); + } + + @Override public void execute(CommandSender sender, String[] strings) { + ProxiedPlayer player = (ProxiedPlayer) sender; + SteamwarUser user = SteamwarUser.get(player); + Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + } +} From 9b487e929c43090256977e3b431c4964f3e784f1 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 17:16:01 +0100 Subject: [PATCH 02/56] Fixes --- .../bungeecore/commands/PlaytimeCommand.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 003f3dcf..47b96a89 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.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.Message; @@ -13,7 +32,10 @@ public class PlaytimeCommand extends BasicCommand{ super("playtime", null); } - @Override public void execute(CommandSender sender, String[] strings) { + @Override + public void execute(CommandSender sender, String[] strings) { + if(!(sender instanceof ProxiedPlayer)) + return; ProxiedPlayer player = (ProxiedPlayer) sender; SteamwarUser user = SteamwarUser.get(player); Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); From 28f96c1708c6e95344a0e4443469d449c21527e6 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 17:29:41 +0100 Subject: [PATCH 03/56] Formatting --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 5 ++++- src/de/steamwar/messages/BungeeCore.properties | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 47b96a89..9cce3fb6 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -34,10 +34,13 @@ public class PlaytimeCommand extends BasicCommand{ @Override public void execute(CommandSender sender, String[] strings) { + if(!(sender instanceof ProxiedPlayer)) return; + ProxiedPlayer player = (ProxiedPlayer) sender; SteamwarUser user = SteamwarUser.get(player); - Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + Message.send("HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); } + } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 9e232f9d..fbfb85f9 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -557,4 +557,7 @@ GDPR_STATUS_WORLD=§7Packe Bauwelten... GDPR_STATUS_INVENTORIES=§7Suche und packe Inventare... GDPR_STATUS_DATABASE=§7Packe Datenbankinhalte... GDPR_STATUS_LOGS=§7Suche und packe logs... -GDPR_STATUS_FINISHED=§7Packen abgeschlossen \ No newline at end of file +GDPR_STATUS_FINISHED=§7Packen abgeschlossen + +#Playtime Command +HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h \ No newline at end of file From 896ea6b6d4121f4aa9c941fdb3b9e42dca5985af Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 17:35:17 +0100 Subject: [PATCH 04/56] Formatting --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 9cce3fb6..9e17309c 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -34,13 +34,10 @@ public class PlaytimeCommand extends BasicCommand{ @Override public void execute(CommandSender sender, String[] strings) { - if(!(sender instanceof ProxiedPlayer)) return; - ProxiedPlayer player = (ProxiedPlayer) sender; - SteamwarUser user = SteamwarUser.get(player); - Message.send("HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + Message.send("HOURS_PLAYED", sender, new DecimalFormat("###.##").format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); } } From 86e9c17d732dd54ab1124e79da09605519cbfcc1 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 17:36:22 +0100 Subject: [PATCH 05/56] Yoyo ist nen formatting freak --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 9e17309c..7e40f9fc 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -39,5 +39,4 @@ public class PlaytimeCommand extends BasicCommand{ Message.send("HOURS_PLAYED", sender, new DecimalFormat("###.##").format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); } - } From 6b0fb7ca6f935871c05ba62f2b4877144f5cb329 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 17:37:53 +0100 Subject: [PATCH 06/56] ) --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 7e40f9fc..468fae8d 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -37,6 +37,6 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - Message.send("HOURS_PLAYED", sender, new DecimalFormat("###.##").format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + Message.send("HOURS_PLAYED", sender, new DecimalFormat("###.##").format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600))); } } From 803b591ff4e0ef114c60e62053c0346fcef4f08a Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 09:29:55 +0100 Subject: [PATCH 07/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 468fae8d..e570db1b 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -25,6 +25,9 @@ import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.text.DecimalFormat; +import java.text.Format; +import java.text.NumberFormat; +import java.util.Locale; public class PlaytimeCommand extends BasicCommand{ @@ -37,6 +40,10 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - Message.send("HOURS_PLAYED", sender, new DecimalFormat("###.##").format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600))); + NumberFormat format = NumberFormat.getNumberInstance(Locale.GERMAN); + format.setMaximumFractionDigits(2); + format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + + Message.send("HOURS_PLAYED", sender, format); } } From 73321e4b7e46bcb38c57875bab63196d75913795 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:11:39 +0100 Subject: [PATCH 08/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 5 ++--- src/de/steamwar/messages/BungeeCore.properties | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index e570db1b..5b39ca83 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -40,9 +40,8 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - NumberFormat format = NumberFormat.getNumberInstance(Locale.GERMAN); - format.setMaximumFractionDigits(2); - format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + String s = Message.parse("TIME_FORMAT", sender); + String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); Message.send("HOURS_PLAYED", sender, format); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index fbfb85f9..48b8f970 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -560,4 +560,7 @@ GDPR_STATUS_LOGS=§7Suche und packe logs... GDPR_STATUS_FINISHED=§7Packen abgeschlossen #Playtime Command -HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h \ No newline at end of file +HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h + +#Player +TIME_FORMAT=hh:mm:ss \ No newline at end of file From 981be71d4ebdcb62cdb3ceefb044f459685d035d Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:15:24 +0100 Subject: [PATCH 09/56] Format --- 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 48b8f970..7dac9363 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -563,4 +563,4 @@ GDPR_STATUS_FINISHED=§7Packen abgeschlossen HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h #Player -TIME_FORMAT=hh:mm:ss \ No newline at end of file +TIME_FORMAT='###,##' \ No newline at end of file From 591395c64c0788d93843551a33a271b885b953fe Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:16:58 +0100 Subject: [PATCH 10/56] Format --- 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 7dac9363..b55dce66 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -563,4 +563,4 @@ GDPR_STATUS_FINISHED=§7Packen abgeschlossen HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h #Player -TIME_FORMAT='###,##' \ No newline at end of file +DECIMAL_FORMAT='###,##' \ No newline at end of file From f1c85771a7668444141d31619b7f1698ed4ebd18 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:17:09 +0100 Subject: [PATCH 11/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 5b39ca83..83805a53 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -43,6 +43,6 @@ public class PlaytimeCommand extends BasicCommand{ String s = Message.parse("TIME_FORMAT", sender); String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send("HOURS_PLAYED", sender, format); + Message.send("DECIMAL_FORMAT", sender, format); } } From 1815c986d588901ea623936fb5388c288e89dd6f Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:17:25 +0100 Subject: [PATCH 12/56] Format --- 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 b55dce66..8c9c1fcf 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -563,4 +563,4 @@ GDPR_STATUS_FINISHED=§7Packen abgeschlossen HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h #Player -DECIMAL_FORMAT='###,##' \ No newline at end of file +DECIMAL_FORMAT=###,## \ No newline at end of file From 94fe11933048416fade1f7968e34ea126a4de883 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:19:53 +0100 Subject: [PATCH 13/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 83805a53..862515c5 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -25,9 +25,6 @@ import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.text.DecimalFormat; -import java.text.Format; -import java.text.NumberFormat; -import java.util.Locale; public class PlaytimeCommand extends BasicCommand{ @@ -43,6 +40,6 @@ public class PlaytimeCommand extends BasicCommand{ String s = Message.parse("TIME_FORMAT", sender); String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send("DECIMAL_FORMAT", sender, format); + Message.send(format,sender); } } From 071e88966e78bd65366612839672d1909ecafd71 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:23:58 +0100 Subject: [PATCH 14/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 862515c5..8a0eee3b 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -40,6 +40,6 @@ public class PlaytimeCommand extends BasicCommand{ String s = Message.parse("TIME_FORMAT", sender); String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send(format,sender); + Message.send(Message.parse("HOURS_PLAYED", sender) + format,sender); } } From 858e657974b5d4c5161125f4de16a1b89b2e729a Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:30:15 +0100 Subject: [PATCH 15/56] Format --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 8a0eee3b..0aaca7c9 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -37,7 +37,7 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - String s = Message.parse("TIME_FORMAT", sender); + String s = Message.parse("DECIMAL_FORMAT", sender); String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); Message.send(Message.parse("HOURS_PLAYED", sender) + format,sender); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 8c9c1fcf..77a720ab 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -561,6 +561,4 @@ GDPR_STATUS_FINISHED=§7Packen abgeschlossen #Playtime Command HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h - -#Player DECIMAL_FORMAT=###,## \ No newline at end of file From 1cfa6359e8c7dbae8ac7890ac7d8e1b48152c40e Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:38:05 +0100 Subject: [PATCH 16/56] Formatting --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 0aaca7c9..f705790e 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -34,6 +34,7 @@ public class PlaytimeCommand extends BasicCommand{ @Override public void execute(CommandSender sender, String[] strings) { + if(!(sender instanceof ProxiedPlayer)) return; From 87db052478df9213c72dc5e264b3f0249ca3f46a Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 29 Dec 2021 10:42:38 +0100 Subject: [PATCH 17/56] =?UTF-8?q?Yoyo=20gl=C3=BCcklich=20machen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index f705790e..0aaca7c9 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -34,7 +34,6 @@ public class PlaytimeCommand extends BasicCommand{ @Override public void execute(CommandSender sender, String[] strings) { - if(!(sender instanceof ProxiedPlayer)) return; From 7220051c18aff0e180730a46040cf9702d7d8764 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 31 Dec 2021 22:21:25 +0100 Subject: [PATCH 18/56] Rework --- .../steamwar/bungeecore/commands/PlaytimeCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 0aaca7c9..c5ff3472 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -23,8 +23,11 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; +import org.apache.commons.lang3.LocaleUtils; import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; public class PlaytimeCommand extends BasicCommand{ @@ -37,9 +40,10 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - String s = Message.parse("DECIMAL_FORMAT", sender); - String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + NumberFormat format = NumberFormat.getNumberInstance(LocaleUtils.toLocale(Message.parse("DECIMAL_FORMAT", sender))); + format.setMaximumFractionDigits(2); + String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send(Message.parse("HOURS_PLAYED", sender) + format,sender); + Message.send(Message.parse("HOURS_PLAYED", sender) + formattedText,sender); } } From 20dc8fca3e0a16fd2ea27b310c3850340ef109fd Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 1 Jan 2022 12:24:36 +0100 Subject: [PATCH 19/56] . --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index c5ff3472..5953e03e 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -40,7 +40,7 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - NumberFormat format = NumberFormat.getNumberInstance(LocaleUtils.toLocale(Message.parse("DECIMAL_FORMAT", sender))); + NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale()); format.setMaximumFractionDigits(2); String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 436827d5..5e46bc56 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -570,5 +570,4 @@ GDPR_STATUS_LOGS=§7Suche und packe logs... GDPR_STATUS_FINISHED=§7Packen abgeschlossen #Playtime Command -HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h -DECIMAL_FORMAT=###,## \ No newline at end of file +HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h \ No newline at end of file From b77cce9921444b4cadf95af39821e6278ee05178 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 1 Jan 2022 18:43:43 +0100 Subject: [PATCH 20/56] . --- src/de/steamwar/bungeecore/commands/PlaytimeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 5953e03e..23e16a09 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -44,6 +44,6 @@ public class PlaytimeCommand extends BasicCommand{ format.setMaximumFractionDigits(2); String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send(Message.parse("HOURS_PLAYED", sender) + formattedText,sender); + Message.send("HOURS_PLAYED", sender, formattedText); } } From f75e24787fc4deac074df3e37875fdd4a0fe0b7c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 11:31:57 +0100 Subject: [PATCH 21/56] Implement execute command handler for lobby Signed-off-by: Lixfel --- .../bungeecore/comms/PacketIdManager.java | 1 + .../bungeecore/comms/SpigotReceiver.java | 1 + .../comms/handlers/ExecuteCommandHandler.java | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java index 01d474a5..8db10ad7 100644 --- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java +++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java @@ -26,6 +26,7 @@ public class PacketIdManager { public static final byte TABLIST_NAME = 0x02; public static final byte PREPARE_SCHEM = 0x03; public static final byte BAUMEMBER_UPDATE = 0x04; + public static final byte EXECUTE_COMMAND = 0x05; //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 ab6d246f..8eadfd74 100644 --- a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java +++ b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java @@ -58,5 +58,6 @@ public class SpigotReceiver extends BasicListener { registerHandler(PacketIdManager.PREPARE_SCHEM, new PrepareSchemHandler()); registerHandler(PacketIdManager.I_AM_A_LOBBY, new ImALobbyHandler()); registerHandler(PacketIdManager.FIGHT_INFO, new FightInfoHandler()); + registerHandler(PacketIdManager.EXECUTE_COMMAND, new ExecuteCommandHandler()); } } diff --git a/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java b/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java new file mode 100644 index 00000000..0051e55f --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java @@ -0,0 +1,36 @@ +/* + 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.comms.handlers; + +import com.google.common.io.ByteArrayDataInput; +import de.steamwar.bungeecore.comms.SpigotHandler; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.config.ServerInfo; + +public class ExecuteCommandHandler implements SpigotHandler { + @Override + public void handle(ByteArrayDataInput in, ServerInfo info) { + SteamwarUser target = SteamwarUser.get(in.readInt()); + String command = in.readUTF(); + + ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command); + } +} From 51fd1ea35aa659474c344898b257e5a8adaea569 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 21:19:43 +0100 Subject: [PATCH 22/56] Fix badlion Signed-off-by: Lixfel --- .../steamwar/bungeecore/listeners/mods/Badlion.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java index b0036161..79834b47 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java @@ -23,17 +23,6 @@ public class Badlion extends BasicListener { "ToggleSprint":{"disabled":true} } */ - event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{" + - "\"Clear Glass\":{\"disabled\":true}," + - "\"ClearWater\":{\"disabled\":true}," + - "\"FOV Changer\":{\"disabled\":true}," + - "\"Hitboxes\":{\"disabled\":true}," + - "\"MiniMap\":{\"disabled\":true}," + - "\"MLG Cobweb\":{\"disabled\":true}," + - "\"Replay\":{\"disabled\":true}," + - "\"Schematica\":{\"disabled\":true}," + - "\"ToggleSneak\":{\"disabled\":true}," + - "\"ToggleSprint\":{\"disabled\":true}" + - "}").getBytes(), false)); + event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"modsDisallowed\":{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true}}}").getBytes(), false)); } } From 9fa89644ee7b32807c31bd77daaf6650bf8dcde7 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 21:34:04 +0100 Subject: [PATCH 23/56] Fix badlion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 6 ++---- src/de/steamwar/bungeecore/listeners/mods/Badlion.java | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 53e5b0aa..f4481365 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -24,10 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.comms.SpigotReceiver; import de.steamwar.bungeecore.listeners.*; -import de.steamwar.bungeecore.listeners.mods.Forge; -import de.steamwar.bungeecore.listeners.mods.LabyMod; -import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; -import de.steamwar.bungeecore.listeners.mods.WorldDownloader; +import de.steamwar.bungeecore.listeners.mods.*; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.Statement; import de.steamwar.bungeecore.sql.SteamwarUser; @@ -81,6 +78,7 @@ public class BungeeCore extends Plugin { new ConnectionListener(); new Forge(); new LabyMod(); + new Badlion(); new ChatListener(); new BanListener(); new CheckListener(); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java index 79834b47..1e2c93e5 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java @@ -3,7 +3,6 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.event.EventHandler; -import net.md_5.bungee.protocol.packet.PluginMessage; public class Badlion extends BasicListener { @@ -11,6 +10,7 @@ public class Badlion extends BasicListener { public void onPostLogin(PostLoginEvent event) { /* { + "modsDisallowed": { "Clear Glass":{"disabled":true}, "ClearWater":{"disabled":true}, "FOV Changer":{"disabled":true}, @@ -22,7 +22,10 @@ public class Badlion extends BasicListener { "ToggleSneak":{"disabled":true}, "ToggleSprint":{"disabled":true} } + } */ + event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"modsDisallowed\":{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true}}}").getBytes(), false)); + //event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", "{\"modsDisallowed\":{\"Animations\":{\"disabled\":true},\"ArmorStatus\":{\"disabled\":true},\"AutoFriend\":{\"disabled\":true},\"AutoGG\":{\"disabled\":true},\"AutoText\":{\"disabled\":true},\"AutoTip\":{\"disabled\":true},\"Block Overlay\":{\"disabled\":true},\"BlockInfo\":{\"disabled\":true},\"BossBar\":{\"disabled\":true},\"Chat\":{\"disabled\":true},\"Chunk Borders\":{\"disabled\":true},\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"Clock\":{\"disabled\":true},\"Combo Counter\":{\"disabled\":true},\"Coordinates\":{\"disabled\":true},\"CPS\":{\"disabled\":true},\"Crosshair\":{\"disabled\":true},\"Custom Fonts\":{\"disabled\":true},\"Direction\":{\"disabled\":true},\"EnchantGlint\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"FPS\":{\"disabled\":true},\"Fullbright\":{\"disabled\":true},\"Hit Color\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"InventoryBlur\":{\"disabled\":true},\"Item Counter\":{\"disabled\":true},\"Item Info\":{\"disabled\":true},\"Item Physics\":{\"disabled\":true},\"Item Tracker\":{\"disabled\":true},\"JustEnoughItems\":{\"disabled\":true},\"Keystrokes\":{\"disabled\":true},\"LevelHead\":{\"disabled\":true},\"Light Overlay\":{\"disabled\":true},\"Memory\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"MotionBlur\":{\"disabled\":true},\"MumbleLink\":{\"disabled\":true},\"Music\":{\"disabled\":true},\"Name History\":{\"disabled\":true},\"NickHider\":{\"disabled\":true},\"NotEnoughUpdates\":{\"disabled\":true},\"Notifications\":{\"disabled\":true},\"Pack Display\":{\"disabled\":true},\"Pack Tweaks\":{\"disabled\":true},\"Particles\":{\"disabled\":true},\"Perspective\":{\"disabled\":true},\"Ping\":{\"disabled\":true},\"Player Counter\":{\"disabled\":true},\"PotionStatus\":{\"disabled\":true},\"Protection\":{\"disabled\":true},\"Quickplay\":{\"disabled\":true},\"Reach Display\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Saturation\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"Scoreboard\":{\"disabled\":true},\"Server Address\":{\"disabled\":true},\"Shinypots\":{\"disabled\":true},\"SkyblockAddons\":{\"disabled\":true},\"Stopwatch\":{\"disabled\":true},\"TcpNoDelay\":{\"disabled\":true},\"TeamSpeak\":{\"disabled\":true},\"TimeChanger\":{\"disabled\":true},\"Timers\":{\"disabled\":true},\"ToggleChat\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"Waypoints\":{\"disabled\":true},\"WeatherChanger\":{\"disabled\":true},\"World Edit CUI\":{\"disabled\":true},\"Zoom\":{\"disabled\":true},\"Clan Wars\":{\"disabled\":true},\"ColorSaturation\":{\"disabled\":true}}}".getBytes(), false)); } } From 1725a180d7fa2d37472bfb513e8b565de8308ee6 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 21:34:19 +0100 Subject: [PATCH 24/56] Fix badlion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Badlion.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java index 1e2c93e5..45ecf9eb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java @@ -3,6 +3,7 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.event.EventHandler; +import net.md_5.bungee.protocol.packet.PluginMessage; public class Badlion extends BasicListener { From 28ca028b733e6b8bf1070448ad14bee10f8bafe9 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 21:39:17 +0100 Subject: [PATCH 25/56] Fix badlion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Badlion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java index 45ecf9eb..2ba65e93 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java @@ -26,7 +26,7 @@ public class Badlion extends BasicListener { } */ - event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"modsDisallowed\":{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true}}}").getBytes(), false)); - //event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", "{\"modsDisallowed\":{\"Animations\":{\"disabled\":true},\"ArmorStatus\":{\"disabled\":true},\"AutoFriend\":{\"disabled\":true},\"AutoGG\":{\"disabled\":true},\"AutoText\":{\"disabled\":true},\"AutoTip\":{\"disabled\":true},\"Block Overlay\":{\"disabled\":true},\"BlockInfo\":{\"disabled\":true},\"BossBar\":{\"disabled\":true},\"Chat\":{\"disabled\":true},\"Chunk Borders\":{\"disabled\":true},\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"Clock\":{\"disabled\":true},\"Combo Counter\":{\"disabled\":true},\"Coordinates\":{\"disabled\":true},\"CPS\":{\"disabled\":true},\"Crosshair\":{\"disabled\":true},\"Custom Fonts\":{\"disabled\":true},\"Direction\":{\"disabled\":true},\"EnchantGlint\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"FPS\":{\"disabled\":true},\"Fullbright\":{\"disabled\":true},\"Hit Color\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"InventoryBlur\":{\"disabled\":true},\"Item Counter\":{\"disabled\":true},\"Item Info\":{\"disabled\":true},\"Item Physics\":{\"disabled\":true},\"Item Tracker\":{\"disabled\":true},\"JustEnoughItems\":{\"disabled\":true},\"Keystrokes\":{\"disabled\":true},\"LevelHead\":{\"disabled\":true},\"Light Overlay\":{\"disabled\":true},\"Memory\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"MotionBlur\":{\"disabled\":true},\"MumbleLink\":{\"disabled\":true},\"Music\":{\"disabled\":true},\"Name History\":{\"disabled\":true},\"NickHider\":{\"disabled\":true},\"NotEnoughUpdates\":{\"disabled\":true},\"Notifications\":{\"disabled\":true},\"Pack Display\":{\"disabled\":true},\"Pack Tweaks\":{\"disabled\":true},\"Particles\":{\"disabled\":true},\"Perspective\":{\"disabled\":true},\"Ping\":{\"disabled\":true},\"Player Counter\":{\"disabled\":true},\"PotionStatus\":{\"disabled\":true},\"Protection\":{\"disabled\":true},\"Quickplay\":{\"disabled\":true},\"Reach Display\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Saturation\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"Scoreboard\":{\"disabled\":true},\"Server Address\":{\"disabled\":true},\"Shinypots\":{\"disabled\":true},\"SkyblockAddons\":{\"disabled\":true},\"Stopwatch\":{\"disabled\":true},\"TcpNoDelay\":{\"disabled\":true},\"TeamSpeak\":{\"disabled\":true},\"TimeChanger\":{\"disabled\":true},\"Timers\":{\"disabled\":true},\"ToggleChat\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"Waypoints\":{\"disabled\":true},\"WeatherChanger\":{\"disabled\":true},\"World Edit CUI\":{\"disabled\":true},\"Zoom\":{\"disabled\":true},\"Clan Wars\":{\"disabled\":true},\"ColorSaturation\":{\"disabled\":true}}}".getBytes(), false)); + //event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"modsDisallowed\":{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true}}}").getBytes(), false)); + event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", "{\"modsDisallowed\":{\"Animations\":{\"disabled\":true},\"ArmorStatus\":{\"disabled\":true},\"AutoFriend\":{\"disabled\":true},\"AutoGG\":{\"disabled\":true},\"AutoText\":{\"disabled\":true},\"AutoTip\":{\"disabled\":true},\"Block Overlay\":{\"disabled\":true},\"BlockInfo\":{\"disabled\":true},\"BossBar\":{\"disabled\":true},\"Chat\":{\"disabled\":true},\"Chunk Borders\":{\"disabled\":true},\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"Clock\":{\"disabled\":true},\"Combo Counter\":{\"disabled\":true},\"Coordinates\":{\"disabled\":true},\"CPS\":{\"disabled\":true},\"Crosshair\":{\"disabled\":true},\"Custom Fonts\":{\"disabled\":true},\"Direction\":{\"disabled\":true},\"EnchantGlint\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"FPS\":{\"disabled\":true},\"Fullbright\":{\"disabled\":true},\"Hit Color\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"InventoryBlur\":{\"disabled\":true},\"Item Counter\":{\"disabled\":true},\"Item Info\":{\"disabled\":true},\"Item Physics\":{\"disabled\":true},\"Item Tracker\":{\"disabled\":true},\"JustEnoughItems\":{\"disabled\":true},\"Keystrokes\":{\"disabled\":true},\"LevelHead\":{\"disabled\":true},\"Light Overlay\":{\"disabled\":true},\"Memory\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"MotionBlur\":{\"disabled\":true},\"MumbleLink\":{\"disabled\":true},\"Music\":{\"disabled\":true},\"Name History\":{\"disabled\":true},\"NickHider\":{\"disabled\":true},\"NotEnoughUpdates\":{\"disabled\":true},\"Notifications\":{\"disabled\":true},\"Pack Display\":{\"disabled\":true},\"Pack Tweaks\":{\"disabled\":true},\"Particles\":{\"disabled\":true},\"Perspective\":{\"disabled\":true},\"Ping\":{\"disabled\":true},\"Player Counter\":{\"disabled\":true},\"PotionStatus\":{\"disabled\":true},\"Protection\":{\"disabled\":true},\"Quickplay\":{\"disabled\":true},\"Reach Display\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Saturation\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"Scoreboard\":{\"disabled\":true},\"Server Address\":{\"disabled\":true},\"Shinypots\":{\"disabled\":true},\"SkyblockAddons\":{\"disabled\":true},\"Stopwatch\":{\"disabled\":true},\"TcpNoDelay\":{\"disabled\":true},\"TeamSpeak\":{\"disabled\":true},\"TimeChanger\":{\"disabled\":true},\"Timers\":{\"disabled\":true},\"ToggleChat\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"Waypoints\":{\"disabled\":true},\"WeatherChanger\":{\"disabled\":true},\"World Edit CUI\":{\"disabled\":true},\"Zoom\":{\"disabled\":true},\"Clan Wars\":{\"disabled\":true},\"ColorSaturation\":{\"disabled\":true}}}".getBytes(), false)); } } From 83df7665e2859dc1eca4277cfe43fb546dd503a7 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 22:04:45 +0100 Subject: [PATCH 26/56] Fix badlion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Badlion.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java index 2ba65e93..cfc9ab70 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Badlion.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Badlion.java @@ -21,12 +21,12 @@ public class Badlion extends BasicListener { "Replay":{"disabled":true}, "Schematica":{"disabled":true}, "ToggleSneak":{"disabled":true}, - "ToggleSprint":{"disabled":true} + "ToggleSprint":{"disabled":true}, + "TNT Time":{"disabled":true} } } */ - //event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"modsDisallowed\":{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true}}}").getBytes(), false)); - event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", "{\"modsDisallowed\":{\"Animations\":{\"disabled\":true},\"ArmorStatus\":{\"disabled\":true},\"AutoFriend\":{\"disabled\":true},\"AutoGG\":{\"disabled\":true},\"AutoText\":{\"disabled\":true},\"AutoTip\":{\"disabled\":true},\"Block Overlay\":{\"disabled\":true},\"BlockInfo\":{\"disabled\":true},\"BossBar\":{\"disabled\":true},\"Chat\":{\"disabled\":true},\"Chunk Borders\":{\"disabled\":true},\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"Clock\":{\"disabled\":true},\"Combo Counter\":{\"disabled\":true},\"Coordinates\":{\"disabled\":true},\"CPS\":{\"disabled\":true},\"Crosshair\":{\"disabled\":true},\"Custom Fonts\":{\"disabled\":true},\"Direction\":{\"disabled\":true},\"EnchantGlint\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"FPS\":{\"disabled\":true},\"Fullbright\":{\"disabled\":true},\"Hit Color\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"InventoryBlur\":{\"disabled\":true},\"Item Counter\":{\"disabled\":true},\"Item Info\":{\"disabled\":true},\"Item Physics\":{\"disabled\":true},\"Item Tracker\":{\"disabled\":true},\"JustEnoughItems\":{\"disabled\":true},\"Keystrokes\":{\"disabled\":true},\"LevelHead\":{\"disabled\":true},\"Light Overlay\":{\"disabled\":true},\"Memory\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"MotionBlur\":{\"disabled\":true},\"MumbleLink\":{\"disabled\":true},\"Music\":{\"disabled\":true},\"Name History\":{\"disabled\":true},\"NickHider\":{\"disabled\":true},\"NotEnoughUpdates\":{\"disabled\":true},\"Notifications\":{\"disabled\":true},\"Pack Display\":{\"disabled\":true},\"Pack Tweaks\":{\"disabled\":true},\"Particles\":{\"disabled\":true},\"Perspective\":{\"disabled\":true},\"Ping\":{\"disabled\":true},\"Player Counter\":{\"disabled\":true},\"PotionStatus\":{\"disabled\":true},\"Protection\":{\"disabled\":true},\"Quickplay\":{\"disabled\":true},\"Reach Display\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Saturation\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"Scoreboard\":{\"disabled\":true},\"Server Address\":{\"disabled\":true},\"Shinypots\":{\"disabled\":true},\"SkyblockAddons\":{\"disabled\":true},\"Stopwatch\":{\"disabled\":true},\"TcpNoDelay\":{\"disabled\":true},\"TeamSpeak\":{\"disabled\":true},\"TimeChanger\":{\"disabled\":true},\"Timers\":{\"disabled\":true},\"ToggleChat\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"Waypoints\":{\"disabled\":true},\"WeatherChanger\":{\"disabled\":true},\"World Edit CUI\":{\"disabled\":true},\"Zoom\":{\"disabled\":true},\"Clan Wars\":{\"disabled\":true},\"ColorSaturation\":{\"disabled\":true}}}".getBytes(), false)); + event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"TNT Time\":{\"disabled\":true}}").getBytes(), false)); } } From 55a5492a2d4fa423cf5043ee95438157d21bfcd0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 5 Jan 2022 16:00:45 +0100 Subject: [PATCH 27/56] Rebuild Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index f4481365..43a6a378 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -67,6 +67,7 @@ public class BungeeCore extends Plugin { private ErrorLogger errorLogger; + @Override public void onEnable(){ getProxy().registerChannel("sw:bridge"); From 9218544349c7b62857c07b20cef7a8912ceda68d Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 7 Jan 2022 11:50:26 +0100 Subject: [PATCH 28/56] Primitive Version --- .../listeners/mods/CustomPacketHandler.java | 44 +++++++++++++++++ .../bungeecore/listeners/mods/FMLPing.java | 48 +++++++++++++++++++ .../bungeecore/listeners/mods/Forge.java | 38 +++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java create mode 100644 src/de/steamwar/bungeecore/listeners/mods/FMLPing.java diff --git a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java new file mode 100644 index 00000000..c210912f --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java @@ -0,0 +1,44 @@ +package de.steamwar.bungeecore.listeners.mods; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.sql.Mod; +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.LoginEvent; +import net.md_5.bungee.api.event.PreLoginEvent; +import net.md_5.bungee.api.plugin.Event; +import net.md_5.bungee.netty.ChannelWrapper; +import net.md_5.bungee.netty.PacketHandler; +import net.md_5.bungee.protocol.packet.LoginPayloadResponse; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class CustomPacketHandler extends PacketHandler { + + private LoginEvent event; + private ChannelWrapper wrapper; + + public CustomPacketHandler(LoginEvent event, ChannelWrapper wrapper) { + this.event = event; + this.wrapper = wrapper; + } + + @Override public String toString() { + return null; + } + + public void handle(LoginPayloadResponse response){ + if(response.getData() == null) { + System.out.println("Data is null with id: " + response.getId() + " , which means Client has no installed mods!"); + event.completeIntent(BungeeCore.get()); + return; + } + + + event.completeIntent(BungeeCore.get()); + } +} diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java new file mode 100644 index 00000000..73dba3d8 --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -0,0 +1,48 @@ +package de.steamwar.bungeecore.listeners.mods; + +import net.md_5.bungee.api.ServerPing; + +import java.util.ArrayList; +import java.util.List; + +public class FMLPing extends ServerPing { + private final ForgeData forgeData = new ForgeData(); + + public FMLPing(ServerPing existing) { + super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); + } + + private static class ForgeData { + private final List channels = new ArrayList<>(); + private final List mods = new ArrayList<>(); + private final int fmlNetworkVersion = 2; + + public ForgeData() { + channels.add(new ForgeChannel("minecraft:unregister")); + channels.add(new ForgeChannel("minecraft:register")); + channels.add(new ForgeChannel("fml:handshake")); + mods.add(new ForgeMod("minecraft", "1.15.2")); + mods.add(new ForgeMod("forge", "ANY")); + } + + private static class ForgeChannel { + private final String res; + private final String version = "FML2"; + private final boolean required = true; + + private ForgeChannel(String res) { + this.res = res; + } + } + + private static class ForgeMod { + private final String modId; + private final String modmarker; + + private ForgeMod(String modId, String modmarker) { + this.modId = modId; + this.modmarker = modmarker; + } + } + } +} diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 905eecb8..881e4d7c 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -27,10 +27,17 @@ import io.netty.buffer.UnpooledByteBufAllocator; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.LoginEvent; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PostLoginEvent; +import net.md_5.bungee.api.event.ProxyPingEvent; +import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.event.EventHandler; +import net.md_5.bungee.netty.ChannelWrapper; +import net.md_5.bungee.netty.HandlerBoss; +import net.md_5.bungee.protocol.packet.LoginPayloadRequest; +import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.TimeUnit; @@ -39,6 +46,7 @@ public class Forge extends BasicListener { private static final String FMLHS = "FML|HS"; private static final String FMLHS13 = "fml:handshake"; + private static final String WRAPPER = "fml:loginwrapper"; private static final byte[] REGISTER; private static final byte[] REGISTER13; private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0}; @@ -58,6 +66,36 @@ public class Forge extends BasicListener { buf.readBytes(REGISTER13); } + @EventHandler + public void onServerConnected(LoginEvent event){ + //Wir senden Packet ID 1 + //Wir wollen empfangen Packet ID 2 + //(FMLHS13, new byte[]{4, 1, 0, 0, 0}); + //13,102,109,108,58,104,97,110,100,115,104,97,107,101 = 13 + "fml:handshake" + event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1,WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0})); + event.registerIntent(BungeeCore.get()); + + + InitialHandler handler = (InitialHandler) event.getConnection(); + + Field ch; + ChannelWrapper wrapper = null; + + try{ + ch = handler.getClass().getDeclaredField("ch"); + ch.setAccessible(true); + wrapper = (ChannelWrapper) ch.get(handler); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event, wrapper)); + } + + @EventHandler + public void onServerPing(ProxyPingEvent event) { + event.setResponse(new FMLPing(event.getResponse())); + } + @EventHandler public void onPostLogin(PostLoginEvent event) { ProxiedPlayer player = event.getPlayer(); From 1c50d61a28aa5e0cded3303252cd61d576a52625 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 7 Jan 2022 22:03:06 +0100 Subject: [PATCH 29/56] Some minor bugfixes Signed-off-by: Lixfel --- .gitignore | 1 + src/de/steamwar/bungeecore/commands/VerifyCommand.java | 10 +++++++++- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 6 ++++-- src/de/steamwar/messages/BungeeCore.properties | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index eba3be62..958dc459 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ lib .idea target +dependency-reduced-pom.xml \ No newline at end of file diff --git a/src/de/steamwar/bungeecore/commands/VerifyCommand.java b/src/de/steamwar/bungeecore/commands/VerifyCommand.java index 927c2765..cbc5430e 100644 --- a/src/de/steamwar/bungeecore/commands/VerifyCommand.java +++ b/src/de/steamwar/bungeecore/commands/VerifyCommand.java @@ -40,7 +40,15 @@ public class VerifyCommand extends BasicCommand { Message.send("VERIFY_USAGE", sender); return; } - byte[] bytes = Base64.getDecoder().decode(strings[0]); + + byte[] bytes; + try { + bytes = Base64.getDecoder().decode(strings[0]); + } catch (IllegalArgumentException e) { + Message.send("VERIFY_INVALID", sender); + return; + } + if(bytes.length != 16) { Message.send("VERIFY_INVALID", sender); return; diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 86d5d023..58c53a68 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -224,10 +224,12 @@ public class SteamwarUser { final URL url = new URL(API_URL + playerName); String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString(); return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); - } catch (NoSuchElementException | IOException e) { + } catch (NoSuchElementException e) { + // ignore, player does not exist + } catch (IOException e) { BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e); - return null; } + return null; } public void setTeam(int team) { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index e0a8b7a1..92875de4 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -537,7 +537,7 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand -WHOIS_USAGE=§c/whois [Spieler/ID] {-a} +WHOIS_USAGE=§c/whois [Spieler/ID] \{-a\} WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eUUID Kopieren From 361077cc3eca588f4804e1aa7c4b272731a8d0f5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 8 Jan 2022 08:46:28 +0100 Subject: [PATCH 30/56] Fix future event participations on team deletion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/Team.java | 1 + src/de/steamwar/bungeecore/sql/TeamTeilnahme.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index f721fa5d..be3bbec1 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -146,6 +146,7 @@ public class Team { user.setLeader(false); delete.update(teamId); teamCache.remove(this); + TeamTeilnahme.deleteFuture(teamId); } public List getMembers(){ diff --git a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java index 68b1192e..e8eabbaa 100644 --- a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java +++ b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java @@ -28,6 +28,7 @@ public class TeamTeilnahme { private static final Statement insert = new Statement("INSERT INTO TeamTeilnahme (TeamID, EventID) VALUES (?, ?)"); private static final Statement delete = new Statement("DELETE FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); + private static final Statement deleteFuture = new Statement("DELETE FROM TeamTeilnahme t WHERE t.TeamID = ? AND (SELECT e.Start FROM Event e WHERE e.EventID = t.EventID) > NOW()"); private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?"); private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?"); @@ -44,6 +45,10 @@ public class TeamTeilnahme { return byEventTeam.select(ResultSet::next, teamID, eventID); } + public static void deleteFuture(int teamID) { + deleteFuture.update(teamID); + } + public static Set getTeams(int eventID){ return byEvent.select(rs -> { Set teams = new HashSet<>(); From 28946876cf0444541b5d36634b56a01b37c2bab5 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 8 Jan 2022 09:57:45 +0100 Subject: [PATCH 31/56] Fixes --- .../listeners/mods/CustomPacketHandler.java | 43 +++++++++++-------- .../bungeecore/listeners/mods/FMLPing.java | 18 ++++++++ .../bungeecore/listeners/mods/Forge.java | 32 +++++--------- .../listeners/mods/ModLoaderBlocker.java | 20 --------- 4 files changed, 52 insertions(+), 61 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java index c210912f..949823ea 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java +++ b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java @@ -1,43 +1,48 @@ +/* + 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.mods; import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.sql.Mod; -import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.LoginEvent; -import net.md_5.bungee.api.event.PreLoginEvent; -import net.md_5.bungee.api.plugin.Event; -import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.PacketHandler; import net.md_5.bungee.protocol.packet.LoginPayloadResponse; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; public class CustomPacketHandler extends PacketHandler { - private LoginEvent event; - private ChannelWrapper wrapper; + private LoginEvent event; - public CustomPacketHandler(LoginEvent event, ChannelWrapper wrapper) { + public CustomPacketHandler(LoginEvent event) { this.event = event; - this.wrapper = wrapper; } - @Override public String toString() { + @Override + public String toString() { return null; } public void handle(LoginPayloadResponse response){ if(response.getData() == null) { - System.out.println("Data is null with id: " + response.getId() + " , which means Client has no installed mods!"); event.completeIntent(BungeeCore.get()); return; } - + + byte[] data = response.getData(); event.completeIntent(BungeeCore.get()); } diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index 73dba3d8..56edfc21 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -1,3 +1,21 @@ +/* + 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.mods; import net.md_5.bungee.api.ServerPing; diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 881e4d7c..64c1ce08 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.listeners.mods; +import com.google.common.collect.ImmutableMap; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; @@ -41,14 +42,13 @@ import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; public class Forge extends BasicListener { private static final String FMLHS = "FML|HS"; - private static final String FMLHS13 = "fml:handshake"; private static final String WRAPPER = "fml:loginwrapper"; private static final byte[] REGISTER; - private static final byte[] REGISTER13; private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0}; private static final Set unlocked = new HashSet<>(); @@ -58,37 +58,28 @@ public class Forge extends BasicListener { buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8); REGISTER = new byte[buf.readableBytes()]; buf.readBytes(REGISTER); - - buf.clear(); - buf.writeByte(13); - buf.writeCharSequence(FMLHS13, StandardCharsets.UTF_8); - REGISTER13 = new byte[buf.readableBytes()]; - buf.readBytes(REGISTER13); } @EventHandler public void onServerConnected(LoginEvent event){ - //Wir senden Packet ID 1 - //Wir wollen empfangen Packet ID 2 - //(FMLHS13, new byte[]{4, 1, 0, 0, 0}); - //13,102,109,108,58,104,97,110,100,115,104,97,107,101 = 13 + "fml:handshake" + if(event.getConnection().getVersion() < 340) return; //1.13+ event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1,WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0})); - event.registerIntent(BungeeCore.get()); - InitialHandler handler = (InitialHandler) event.getConnection(); Field ch; - ChannelWrapper wrapper = null; + ChannelWrapper wrapper; try{ ch = handler.getClass().getDeclaredField("ch"); ch.setAccessible(true); wrapper = (ChannelWrapper) ch.get(handler); } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e); + return; } - wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event, wrapper)); + event.registerIntent(BungeeCore.get()); + wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event)); } @EventHandler @@ -107,10 +98,7 @@ public class Forge extends BasicListener { } } - if(player.getPendingConnection().getVersion() > 340) { - player.sendData("minecraft:register", REGISTER13); //1.13+ - player.sendData(FMLHS13, Forge.HELLO); - }else{ + if(player.getPendingConnection().getVersion() <= 340) { player.sendData("REGISTER", REGISTER); //1.12- player.sendData(FMLHS, Forge.HELLO); } @@ -118,7 +106,7 @@ public class Forge extends BasicListener { @EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ - if(!e.getTag().equals(FMLHS) && !e.getTag().equals(FMLHS13)) + if(!e.getTag().equals(FMLHS)) return; e.setCancelled(true); diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index 281830cf..a4d54e6d 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -56,26 +56,6 @@ public class ModLoaderBlocker extends BasicListener { } } - @EventHandler - public void onPluginMessage(PluginMessageEvent e){ - if(!e.getTag().equals("minecraft:register")) - return; - - Connection sender = e.getSender(); - if(!(sender instanceof ProxiedPlayer)) - return; - ProxiedPlayer p = (ProxiedPlayer) sender; - - if(p.getPendingConnection().getVersion() <= 340) - return; - - String registered = new String(e.getData(), StandardCharsets.UTF_8); - if(registered.contains("fml:loginwrapper") || registered.contains("fml:handshake") || registered.contains("fml:play")){ - Storage.fabricPlayers.add(p); - Message.send("MODLOADER_INSTALLED", p, "Forge"); - } - } - @EventHandler public void onDisconnect(PlayerDisconnectEvent e){ Storage.fabricPlayers.remove(e.getPlayer()); From 3773d3cefcd7c99190e9651ed54ae0cbbde95f41 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 9 Jan 2022 09:29:45 +0100 Subject: [PATCH 32/56] Performance --- src/de/steamwar/bungeecore/listeners/mods/FMLPing.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index 56edfc21..79f28f26 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -24,7 +24,10 @@ import java.util.ArrayList; import java.util.List; public class FMLPing extends ServerPing { - private final ForgeData forgeData = new ForgeData(); + + static { + ForgeData forgeData = new ForgeData(); + } public FMLPing(ServerPing existing) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); From 88ec0ad7db390ab98ed3c187cb8c9805a63fc6e9 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 14 Jan 2022 12:08:00 +0100 Subject: [PATCH 33/56] Performance --- src/de/steamwar/bungeecore/listeners/mods/FMLPing.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index 79f28f26..ed460bea 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -25,9 +25,7 @@ import java.util.List; public class FMLPing extends ServerPing { - static { - ForgeData forgeData = new ForgeData(); - } + private static final ForgeData data = new ForgeData(); public FMLPing(ServerPing existing) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); From 7f196f0801afc2bae984f986b812ddc66f05e31d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 14 Jan 2022 14:35:21 +0100 Subject: [PATCH 34/56] Prevent starting multiple baus at once Signed-off-by: Lixfel --- .../steamwar/bungeecore/commands/BauCommand.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 37955184..11da6847 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -259,16 +259,22 @@ public class BauCommand extends BasicCommand { }); } - public static boolean stopBauserver(ProxiedPlayer p){ + private static boolean startingBau(ProxiedPlayer p) { for (Subserver subserver : Subserver.getServerList()) { if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId()) && !subserver.hasStarted()) { Message.send("BAU_START_ALREADY", p); - return false; + return true; } } + return false; + } + + public static boolean stopBauserver(ProxiedPlayer p){ + if(startingBau(p)) + return false; for (Subserver subserver : Subserver.getServerList()) { - if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) { + if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId()) && subserver.hasStarted()) { subserver.stop(); try { Thread.sleep(200); // Wait until possible testarena-World has been deleted @@ -278,7 +284,8 @@ public class BauCommand extends BasicCommand { break; } } - return true; + + return !startingBau(p); } private static void testarena(ProxiedPlayer p, String[] args){ From 5461c47ea2f2a3a80ee1c2801234f6cba449562f Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 15 Jan 2022 16:29:44 +0100 Subject: [PATCH 35/56] Performance --- src/de/steamwar/bungeecore/listeners/mods/FMLPing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index ed460bea..5ce9aafb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -25,7 +25,7 @@ import java.util.List; public class FMLPing extends ServerPing { - private static final ForgeData data = new ForgeData(); + private ForgeData forgeData = new ForgeData(); public FMLPing(ServerPing existing) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); From ae3948f400e6d73f24b75482a2128817ba9e948c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 29 Jan 2022 12:17:48 +0100 Subject: [PATCH 36/56] Arena command Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/ArenaCommand.java | 56 +++++++++++++++++++ .../bungeecore/commands/ChallengeCommand.java | 2 +- .../bungeecore/commands/FightCommand.java | 2 +- .../bungeecore/commands/HistoricCommand.java | 2 +- .../bungeecore/commands/RankedCommand.java | 2 +- .../steamwar/messages/BungeeCore.properties | 5 +- 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/de/steamwar/bungeecore/commands/ArenaCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 43a6a378..c9f35709 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -127,6 +127,7 @@ public class BungeeCore extends Plugin { new ReplayCommand(); new GDPRQuery(); new PlaytimeCommand(); + new ArenaCommand(); // Punishment Commands: new PunishmentCommand("ban", Punishment.PunishmentType.Ban); diff --git a/src/de/steamwar/bungeecore/commands/ArenaCommand.java b/src/de/steamwar/bungeecore/commands/ArenaCommand.java new file mode 100644 index 00000000..c5f9c20a --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/ArenaCommand.java @@ -0,0 +1,56 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.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; + +public class ArenaCommand extends BasicCommand { + + public ArenaCommand() { + super("arena", null); + } + + @Override + public void execute(CommandSender sender, String[] args) { + if(!(sender instanceof ProxiedPlayer)) + return; + ProxiedPlayer player = (ProxiedPlayer) sender; + + ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", args)); + if(server == null) { + Message.send("ARENA_NOT_FOUND", player); + return; + } + + Subserver subserver = Subserver.getSubserver(server); + if(subserver.getType() != Servertype.ARENA) { + Message.send("ARENA_NOT_FOUND", player); + return; + } + + subserver.sendPlayer(player); + } +} diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index ae34de97..1a2db5cf 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -82,7 +82,7 @@ public class ChallengeCommand extends BasicCommand { arena.sendPlayer(target); Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER", - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), mode.getDisplayName(), player.getName(), target.getName()); + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName(), target.getName()); }else{ if(!challenges.containsKey(player)){ challenges.put(player, new LinkedList<>()); diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 65eea1c6..0f995a91 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -167,7 +167,7 @@ public class FightCommand extends BasicCommand { Subserver arena = SubserverSystem.startArena(mode, map, 0, 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()); + , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); }); } diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java index 6d1f936e..05379381 100644 --- a/src/de/steamwar/bungeecore/commands/HistoricCommand.java +++ b/src/de/steamwar/bungeecore/commands/HistoricCommand.java @@ -39,7 +39,7 @@ public class HistoricCommand extends BasicCommand { Subserver arena = SubserverSystem.startArena(mode, map, 0, 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()); + , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName()); }); } diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index a9d87771..55c9b094 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -173,7 +173,7 @@ public class RankedCommand extends BasicCommand { arena.sendPlayer(wp2.player); Message.broadcast("RANKED_BROADCAST", "RANKED_BROADCAST_HOVER", - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + wp1.player.getName()), mode.getDisplayName(), wp1.player.getName(), wp2.player.getName()); + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), wp1.player.getName(), wp2.player.getName()); } } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 92875de4..e9422f4c 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -571,4 +571,7 @@ GDPR_STATUS_LOGS=§7Suche und packe logs... GDPR_STATUS_FINISHED=§7Packen abgeschlossen #Playtime Command -HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h \ No newline at end of file +HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h + +#Arena command +ARENA_NOT_FOUND=§cDie angegebene Arena konnte nicht gefunden werden From 2026893d950440e24aecbca4f47b23fce0d54535 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 29 Jan 2022 13:16:30 +0100 Subject: [PATCH 37/56] Forge packet parsing Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + src/de/steamwar/bungeecore/Message.java | 24 +-- .../listeners/mods/CustomPacketHandler.java | 49 ------ .../bungeecore/listeners/mods/FMLPing.java | 2 +- .../bungeecore/listeners/mods/Forge.java | 151 ++++++++---------- .../bungeecore/listeners/mods/Forge12.java | 113 +++++++++++++ .../bungeecore/listeners/mods/Utils.java | 25 ++- src/de/steamwar/bungeecore/sql/UserGroup.java | 22 ++- 8 files changed, 224 insertions(+), 163 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java create mode 100644 src/de/steamwar/bungeecore/listeners/mods/Forge12.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 43a6a378..27b28ddd 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -78,6 +78,7 @@ public class BungeeCore extends Plugin { errorLogger = new ErrorLogger(); new ConnectionListener(); new Forge(); + new Forge12(); new LabyMod(); new Badlion(); new ChatListener(); diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index b9a6f585..f755cdf1 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -44,24 +44,26 @@ public class Message { }; public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){ - return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, sender, params))); + return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params))); } public static String parsePrefixed(String message, CommandSender sender, Object... params){ - return parse(message, true, sender, params); + return parse(message, true, locale(sender), params); } public static String parse(String message, CommandSender sender, Object... params){ - return parse(message, false, sender, params); + return parse(message, false, locale(sender), params); } - private static String parse(String message, boolean prefixed, CommandSender sender, Object... params){ - Locale locale = null; - if(sender instanceof ProxiedPlayer) - locale = ((ProxiedPlayer)sender).getLocale(); - if(locale == null) - locale = Locale.getDefault(); + public static String parse(String message, Locale locale, Object... params){ + return parse(message, false, locale, params); + } + private static Locale locale(CommandSender sender) { + return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault(); + } + + private static String parse(String message, boolean prefixed, Locale locale, Object... params){ ResourceBundle resourceBundle = ResourceBundle.getBundle("de.steamwar.messages.BungeeCore", locale, CONTROL); String pattern = ""; if(prefixed) @@ -72,7 +74,7 @@ public class Message { for (int i = 0; i < params.length; i++) { if(params[i] instanceof Message) { Message msg = (Message) params[i]; - params[i] = parse(msg.getMessage(), sender, msg.getParams()); + params[i] = parse(msg.getMessage(), false, locale, msg.getParams()); } else if(params[i] instanceof Date) { params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]); } @@ -120,7 +122,7 @@ public class Message { public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params){ for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) - send(message, player, parse(onHover, false, player, params), onClick, params); + send(message, player, parse(onHover, player, params), onClick, params); } public static void broadcast(String message, Object... params){ diff --git a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java deleted file mode 100644 index 949823ea..00000000 --- a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java +++ /dev/null @@ -1,49 +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.listeners.mods; - -import de.steamwar.bungeecore.BungeeCore; -import net.md_5.bungee.api.event.LoginEvent; -import net.md_5.bungee.netty.PacketHandler; -import net.md_5.bungee.protocol.packet.LoginPayloadResponse; - -public class CustomPacketHandler extends PacketHandler { - - private LoginEvent event; - - public CustomPacketHandler(LoginEvent event) { - this.event = event; - } - - @Override - public String toString() { - return null; - } - - public void handle(LoginPayloadResponse response){ - if(response.getData() == null) { - event.completeIntent(BungeeCore.get()); - return; - } - - byte[] data = response.getData(); - - event.completeIntent(BungeeCore.get()); - } -} diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index 5ce9aafb..4ed9a01c 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -25,7 +25,7 @@ import java.util.List; public class FMLPing extends ServerPing { - private ForgeData forgeData = new ForgeData(); + private final ForgeData forgeData = new ForgeData(); public FMLPing(ServerPing existing) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 64c1ce08..99d46143 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -19,67 +19,38 @@ package de.steamwar.bungeecore.listeners.mods; -import com.google.common.collect.ImmutableMap; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.Connection; -import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.event.LoginEvent; -import net.md_5.bungee.api.event.PluginMessageEvent; -import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.HandlerBoss; +import net.md_5.bungee.netty.PacketHandler; import net.md_5.bungee.protocol.packet.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.LoginPayloadResponse; import java.lang.reflect.Field; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.concurrent.TimeUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; import java.util.logging.Level; public class Forge extends BasicListener { - private static final String FMLHS = "FML|HS"; private static final String WRAPPER = "fml:loginwrapper"; - private static final byte[] REGISTER; - private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0}; - private static final Set unlocked = new HashSet<>(); + private static final Field initialHandlerCh; static{ - ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(7); - buf.writeByte(6); - buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8); - REGISTER = new byte[buf.readableBytes()]; - buf.readBytes(REGISTER); - } - - @EventHandler - public void onServerConnected(LoginEvent event){ - if(event.getConnection().getVersion() < 340) return; //1.13+ - event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1,WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0})); - - InitialHandler handler = (InitialHandler) event.getConnection(); - - Field ch; - ChannelWrapper wrapper; - - try{ - ch = handler.getClass().getDeclaredField("ch"); - ch.setAccessible(true); - wrapper = (ChannelWrapper) ch.get(handler); - } catch (NoSuchFieldException | IllegalAccessException e) { - BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e); - return; + try { + initialHandlerCh = InitialHandler.class.getDeclaredField("ch"); + } catch (NoSuchFieldException e) { + throw new SecurityException("Could not initialize Reflection", e); } - event.registerIntent(BungeeCore.get()); - wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event)); + initialHandlerCh.setAccessible(true); } @EventHandler @@ -88,62 +59,70 @@ public class Forge extends BasicListener { } @EventHandler - public void onPostLogin(PostLoginEvent event) { - ProxiedPlayer player = event.getPlayer(); + public void onServerConnected(LoginEvent event){ + if(event.getConnection().getVersion() < 340) return; //1.13+ - synchronized (unlocked) { - if(unlocked.contains(player.getUniqueId())){ - unlocked.remove(player.getUniqueId()); - return; - } + //fml:handshake without mods, channels and registries + //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 + event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1, WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0})); + + InitialHandler handler = (InitialHandler) event.getConnection(); + + ChannelWrapper wrapper; + try{ + wrapper = (ChannelWrapper) initialHandlerCh.get(handler); + } catch (IllegalAccessException e) { + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e); + return; } - if(player.getPendingConnection().getVersion() <= 340) { - player.sendData("REGISTER", REGISTER); //1.12- - player.sendData(FMLHS, Forge.HELLO); - } + event.registerIntent(BungeeCore.get()); + wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event)); } - @EventHandler - public void onPluginMessageEvent(PluginMessageEvent e){ - if(!e.getTag().equals(FMLHS)) - return; + private static class CustomPacketHandler extends PacketHandler { + private final LoginEvent event; - e.setCancelled(true); - byte[] data = e.getData(); + public CustomPacketHandler(LoginEvent event) { + this.event = event; + } - Connection sender = e.getSender(); - if(!(sender instanceof ProxiedPlayer)) - return; - ProxiedPlayer p = (ProxiedPlayer) sender; + @Override + public String toString() { + return "SteamWar Forge Handler"; + } - if (data[0] == 2) { - Utils.VarInt numMods = Utils.readVarInt(data, 1); - List mods = new LinkedList<>(); - - int bytePos = 1 + numMods.length; - for (int i = 0; i < numMods.value; i++) { - byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1); - bytePos += 1 + data[bytePos]; - //Version information is unused - bytePos += 1 + data[bytePos]; - - mods.add(Mod.get(new String(name), Mod.Platform.FORGE)); + @Override + public void handle(LoginPayloadResponse response){ + byte[] data = response.getData(); + if(data == null) { + event.completeIntent(BungeeCore.get()); + return; } - if (Utils.handleMods(p, mods)) { - synchronized (unlocked) { - unlocked.add(p.getUniqueId()); - } - ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), - () -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")), - 2, TimeUnit.SECONDS); - ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { - synchronized (unlocked) { - unlocked.remove(p.getUniqueId()); - } - }, 30, TimeUnit.SECONDS); + //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 + Utils.VarInt length = Utils.readVarInt(data, 0); + assert length.length + length.value == data.length; + + Utils.VarInt packetId = Utils.readVarInt(data, length.length); + assert packetId.value == 2; + + int pos = length.length + packetId.length; + Utils.VarInt modCount = Utils.readVarInt(data, pos); + pos += modCount.length; + + List mods = new ArrayList<>(); + for(int i = 0; i < modCount.value; i++) { + Utils.VarInt nameLength = Utils.readVarInt(data, pos); + pos += nameLength.length; + + mods.add(Mod.get(new String(data, pos, nameLength.value), Mod.Platform.FORGE)); + pos += nameLength.value; } + + PendingConnection connection = event.getConnection(); + if(Utils.handleMods(connection.getUniqueId(), Locale.getDefault(), connection::disconnect, mods)) + event.completeIntent(BungeeCore.get()); } } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge12.java b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java new file mode 100644 index 00000000..eb463f40 --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java @@ -0,0 +1,113 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2022 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.mods; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.listeners.BasicListener; +import de.steamwar.bungeecore.sql.Mod; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.event.PostLoginEvent; +import net.md_5.bungee.event.EventHandler; + +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class Forge12 extends BasicListener { + private static final String FMLHS = "FML|HS"; + private static final byte[] REGISTER; + private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0}; + + private static final Set unlocked = new HashSet<>(); + + static { + ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(7); + buf.writeByte(6); + buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8); + REGISTER = new byte[buf.readableBytes()]; + buf.readBytes(REGISTER); + } + + + @EventHandler + public void onPostLogin(PostLoginEvent event) { + ProxiedPlayer player = event.getPlayer(); + + synchronized (unlocked) { + if(unlocked.contains(player.getUniqueId())){ + unlocked.remove(player.getUniqueId()); + return; + } + } + + if(player.getPendingConnection().getVersion() <= 340) { + player.sendData("REGISTER", REGISTER); //1.12- + player.sendData(FMLHS, HELLO); + } + } + + @EventHandler + public void onPluginMessageEvent(PluginMessageEvent e){ + if(!e.getTag().equals(FMLHS)) + return; + + e.setCancelled(true); + byte[] data = e.getData(); + + Connection sender = e.getSender(); + if(!(sender instanceof ProxiedPlayer)) + return; + ProxiedPlayer p = (ProxiedPlayer) sender; + + if (data[0] == 2) { + Utils.VarInt numMods = Utils.readVarInt(data, 1); + List mods = new LinkedList<>(); + + int bytePos = 1 + numMods.length; + for (int i = 0; i < numMods.value; i++) { + byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1); + bytePos += 1 + data[bytePos]; + //Version information is unused + bytePos += 1 + data[bytePos]; + + mods.add(Mod.get(new String(name), Mod.Platform.FORGE)); + } + + if (Utils.handleMods(p, mods)) { + synchronized (unlocked) { + unlocked.add(p.getUniqueId()); + } + ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), + () -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")), + 2, TimeUnit.SECONDS); + ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { + synchronized (unlocked) { + unlocked.remove(p.getUniqueId()); + } + }, 30, TimeUnit.SECONDS); + } + } + } +} diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index 9ed160af..417f8464 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -25,6 +25,8 @@ import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Mod.ModType; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.sql.Timestamp; @@ -32,6 +34,9 @@ import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Iterator; import java.util.List; +import java.util.Locale; +import java.util.UUID; +import java.util.function.Consumer; import java.util.logging.Level; class Utils { @@ -55,9 +60,13 @@ class Utils { return new VarInt(numRead, result); } - static boolean handleMods(ProxiedPlayer player, List mods){ - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - boolean privileged = player.hasPermission("bungeecore.youtubermods"); + static boolean handleMods(ProxiedPlayer player, List mods) { + return handleMods(player.getUniqueId(), player.getLocale(), player::disconnect, mods); + } + + static boolean handleMods(UUID uuid, Locale locale, Consumer disconnect, List mods){ + SteamwarUser user = SteamwarUser.get(uuid); + boolean privileged = user.getUserGroup().privilegedMods(); ModType max = ModType.YELLOW; Iterator it = mods.iterator(); @@ -74,9 +83,9 @@ class Utils { if(mods.size() == 1){ if(max == ModType.YELLOW) - player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_SING", player, mods.get(0).getModName()))); + disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_SING", locale, mods.get(0).getModName()))); else{ - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", player, mods.get(0).getModName()), 0, false); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", locale, mods.get(0).getModName()), 0, false); BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen des Mods " + mods.get(0).getModName() + " gebannt."); } }else{ @@ -84,10 +93,10 @@ class Utils { mods.forEach(mod -> sb.append(mod.getModName()).append('\n')); if(max == ModType.YELLOW) - player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_PLUR", player, sb.toString()))); + disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_PLUR", locale, sb.toString()))); else{ - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", player, sb.toString()), 0, false); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb.toString() + " gebannt."); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", locale, sb.toString()), 0, false); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb + " gebannt."); } } diff --git a/src/de/steamwar/bungeecore/sql/UserGroup.java b/src/de/steamwar/bungeecore/sql/UserGroup.java index 73273dcf..e6c30f9a 100644 --- a/src/de/steamwar/bungeecore/sql/UserGroup.java +++ b/src/de/steamwar/bungeecore/sql/UserGroup.java @@ -24,26 +24,28 @@ import java.util.stream.Collectors; public enum UserGroup { - Admin("§4", "§e", true, true, true), - Developer("§3", "§f", true, true, true), - Moderator("§c", "§f", true, true, true), - Supporter("§9", "§f", false, true, true), - Builder("§2", "§f", false, true, false), - YouTuber("§5", "§f", false, false, false), - Member("§7", "§7", false, false, false); + Admin("§4", "§e", true, true, true, true), + Developer("§3", "§f", true, true, true, true), + Moderator("§c", "§f", true, true, true, true), + Supporter("§9", "§f", false, true, true, true), + Builder("§2", "§f", false, true, false, true), + YouTuber("§5", "§f", false, false, false, true), + Member("§7", "§7", false, false, false, false); private final String colorCode; private final String chatColorCode; private final boolean adminGroup; private final boolean teamGroup; private final boolean checkSchematics; + private final boolean privilegedMods; - UserGroup(String colorCode, String chatColorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics) { + UserGroup(String colorCode, String chatColorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics, boolean privilegedMods) { this.colorCode = colorCode; this.chatColorCode = chatColorCode; this.adminGroup = adminGroup; this.teamGroup = teamGroup; this.checkSchematics = checkSchematics; + this.privilegedMods = privilegedMods; } public String getColorCode() { @@ -62,6 +64,10 @@ public enum UserGroup { return checkSchematics; } + public boolean privilegedMods() { + return privilegedMods; + } + public String getChatColorCode() { return chatColorCode; } From 4e6daaa8c061d7c06add9095a551eaa1907aff61 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 29 Jan 2022 13:56:24 +0100 Subject: [PATCH 38/56] Java 8 for 1.8 - 1.10 Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Node.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/Node.java b/src/de/steamwar/bungeecore/Node.java index d53d2e8e..bf4b3e95 100644 --- a/src/de/steamwar/bungeecore/Node.java +++ b/src/de/steamwar/bungeecore/Node.java @@ -22,10 +22,7 @@ package de.steamwar.bungeecore; import net.md_5.bungee.api.ProxyServer; import java.io.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.logging.Level; @@ -34,6 +31,14 @@ public abstract class Node { private static final List OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml"); private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB + private static final Set JAVA_8 = new HashSet<>(); + static { + JAVA_8.add("paper-1.8.8.jar"); + JAVA_8.add("paper-1.10.2.jar"); + JAVA_8.add("spigot-1.8.8.jar"); + JAVA_8.add("spigot-1.9.4.jar"); + JAVA_8.add("spigot-1.10.2.jar"); + } private static final List nodes = new ArrayList<>(); public static Node local = null; @@ -74,7 +79,10 @@ public abstract class Node { public abstract double getLoad(); protected void constructServerstart(File directory, List cmd, String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams) { - cmd.add("java"); + if (JAVA_8.contains(serverJar)) + cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java"); + else + cmd.add("java"); for(String param : dParams){ cmd.add("-D" + param); From ec74034c0b5175f1a8181cd42b8d697c5c154871 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 31 Jan 2022 08:34:27 +0100 Subject: [PATCH 39/56] Fix NPE Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/ArenaCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/ArenaCommand.java b/src/de/steamwar/bungeecore/commands/ArenaCommand.java index c5f9c20a..9abd0f5b 100644 --- a/src/de/steamwar/bungeecore/commands/ArenaCommand.java +++ b/src/de/steamwar/bungeecore/commands/ArenaCommand.java @@ -46,7 +46,7 @@ public class ArenaCommand extends BasicCommand { } Subserver subserver = Subserver.getSubserver(server); - if(subserver.getType() != Servertype.ARENA) { + if(subserver == null || subserver.getType() != Servertype.ARENA) { Message.send("ARENA_NOT_FOUND", player); return; } From 0033de233b062a2e7d19fdf122f5eb614c6d1169 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 31 Jan 2022 16:58:48 +0100 Subject: [PATCH 40/56] FmlPing now multi versions --- .../bungeecore/listeners/mods/FMLPing.java | 48 +++++++++++++++++-- .../bungeecore/listeners/mods/Forge.java | 2 +- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index 4ed9a01c..c7f68c84 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -21,14 +21,17 @@ package de.steamwar.bungeecore.listeners.mods; import net.md_5.bungee.api.ServerPing; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; public class FMLPing extends ServerPing { - private final ForgeData forgeData = new ForgeData(); + private final ForgeData forgeData; - public FMLPing(ServerPing existing) { + public FMLPing(ServerPing existing, int version) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); + forgeData = new ForgeData(version); } private static class ForgeData { @@ -36,14 +39,51 @@ public class FMLPing extends ServerPing { private final List mods = new ArrayList<>(); private final int fmlNetworkVersion = 2; - public ForgeData() { + public ForgeData(int versionNumber) { channels.add(new ForgeChannel("minecraft:unregister")); channels.add(new ForgeChannel("minecraft:register")); channels.add(new ForgeChannel("fml:handshake")); - mods.add(new ForgeMod("minecraft", "1.15.2")); + mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber).toString())); mods.add(new ForgeMod("forge", "ANY")); } + public enum ProtocolVersion { + MINECRAFT_1_18(757), + MINECRAFT_1_17_1(756), + MINECRAFT_1_16_5(754), + MINECRAFT_1_15_2(578), + MINECRAFT_1_14_4(498), + MINECRAFT_1_13(393), + UNKNOWN(0); + + private int number; + + ProtocolVersion(int versionNumber) { + this.number = versionNumber; + } + + private static Map numbers; + + static { + numbers = new LinkedHashMap<>(); + for(ProtocolVersion version : values()) { + numbers.put(version.number, version); + } + } + + public static ProtocolVersion getVersion(int versionNumber) { + ProtocolVersion protocolVersion = numbers.get(versionNumber); + if (protocolVersion != null) { + return protocolVersion; + } + return UNKNOWN; + } + + public String toString() { + return name().replace("MINECRAFT_", "").replace("_", "."); + } + } + private static class ForgeChannel { private final String res; private final String version = "FML2"; diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 99d46143..95219659 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -55,7 +55,7 @@ public class Forge extends BasicListener { @EventHandler public void onServerPing(ProxyPingEvent event) { - event.setResponse(new FMLPing(event.getResponse())); + event.setResponse(new FMLPing(event.getResponse(), event.getConnection().getVersion())); } @EventHandler From 75e744435c7456f47c59f6ce74750bb65eebbe25 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 31 Jan 2022 17:21:18 +0100 Subject: [PATCH 41/56] Performance --- .../bungeecore/listeners/mods/FMLPing.java | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java index c7f68c84..a8b59947 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java @@ -20,10 +20,7 @@ package de.steamwar.bungeecore.listeners.mods; import net.md_5.bungee.api.ServerPing; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class FMLPing extends ServerPing { @@ -43,44 +40,26 @@ public class FMLPing extends ServerPing { channels.add(new ForgeChannel("minecraft:unregister")); channels.add(new ForgeChannel("minecraft:register")); channels.add(new ForgeChannel("fml:handshake")); - mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber).toString())); + mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber))); mods.add(new ForgeMod("forge", "ANY")); } - public enum ProtocolVersion { - MINECRAFT_1_18(757), - MINECRAFT_1_17_1(756), - MINECRAFT_1_16_5(754), - MINECRAFT_1_15_2(578), - MINECRAFT_1_14_4(498), - MINECRAFT_1_13(393), - UNKNOWN(0); + public final static class ProtocolVersion { - private int number; - - ProtocolVersion(int versionNumber) { - this.number = versionNumber; - } - - private static Map numbers; + private static final HashMap versions; static { - numbers = new LinkedHashMap<>(); - for(ProtocolVersion version : values()) { - numbers.put(version.number, version); - } + versions = new HashMap(); + versions.put(757, "1.18"); + versions.put(756, "1.17.1"); + versions.put(754, "1.16.5"); + versions.put(578, "1.15.2"); + versions.put(498, "1.14.1"); + versions.put(393, "1.13"); } - public static ProtocolVersion getVersion(int versionNumber) { - ProtocolVersion protocolVersion = numbers.get(versionNumber); - if (protocolVersion != null) { - return protocolVersion; - } - return UNKNOWN; - } - - public String toString() { - return name().replace("MINECRAFT_", "").replace("_", "."); + public static String getVersion(int version) { + return versions.get(version); } } From 70056b838eceff67a5adb983d1b92f993c08d890 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 31 Jan 2022 21:20:19 +0100 Subject: [PATCH 42/56] Fix missing value read Signed-off-by: Lixfel --- .../steamwar/bungeecore/listeners/mods/Forge.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 95219659..2a6a8cab 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -101,13 +101,18 @@ public class Forge extends BasicListener { } //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 - Utils.VarInt length = Utils.readVarInt(data, 0); - assert length.length + length.value == data.length; + Utils.VarInt channelLength = Utils.readVarInt(data, 0); + int pos = channelLength.length; + assert new String(data, pos, channelLength.value).equals("fml:handshake"); - Utils.VarInt packetId = Utils.readVarInt(data, length.length); + Utils.VarInt length = Utils.readVarInt(data, pos); + pos += length.length; + assert channelLength.length + channelLength.value + length.length + length.value == data.length; + + Utils.VarInt packetId = Utils.readVarInt(data, pos); + pos += packetId.length; assert packetId.value == 2; - int pos = length.length + packetId.length; Utils.VarInt modCount = Utils.readVarInt(data, pos); pos += modCount.length; From 7e3563838b5a00ae9c0da45212afd969ac1e411f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 3 Feb 2022 21:17:08 +0100 Subject: [PATCH 43/56] Fix permissions Signed-off-by: Lixfel --- 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 11da6847..cc9b8ef6 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -119,7 +119,7 @@ public class BauCommand extends BasicCommand { return; } - new BauweltMember(p.getUniqueId(), target.getUuid(), true, false); + new BauweltMember(p.getUniqueId(), target.getUuid(), false, false); Message.send("BAU_ADDMEMBER_ADDED", p); ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid()); From 4fa7437b279e5d28168d0f3730d5b2f964ca2ccf Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 3 Feb 2022 22:02:56 +0100 Subject: [PATCH 44/56] Yes --- src/de/steamwar/bungeecore/commands/CheckCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index ba662c03..a74dc788 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -301,7 +301,6 @@ public class CheckCommand extends BasicCommand { } private void decline(String reason){ - schematic.setType(SchematicType.Normal.toDB()); CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason); SteamwarUser user = SteamwarUser.get(schematic.getOwner()); ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid()); @@ -311,6 +310,7 @@ public class CheckCommand extends BasicCommand { DiscordSchemAlert.sendDecline(schematic, user, reason); } Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason); + schematic.setType(SchematicType.Normal.toDB()); stop(); } From bc8042816d1338a0648ab73aa3c1cc1b2895ea55 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 4 Feb 2022 12:39:52 +0100 Subject: [PATCH 45/56] Add opens for 1.18 Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Node.java b/src/de/steamwar/bungeecore/Node.java index bf4b3e95..aa1eb8e6 100644 --- a/src/de/steamwar/bungeecore/Node.java +++ b/src/de/steamwar/bungeecore/Node.java @@ -29,7 +29,7 @@ import java.util.logging.Level; public abstract class Node { - private static final List OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml"); + private static final List OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", "-Dlog4j.configurationFile=log4j2.xml"); private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB private static final Set JAVA_8 = new HashSet<>(); static { From cce444719d8f1fb4f479f755fcb87ad6f163dd7e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 4 Feb 2022 12:56:51 +0100 Subject: [PATCH 46/56] Fix build Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 24b494b4..b3be7cb2 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -67,7 +67,6 @@ public class BungeeCore extends Plugin { private ErrorLogger errorLogger; - @Override public void onEnable(){ getProxy().registerChannel("sw:bridge"); From 0f47914c4d3616438a275d7e38482b8894b20af3 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 4 Feb 2022 12:59:47 +0100 Subject: [PATCH 47/56] Hotfix message Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index f755cdf1..a54694ed 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -64,6 +64,8 @@ public class Message { } private static String parse(String message, boolean prefixed, Locale locale, Object... params){ + if(locale == null) + locale = Locale.getDefault(); ResourceBundle resourceBundle = ResourceBundle.getBundle("de.steamwar.messages.BungeeCore", locale, CONTROL); String pattern = ""; if(prefixed) From d1e62690dd36bb27d32507d91f058638257fc747 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Feb 2022 17:36:18 +0100 Subject: [PATCH 48/56] Fix delete future teams Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/TeamTeilnahme.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java index e8eabbaa..1688cefb 100644 --- a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java +++ b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java @@ -28,7 +28,7 @@ public class TeamTeilnahme { private static final Statement insert = new Statement("INSERT INTO TeamTeilnahme (TeamID, EventID) VALUES (?, ?)"); private static final Statement delete = new Statement("DELETE FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); - private static final Statement deleteFuture = new Statement("DELETE FROM TeamTeilnahme t WHERE t.TeamID = ? AND (SELECT e.Start FROM Event e WHERE e.EventID = t.EventID) > NOW()"); + private static final Statement deleteFuture = new Statement("DELETE t FROM TeamTeilnahme t INNER JOIN Event e ON t.EventID = e.EventID WHERE t.TeamID = ? AND e.Start > NOW()"); private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?"); private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?"); From 29b228bd8dde4f1649c1b9859d757f1edfb9dd78 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Feb 2022 17:39:29 +0100 Subject: [PATCH 49/56] Fix whois -a 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 e9422f4c..0a948903 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -537,7 +537,7 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand -WHOIS_USAGE=§c/whois [Spieler/ID] \{-a\} +WHOIS_USAGE=§c/whois [Spieler/ID] <-a> WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eUUID Kopieren From 265daaa44d72e46d72f3b586da3e58db8ef4ad00 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Feb 2022 17:45:55 +0100 Subject: [PATCH 50/56] Fix Java 8 start Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Node.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Node.java b/src/de/steamwar/bungeecore/Node.java index aa1eb8e6..f07293aa 100644 --- a/src/de/steamwar/bungeecore/Node.java +++ b/src/de/steamwar/bungeecore/Node.java @@ -29,7 +29,7 @@ import java.util.logging.Level; public abstract class Node { - private static final List OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", "-Dlog4j.configurationFile=log4j2.xml"); + private static final List OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml"); private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB private static final Set JAVA_8 = new HashSet<>(); static { @@ -90,6 +90,10 @@ public abstract class Node { cmd.add("-Xmx" + xmx); cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName()); cmd.addAll(OPENJ9_ARGS); + if (!JAVA_8.contains(serverJar)) { + cmd.add("--add-opens"); + cmd.add("java.base/jdk.internal.misc=ALL-UNNAMED"); + } cmd.add("-jar"); cmd.add("/binarys/" + serverJar); cmd.add("--log-strip-color"); From ffa5dc8bc262d6c97ec76045fb32a62e1c6bf02c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Feb 2022 17:47:41 +0100 Subject: [PATCH 51/56] No authenticating errors Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ErrorLogger.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/ErrorLogger.java b/src/de/steamwar/bungeecore/ErrorLogger.java index 80b417f1..17799bea 100644 --- a/src/de/steamwar/bungeecore/ErrorLogger.java +++ b/src/de/steamwar/bungeecore/ErrorLogger.java @@ -91,6 +91,7 @@ public class ErrorLogger extends Handler { contains.add("DownstreamBridge"); contains.add(" took "); contains.add("No client connected for pending server!"); + contains.add("Error authenticating "); ignoreContains = Collections.unmodifiableList(contains); } } From f97f135efcc27e39fd4fd3415762a2a6c6e87877 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Feb 2022 17:57:55 +0100 Subject: [PATCH 52/56] Better Forge failure debugging Signed-off-by: Lixfel --- .../bungeecore/listeners/mods/Forge.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 2a6a8cab..e94d21dc 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.event.LoginEvent; import net.md_5.bungee.api.event.ProxyPingEvent; @@ -103,15 +104,24 @@ public class Forge extends BasicListener { //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 Utils.VarInt channelLength = Utils.readVarInt(data, 0); int pos = channelLength.length; - assert new String(data, pos, channelLength.value).equals("fml:handshake"); + if(!new String(data, pos, channelLength.value).equals("fml:handshake")) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)")); + return; + } Utils.VarInt length = Utils.readVarInt(data, pos); pos += length.length; - assert channelLength.length + channelLength.value + length.length + length.value == data.length; + if(channelLength.length + channelLength.value + length.length + length.value != data.length) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x01)")); + return; + } Utils.VarInt packetId = Utils.readVarInt(data, pos); pos += packetId.length; - assert packetId.value == 2; + if(packetId.value != 2) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x02)")); + return; + } Utils.VarInt modCount = Utils.readVarInt(data, pos); pos += modCount.length; From 9ca14b7565c7fedd0d80014873dfe8ff48a203a9 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Feb 2022 16:36:52 +0100 Subject: [PATCH 53/56] Fix Forgemods Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Forge.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index e94d21dc..cb88649c 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -108,6 +108,7 @@ public class Forge extends BasicListener { event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)")); return; } + pos += channelLength.value; Utils.VarInt length = Utils.readVarInt(data, pos); pos += length.length; From 50ee5c6e95eb2363743de69eb8d422d87aed9d40 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Feb 2022 17:52:16 +0100 Subject: [PATCH 54/56] Hotfix forge disconnect Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Forge.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index cb88649c..c29a03cb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -137,8 +137,10 @@ public class Forge extends BasicListener { } PendingConnection connection = event.getConnection(); - if(Utils.handleMods(connection.getUniqueId(), Locale.getDefault(), connection::disconnect, mods)) - event.completeIntent(BungeeCore.get()); + if(!Utils.handleMods(connection.getUniqueId(), Locale.getDefault(), event::setCancelReason, mods)) { + event.setCancelled(true); + } + event.completeIntent(BungeeCore.get()); } } } From c88ac55b8932dbb6b0a704aabc13bf8942a99daa Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Feb 2022 18:09:00 +0100 Subject: [PATCH 55/56] Fix forge autoban disconnect Signed-off-by: Lixfel --- .../bungeecore/listeners/mods/Utils.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index 417f8464..7e3e4cc5 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -38,6 +38,7 @@ import java.util.Locale; import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Level; +import java.util.stream.Collectors; class Utils { private Utils(){} @@ -81,25 +82,22 @@ class Utils { if(mods.isEmpty()) return true; - if(mods.size() == 1){ - if(max == ModType.YELLOW) - disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_SING", locale, mods.get(0).getModName()))); - else{ - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", locale, mods.get(0).getModName()), 0, false); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen des Mods " + mods.get(0).getModName() + " gebannt."); - } - }else{ - StringBuilder sb = new StringBuilder(); - mods.forEach(mod -> sb.append(mod.getModName()).append('\n')); + ModType finalMax = max; + String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n")); + String message; - if(max == ModType.YELLOW) - disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_PLUR", locale, sb.toString()))); - else{ - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", locale, sb.toString()), 0, false); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb + " gebannt."); - } + if(mods.size() == 1) { + message = Message.parse(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList); + } else { + message = Message.parse(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList); } + if(max == ModType.RED) { + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt."); + } + + disconnect.accept(TextComponent.fromLegacyText(message)); return false; } From 45dc9c148ee4ffcae8d4470b66b2fce77a639c7a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 28 Feb 2022 17:38:04 +0100 Subject: [PATCH 56/56] Fix team changeleader -> promote Signed-off-by: Lixfel --- 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 58a3c355..0cd0277d 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -647,7 +647,7 @@ public class TeamCommand extends BasicCommand { tab.add("event"); tab.add("changekuerzel"); tab.add("changename"); - tab.add("changeleader"); + tab.add("promote"); tab.add("changecolor"); }else if(args.length == 2){ if(args[1].equalsIgnoreCase("event")){