From 24075306fd7526923e91b15548bdbe2a6844d655 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 11 Mar 2022 19:21:29 +0100 Subject: [PATCH 01/11] Fabric Mod Sender Integration. Mod itself is not final --- src/de/steamwar/bungeecore/BungeeCore.java | 2 + .../bungeecore/listeners/mods/Fabric.java | 45 +++++++++++++++++++ src/de/steamwar/bungeecore/sql/Mod.java | 3 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/bungeecore/listeners/mods/Fabric.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index b7338af..8e9e8fd 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -70,6 +70,7 @@ public class BungeeCore extends Plugin { @Override public void onEnable(){ getProxy().registerChannel("sw:bridge"); + getProxy().registerChannel("fabricmodsender:mods"); setInstance(this); loadConfig(); @@ -86,6 +87,7 @@ public class BungeeCore extends Plugin { new ModLoaderBlocker(); new WorldDownloader(); new BrandListener(); + new Fabric(); new Node.LocalNode(); //new Node.RemoteNode("lx"); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java new file mode 100644 index 0000000..61ae91a --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -0,0 +1,45 @@ +package de.steamwar.bungeecore.listeners.mods; + +import de.steamwar.bungeecore.listeners.BasicListener; +import de.steamwar.bungeecore.sql.Mod; +import io.netty.util.internal.StringUtil; +import net.md_5.bungee.api.connection.PendingConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.event.EventHandler; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +public class Fabric extends BasicListener { + + @EventHandler + public void onPluginMessageEvent(PluginMessageEvent e){ + if(!e.getTag().equals("fabricmodsender:mods")) + return; + + String dataString = new String(e.getData()).substring(2); + dataString = StringUtils.chop(dataString); + char x = 34; + dataString = dataString.replace(x, ' '); + dataString = dataString.replaceAll("\\s+",""); + + String[] parts = dataString.split(","); + + List mods = new ArrayList<>(); + + for(String mod : parts) { + mods.add(Mod.get(mod, Mod.Platform.FABRIC)); + } + + if (e.getSender() instanceof ProxiedPlayer) { + ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + + if(!Utils.handleMods(player, mods)) + player.disconnect(""); + } + } + +} diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index 9aad08b..dcd69ae 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -61,7 +61,8 @@ public class Mod { public enum Platform{ FORGE(0), - LABYMOD(1); + LABYMOD(1), + FABRIC(2); Platform(int value){ this.value = value; -- 2.39.2 From 3ecd31c41e9b7f9b7661188b48dcd797038bc6dd Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 11:56:54 +0100 Subject: [PATCH 02/11] Parsing ist kaputt. --- .../bungeecore/listeners/mods/Fabric.java | 91 ++++++++++++++----- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 61ae91a..6037c6e 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -1,17 +1,40 @@ +/* + 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 com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; -import io.netty.util.internal.StringUtil; -import net.md_5.bungee.api.connection.PendingConnection; +import de.steamwar.bungeecore.sql.Punishment; +import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; -import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; +import java.sql.Timestamp; +import java.time.Instant; +import java.util.*; +import java.util.logging.Level; public class Fabric extends BasicListener { @@ -20,26 +43,50 @@ public class Fabric extends BasicListener { if(!e.getTag().equals("fabricmodsender:mods")) return; - String dataString = new String(e.getData()).substring(2); - dataString = StringUtils.chop(dataString); - char x = 34; - dataString = dataString.replace(x, ' '); - dataString = dataString.replaceAll("\\s+",""); - - String[] parts = dataString.split(","); - - List mods = new ArrayList<>(); - - for(String mod : parts) { - mods.add(Mod.get(mod, Mod.Platform.FABRIC)); + if (!(e.getSender() instanceof ProxiedPlayer)) { + return; } - if (e.getSender() instanceof ProxiedPlayer) { - ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + ProxiedPlayer player = (ProxiedPlayer) e.getSender(); - if(!Utils.handleMods(player, mods)) - player.disconnect(""); + List mods = new LinkedList<>(); + + String dataString = new String(e.getData()).substring(1); + String dataString2 = "{:" + dataString + "}"; + + System.out.println(dataString2); + + try { + JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); + + for(int i = 0; i < array.size(); i++) { + mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC)); + } + + boolean isSorted = isSortedAlphabetically(mods); + + if(!isSorted) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte"); + return; + } + + Utils.handleMods(player,mods); + }catch (Exception ex) { + ex.printStackTrace(); + player.disconnect("§7Mod Verification failed! Contact a Developer"); } } + private boolean isSortedAlphabetically(List mods) { + boolean isSorted = true; + for(int i = 0; i < mods.size() - 1; i++) { + if(mods.get(i).getModName().compareToIgnoreCase(mods.get(i + 1).getModName()) > 0) { + isSorted = false; + break; + } + } + return isSorted; + } } -- 2.39.2 From 515c6f86f9e3761ad7cb80952776a86c442d5147 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 12:26:34 +0100 Subject: [PATCH 03/11] Parsing ist kaputt. --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 6037c6e..bce0548 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -52,9 +52,8 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); String dataString = new String(e.getData()).substring(1); - String dataString2 = "{:" + dataString + "}"; - System.out.println(dataString2); + System.out.println(dataString); try { JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); -- 2.39.2 From 3a6f3fb4c0e1976f00099ac725fc988742c48cf3 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:10:54 +0100 Subject: [PATCH 04/11] Parsing ist kaputt. --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index bce0548..2ec7625 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -31,6 +31,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; +import java.nio.charset.StandardCharsets; import java.sql.Timestamp; import java.time.Instant; import java.util.*; @@ -51,7 +52,7 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); - String dataString = new String(e.getData()).substring(1); + String dataString = new String(e.getData(), StandardCharsets.UTF_8).substring(1); System.out.println(dataString); -- 2.39.2 From 657c03dff17fce850d309f0e88c18ef6adcd09ad Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:35:59 +0100 Subject: [PATCH 05/11] Parsing funktioniert + notwendige mods check --- .../bungeecore/listeners/mods/Fabric.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 2ec7625..6a9c30e 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -39,6 +39,15 @@ import java.util.logging.Level; public class Fabric extends BasicListener { + private final List neededMods = new LinkedList<>(); + + { + neededMods.add("java"); + neededMods.add("minecraft"); + neededMods.add("fabricloader"); + neededMods.add("steamwarmodsender"); + } + @EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ if(!e.getTag().equals("fabricmodsender:mods")) @@ -52,9 +61,12 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); - String dataString = new String(e.getData(), StandardCharsets.UTF_8).substring(1); + byte[] data = e.getData(); + Utils.VarInt varInt = Utils.readVarInt(data,0); - System.out.println(dataString); + data = Arrays.copyOfRange(data,varInt.length, data.length); + + String dataString = new String(data, StandardCharsets.UTF_8); try { JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); @@ -68,7 +80,14 @@ public class Fabric extends BasicListener { if(!isSorted) { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte"); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); + return; + } + + if(!modsAreAbsent(mods)) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); return; } @@ -89,4 +108,12 @@ public class Fabric extends BasicListener { } return isSorted; } + + private boolean modsAreAbsent(List mods) { + return mods.stream() + .map(Mod::getModName) + .filter(neededMods::contains) + .distinct() + .count() == neededMods.size(); + } } -- 2.39.2 From c239dc780968b7a8b25e46e468ec59315a70d505 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:54:23 +0100 Subject: [PATCH 06/11] Allow Fabric on Fight Servers --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 10 +++++++++- .../bungeecore/listeners/mods/ModLoaderBlocker.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 6a9c30e..2f1c1bb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -23,11 +23,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; @@ -40,6 +42,7 @@ import java.util.logging.Level; public class Fabric extends BasicListener { private final List neededMods = new LinkedList<>(); + public static final Set checkedPlayers = new HashSet(); { neededMods.add("java"); @@ -91,13 +94,18 @@ public class Fabric extends BasicListener { return; } - Utils.handleMods(player,mods); + if(Utils.handleMods(player,mods)) checkedPlayers.add(player); }catch (Exception ex) { ex.printStackTrace(); player.disconnect("§7Mod Verification failed! Contact a Developer"); } } + @EventHandler + public void onDisconnect(PlayerDisconnectEvent e){ + checkedPlayers.remove(e.getPlayer()); + } + private boolean isSortedAlphabetically(List mods) { boolean isSorted = true; for(int i = 0; i < mods.size() - 1; i++) { diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index a4d54e6..d347d42 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener { } public static boolean isFabric(ProxiedPlayer player) { - return Storage.fabricPlayers.contains(player); + return Storage.fabricPlayers.contains(player) && !Fabric.checkedPlayers.contains(player); } public static void addServer(String server) { -- 2.39.2 From d500c376fa30f10d94852480690e3bbdaf8883f4 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:02:42 +0100 Subject: [PATCH 07/11] Messages --- .../bungeecore/listeners/mods/Fabric.java | 86 +++++++++++-------- .../listeners/mods/ModLoaderBlocker.java | 2 +- .../steamwar/messages/BungeeCore.properties | 5 ++ 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 2f1c1bb..3119452 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -19,10 +19,9 @@ package de.steamwar.bungeecore.listeners.mods; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.google.gson.*; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; @@ -34,6 +33,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; import java.nio.charset.StandardCharsets; +import java.nio.charset.UnsupportedCharsetException; import java.sql.Timestamp; import java.time.Instant; import java.util.*; @@ -41,8 +41,7 @@ import java.util.logging.Level; public class Fabric extends BasicListener { - private final List neededMods = new LinkedList<>(); - public static final Set checkedPlayers = new HashSet(); + private final Set neededMods = new HashSet<>(); { neededMods.add("java"); @@ -61,6 +60,7 @@ public class Fabric extends BasicListener { } ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); List mods = new LinkedList<>(); @@ -69,41 +69,46 @@ public class Fabric extends BasicListener { data = Arrays.copyOfRange(data,varInt.length, data.length); - String dataString = new String(data, StandardCharsets.UTF_8); + if(data.length != varInt.length + varInt.value) { + banPlayer(user,player); + } + + String dataString = ""; + + try{ + dataString = new String(data, StandardCharsets.UTF_8); + }catch (UnsupportedCharsetException exception) { + banPlayer(user, player); + } + + JsonArray array = new JsonArray(); try { - JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); - - for(int i = 0; i < array.size(); i++) { - mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC)); - } - - boolean isSorted = isSortedAlphabetically(mods); - - if(!isSorted) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); - return; - } - - if(!modsAreAbsent(mods)) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); - return; - } - - if(Utils.handleMods(player,mods)) checkedPlayers.add(player); - }catch (Exception ex) { - ex.printStackTrace(); - player.disconnect("§7Mod Verification failed! Contact a Developer"); + array = new JsonParser().parse(dataString).getAsJsonArray(); + }catch (JsonSyntaxException exception) { + banPlayer(user, player); } - } - @EventHandler - public void onDisconnect(PlayerDisconnectEvent e){ - checkedPlayers.remove(e.getPlayer()); + for(JsonElement mod : array) { + mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC)); + } + + boolean isSorted = isSortedAlphabetically(mods); + + if(!isSorted) { + banPlayer(user, player); + return; + } + + if(!modsAreAbsent(mods)) { + banPlayer(user, player); + return; + } + + if(Utils.handleMods(player,mods)) { + Storage.fabricPlayers.remove(player); + Message.send("MODIFICATION_CHECK_SUCCESS", player); + } } private boolean isSortedAlphabetically(List mods) { @@ -124,4 +129,13 @@ public class Fabric extends BasicListener { .distinct() .count() == neededMods.size(); } + + public void banPlayer(SteamwarUser user, ProxiedPlayer player) { + user.punish(Punishment.PunishmentType.Ban, + Timestamp.from(Instant.now()), + Message.parse("MODIFICATION_BAN_MESSAGE", player), + 0, + true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player)); + } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index d347d42..a4d54e6 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener { } public static boolean isFabric(ProxiedPlayer player) { - return Storage.fabricPlayers.contains(player) && !Fabric.checkedPlayers.contains(player); + return Storage.fabricPlayers.contains(player); } public static void addServer(String server) { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 19226ef..00c88de 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -583,3 +583,8 @@ RANK_UNPLACED=§eunplatziert RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8. RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) + +#Fabric Mod Sender +MODIFICATION_BAN_MESSAGE = "Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" +MODIFICATION_BAN_LOG = " hat probiert den Fabric Mod Sender zu editieren / umzugehen!" +MODIFICATION_CHECK_SUCCESS = "§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" -- 2.39.2 From 1675b1dc9cd29312806655e33a7bea15b9db7078 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:03:31 +0100 Subject: [PATCH 08/11] Fix Error --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 3119452..19e53a2 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -67,12 +67,12 @@ public class Fabric extends BasicListener { byte[] data = e.getData(); Utils.VarInt varInt = Utils.readVarInt(data,0); - data = Arrays.copyOfRange(data,varInt.length, data.length); - if(data.length != varInt.length + varInt.value) { banPlayer(user,player); } + data = Arrays.copyOfRange(data,varInt.length, data.length); + String dataString = ""; try{ -- 2.39.2 From a7525dd8a1b6ae2050c24828a2fe616c3e57c6eb Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:04:38 +0100 Subject: [PATCH 09/11] Fix Error --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 19e53a2..e80cfce 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -28,7 +28,6 @@ import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; @@ -69,24 +68,27 @@ public class Fabric extends BasicListener { if(data.length != varInt.length + varInt.value) { banPlayer(user,player); + return; } data = Arrays.copyOfRange(data,varInt.length, data.length); - String dataString = ""; + String dataString; try{ dataString = new String(data, StandardCharsets.UTF_8); }catch (UnsupportedCharsetException exception) { banPlayer(user, player); + return; } - JsonArray array = new JsonArray(); + JsonArray array; try { array = new JsonParser().parse(dataString).getAsJsonArray(); }catch (JsonSyntaxException exception) { banPlayer(user, player); + return; } for(JsonElement mod : array) { -- 2.39.2 From 98326fcaa0ea1301833773dca3fd12c826e47a2b Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 19:24:44 +0100 Subject: [PATCH 10/11] Fix Errors --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 9 ++++----- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index e80cfce..afff053 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -102,7 +102,7 @@ public class Fabric extends BasicListener { return; } - if(!modsAreAbsent(mods)) { + if(!neededModsContained(mods)) { banPlayer(user, player); return; } @@ -124,20 +124,19 @@ public class Fabric extends BasicListener { return isSorted; } - private boolean modsAreAbsent(List mods) { + private boolean neededModsContained(List mods) { return mods.stream() .map(Mod::getModName) .filter(neededMods::contains) - .distinct() .count() == neededMods.size(); } public void banPlayer(SteamwarUser user, ProxiedPlayer player) { user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), - Message.parse("MODIFICATION_BAN_MESSAGE", player), + Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()), 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player)); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 00c88de..cba41eb 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -585,6 +585,6 @@ RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) #Fabric Mod Sender -MODIFICATION_BAN_MESSAGE = "Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" -MODIFICATION_BAN_LOG = " hat probiert den Fabric Mod Sender zu editieren / umzugehen!" -MODIFICATION_CHECK_SUCCESS = "§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" +MODIFICATION_BAN_MESSAGE="Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" +MODIFICATION_BAN_LOG= "{0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!" +MODIFICATION_CHECK_SUCCESS="§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" -- 2.39.2 From 756b4da84e63215377ef1ab9823b572142d61f03 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 24 Mar 2022 13:59:14 +0100 Subject: [PATCH 11/11] Fix Errors --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index afff053..90365cd 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -137,6 +137,6 @@ public class Fabric extends BasicListener { Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()), 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); + BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index cba41eb..d8b87bf 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -585,6 +585,6 @@ RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) #Fabric Mod Sender -MODIFICATION_BAN_MESSAGE="Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" -MODIFICATION_BAN_LOG= "{0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!" -MODIFICATION_CHECK_SUCCESS="§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" +MODIFICATION_BAN_MESSAGE=Du hast probiert den FabricModSender zu umgehen / zu modifizieren! +MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen! +MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen! -- 2.39.2