From e4ab48a386e79575ee8dee41925320d28a760bcb Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 17 Feb 2023 17:22:49 +0100 Subject: [PATCH] Fix vanilla brand check --- .../listeners/NonFabricFabricCheck.java | 22 +++++++++++-------- .../steamwar/messages/BungeeCore.properties | 2 +- .../messages/BungeeCore_de.properties | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java index 72cbb42b..43da2407 100644 --- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java +++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java @@ -25,21 +25,27 @@ import de.steamwar.bungeecore.Storage; import net.md_5.bungee.BungeeCord; 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.PlayerDisconnectEvent; 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.util.HashSet; +import java.util.Locale; import java.util.Set; +import java.util.UUID; import java.util.concurrent.TimeUnit; public class NonFabricFabricCheck extends BasicListener { - private Set usingFabric = new HashSet<>(); + private Set usingFabric = new HashSet<>(); private Set checking = new HashSet<>(); + { + BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), usingFabric::clear, 0, 15, TimeUnit.MINUTES); + } + @EventHandler public void pluginMessageEvent(PluginMessageEvent e) { Connection sender = e.getSender(); @@ -65,18 +71,16 @@ public class NonFabricFabricCheck extends BasicListener { } @EventHandler - public void onPlayerPreLogin(PostLoginEvent e) { - if (usingFabric.contains(e.getPlayer())) { - e.getPlayer().disconnect(Message.parse("MOD_USE_MODSENDER", e.getPlayer())); - usingFabric.remove(e.getPlayer()); + public void onPlayerPreLogin(LoginEvent e) { + if (usingFabric.remove(e.getConnection().getUniqueId())) { + e.getConnection().disconnect(Message.parse("MOD_USE_MODSENDER", Locale.getDefault())); } } @EventHandler public void onPlayerDisconnect(PlayerDisconnectEvent e) { - if (checking.contains(e.getPlayer())) { - usingFabric.add(e.getPlayer()); + if (checking.remove(e.getPlayer())) { + usingFabric.add(e.getPlayer().getUniqueId()); } - checking.remove(e.getPlayer()); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 5725c9b9..926b2552 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -116,7 +116,7 @@ MOD_RED_PLUR=Attempted use of mods:\n{0} MOD_YELLOW_SING=§7Deactivate the mod §e{0}§7 to continue playing on §eSteam§8War§7. MOD_YELLOW_PLUR=§7Deactivate the mods\n§e{0}\n§7to continue playing on §eSteam§8War§7. -MOD_USE_MODSENDER=§cPlease use the §c§lSteamWarModSender§c. +MOD_USE_MODSENDER=§cPlease use the §c§lSteamWarModSender§c or say that you are using fabric. #Various commands ALERT=§f{0} diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 61110187..5a817451 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -102,7 +102,7 @@ MOD_RED_PLUR=Versuchte Benutzung der Mods:\n{0} MOD_YELLOW_SING=§7Deaktiviere den Mod §e{0}§7, um weiter auf §eSteam§8War §7spielen zu können. MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War §7spielen zu können. -MOD_USE_MODSENDER=§cBitte nutze den §c§lSteamWarModSender§c. +MOD_USE_MODSENDER=§cBitte nutze den §c§lSteamWarModSender§c oder sag uns das du Fabric nutzt. #Various commands STAT_SERVER=§7Server §e{0}§8: §7Startfähig §e{1} §7Serveranzahl §e{2}