From e723224282756358d444a3083b47eb41ff7f30ad Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 10 Apr 2022 20:14:33 +0200 Subject: [PATCH] Fix Fabric stuff --- .../bungeecore/listeners/mods/Fabric.java | 35 ++++++++----------- .../listeners/mods/ModLoaderBlocker.java | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 252aac0..4e0a852 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -38,8 +38,6 @@ 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.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -48,9 +46,6 @@ public class Fabric extends BasicListener { private final Set neededMods = new HashSet<>(); - public static final Map checkedPlayers = new HashMap<>(); - private static final Map expectPluginMessage = new HashMap<>(); - { neededMods.add("java"); neededMods.add("minecraft"); @@ -58,9 +53,9 @@ public class Fabric extends BasicListener { neededMods.add("steamwarmodsender"); BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { - synchronized (expectPluginMessage) { - for (Map.Entry entry : expectPluginMessage.entrySet()) { - if (!checkedPlayers.containsKey(entry.getKey())) { + synchronized (Storage.fabricExpectPluginMessage) { + for (Map.Entry entry : Storage.fabricExpectPluginMessage.entrySet()) { + if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) { continue; } if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) { @@ -84,15 +79,15 @@ public class Fabric extends BasicListener { ProxiedPlayer player = (ProxiedPlayer) e.getSender(); SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if (!checkedPlayers.containsKey(player)) { - synchronized (expectPluginMessage) { - if (expectPluginMessage.containsKey(player)) { + if (!Storage.fabricCheckedPlayers.containsKey(player)) { + synchronized (Storage.fabricExpectPluginMessage) { + if (Storage.fabricExpectPluginMessage.containsKey(player)) { banPlayer(user, player); return; } } } - expectPluginMessage.remove(player); + Storage.fabricExpectPluginMessage.remove(player); List mods = new LinkedList<>(); @@ -141,15 +136,15 @@ public class Fabric extends BasicListener { } if(Utils.handleMods(player,mods)) { - if (checkedPlayers.containsKey(player)) { - long current = checkedPlayers.get(player); + if (Storage.fabricCheckedPlayers.containsKey(player)) { + long current = Storage.fabricCheckedPlayers.get(player); if (current != dataString.hashCode()) { banPlayer(user, player); return; } } else { Message.send("MODIFICATION_CHECK_SUCCESS", player); - checkedPlayers.put(player, dataString.hashCode()); + Storage.fabricCheckedPlayers.put(player, dataString.hashCode()); } Storage.fabricPlayers.remove(player); } @@ -158,8 +153,8 @@ public class Fabric extends BasicListener { @EventHandler public void onServerSwitchEvent(ServerSwitchEvent e) { if (e.getFrom() == null) return; - synchronized (expectPluginMessage) { - expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis()); + synchronized (Storage.fabricExpectPluginMessage) { + Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis()); } } @@ -189,9 +184,9 @@ public class Fabric extends BasicListener { } public static void remove(ProxiedPlayer player) { - checkedPlayers.remove(player); - synchronized (expectPluginMessage) { - expectPluginMessage.remove(player); + Storage.fabricCheckedPlayers.remove(player); + synchronized (Storage.fabricExpectPluginMessage) { + Storage.fabricExpectPluginMessage.remove(player); } } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index 9965c3e..71f8220 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -46,7 +46,7 @@ public class ModLoaderBlocker extends BasicListener { if(new String(e.getData()).contains("fabric")){ ProxiedPlayer p = (ProxiedPlayer) sender; - if (!Fabric.checkedPlayers.containsKey(p) && !Storage.fabricPlayers.contains(p)) { + if (!Storage.fabricCheckedPlayers.containsKey(p) && !Storage.fabricPlayers.contains(p)) { Storage.fabricPlayers.add(p); Message.send("MODLOADER_INSTALLED_FABRIC", p, "Fabric"); }