From 42c23e452194ae270c076443b3cb333093fe309b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 18 Feb 2023 11:04:29 +0100 Subject: [PATCH 1/4] Add exception log --- .../bungeecore/listeners/NonFabricFabricCheck.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java index b903b9c..2a1fd2b 100644 --- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java +++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java @@ -22,6 +22,8 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; +import de.steamwar.bungeecore.sql.SWException; +import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -80,7 +82,12 @@ public class NonFabricFabricCheck extends BasicListener { @EventHandler public void onPlayerDisconnect(PlayerDisconnectEvent e) { if (checking.remove(e.getPlayer())) { + logMessage(SteamwarUser.get(e.getPlayer().getUniqueId()), "Player is potentially using rebranded Fabric"); usingFabric.add(e.getPlayer().getUniqueId()); } } + + public void logMessage(SteamwarUser user, String reason) { + SWException.log("Bungee", "NonFabricFabricCheck " + user.getUserName() + ": " + reason, ""); + } } -- 2.39.2 From 05b6b3ac66748186405e5142823ad9a5b48e611b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 18 Feb 2023 12:49:24 +0100 Subject: [PATCH 2/4] Add even better fabric check --- .../listeners/NonFabricFabricCheck.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java index 2a1fd2b..08f44a0 100644 --- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java +++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java @@ -22,8 +22,6 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; -import de.steamwar.bungeecore.sql.SWException; -import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -43,6 +41,7 @@ public class NonFabricFabricCheck extends BasicListener { private final Set usingFabric = new HashSet<>(); private final Set checking = new HashSet<>(); + private final Set vanilla = new HashSet<>(); { BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), usingFabric::clear, 0, 15, TimeUnit.MINUTES); @@ -54,14 +53,23 @@ public class NonFabricFabricCheck extends BasicListener { if(!(sender instanceof ProxiedPlayer)) return; - if(!e.getTag().equals("minecraft:brand")) - return; - - if(!new String(e.getData()).equals("vanilla")){ + ProxiedPlayer p = (ProxiedPlayer) sender; + if (e.getTag().equals("minecraft:register") && new String(e.getData()).contains("fabric")) { + BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { + if (!sender.isConnected()) return; + if (!vanilla.remove(p)) return; + if (Storage.fabricCheckedPlayers.containsKey(p)) return; + p.disconnect(Message.parse("MOD_USE_MODSENDER", p)); + }, 5, TimeUnit.SECONDS); return; } - ProxiedPlayer p = (ProxiedPlayer) sender; + if(!e.getTag().equals("minecraft:brand")) + return; + + if(!new String(e.getData()).equals("vanilla")) + return; + vanilla.add(p); BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { if (!p.isConnected()) return; @@ -82,12 +90,8 @@ public class NonFabricFabricCheck extends BasicListener { @EventHandler public void onPlayerDisconnect(PlayerDisconnectEvent e) { if (checking.remove(e.getPlayer())) { - logMessage(SteamwarUser.get(e.getPlayer().getUniqueId()), "Player is potentially using rebranded Fabric"); usingFabric.add(e.getPlayer().getUniqueId()); } - } - - public void logMessage(SteamwarUser user, String reason) { - SWException.log("Bungee", "NonFabricFabricCheck " + user.getUserName() + ": " + reason, ""); + vanilla.remove(e.getPlayer()); } } -- 2.39.2 From 0dd50c7e09ec42402825ae13fb001426cad2340e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 18 Feb 2023 12:54:34 +0100 Subject: [PATCH 3/4] Update timings --- src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java index 08f44a0..3c2dbb8 100644 --- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java +++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java @@ -60,7 +60,7 @@ public class NonFabricFabricCheck extends BasicListener { if (!vanilla.remove(p)) return; if (Storage.fabricCheckedPlayers.containsKey(p)) return; p.disconnect(Message.parse("MOD_USE_MODSENDER", p)); - }, 5, TimeUnit.SECONDS); + }, 25, TimeUnit.SECONDS); return; } -- 2.39.2 From 0d6e1f54bd838ec5517f00ea4b5f510a8f822b07 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 23 Feb 2023 08:35:43 +0100 Subject: [PATCH 4/4] Update check --- src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java index 3c2dbb8..0f825ab 100644 --- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java +++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java @@ -54,7 +54,7 @@ public class NonFabricFabricCheck extends BasicListener { return; ProxiedPlayer p = (ProxiedPlayer) sender; - if (e.getTag().equals("minecraft:register") && new String(e.getData()).contains("fabric")) { + if (e.getTag().equals("minecraft:register") && new String(e.getData()).contains("fabric-screen-handler-api-v1:open_screen")) { BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { if (!sender.isConnected()) return; if (!vanilla.remove(p)) return; -- 2.39.2