diff --git a/CommonCore b/CommonCore index 74744784..595df40e 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 7474478489da42735a32e84b3f91144c64847e30 +Subproject commit 595df40e1e9078c310cbbb4bbded07744c361f15 diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 9bed4e08..a7285231 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -43,14 +43,30 @@ import java.util.concurrent.TimeUnit; public class Fabric extends BasicListener { - private final Set neededMods = new HashSet<>(); + public static void remove(ProxiedPlayer player) { + Storage.fabricCheckedPlayers.remove(player); + synchronized (Storage.fabricExpectPluginMessage) { + Storage.fabricExpectPluginMessage.remove(player); + } + } - { + private static final HashSet ppCircumventerList = new HashSet<>(); + static { + ppCircumventerList.add("java"); + ppCircumventerList.add("minecraft"); + ppCircumventerList.add("org_joml_joml"); + ppCircumventerList.add("steamwarmodsender"); + } + + private static final Set neededMods = new HashSet<>(); + static { neededMods.add("java"); neededMods.add("minecraft"); neededMods.add("fabricloader"); neededMods.add("steamwarmodsender"); + } + { BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { synchronized (Storage.fabricExpectPluginMessage) { for (Map.Entry entry : Storage.fabricExpectPluginMessage.entrySet()) { @@ -112,7 +128,7 @@ public class Fabric extends BasicListener { JsonArray array; try { - array = new JsonParser().parse(dataString).getAsJsonArray(); + array = JsonParser.parseString(dataString).getAsJsonArray(); }catch (JsonSyntaxException exception) { logMessage(user, "Invalid json", dataString); return; @@ -123,21 +139,28 @@ public class Fabric extends BasicListener { } boolean neededMods = neededModsContained(mods); - if(Utils.handleMods(player,mods) && neededMods) { - if (Storage.fabricCheckedPlayers.containsKey(player)) { - long current = Storage.fabricCheckedPlayers.get(player); - if (current != dataString.hashCode()) { - logMessage(user, "Mods changed during runtime", dataString); - return; - } - } else { - Message.send("MODIFICATION_CHECK_SUCCESS", player); - Storage.fabricCheckedPlayers.put(player, dataString.hashCode()); - } - Storage.fabricPlayers.remove(player); - } else if (!neededMods) { + if(!neededMods) { logMessage(user, "Needed mods are not contained", dataString); + return; } + + if(ppCircumventerCheck(mods)) + logMessage(user, "PP circumventer suspicion", dataString); + + if(!Utils.handleMods(player,mods)) + return; + + if (Storage.fabricCheckedPlayers.containsKey(player)) { + long current = Storage.fabricCheckedPlayers.get(player); + if (current != dataString.hashCode()) { + logMessage(user, "Mods changed during runtime", dataString); + return; + } + } else { + Message.send("MODIFICATION_CHECK_SUCCESS", player); + Storage.fabricCheckedPlayers.put(player, dataString.hashCode()); + } + Storage.fabricPlayers.remove(player); } @EventHandler @@ -155,14 +178,17 @@ public class Fabric extends BasicListener { .count() == neededMods.size(); } - public void logMessage(SteamwarUser user, String reason, String data) { + private void logMessage(SteamwarUser user, String reason, String data) { SWException.log("FabricModSender " + user.getUserName() + ": " + reason, data); } - public static void remove(ProxiedPlayer player) { - Storage.fabricCheckedPlayers.remove(player); - synchronized (Storage.fabricExpectPluginMessage) { - Storage.fabricExpectPluginMessage.remove(player); + private boolean ppCircumventerCheck(List mods) { + for(Mod mod : mods) { + String name = mod.getModName(); + if(!name.startsWith("fabric") && !ppCircumventerList.contains(name)) + return false; } + + return true; } }