From 3ea273767d5d6193ec2268803d1677da3deead8f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 4 Mar 2021 21:14:19 +0100 Subject: [PATCH] Add Static Server Fabric Check --- src/de/steamwar/bungeecore/BungeeCore.java | 3 +++ .../bungeecore/listeners/mods/ModLoaderBlocker.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 23b5e2eb..6ca32200 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -263,6 +263,9 @@ public class BungeeCore extends Plugin { serverPermissions.get(serverName), cmds.toArray(new String[0]) ); + if(server.getBoolean("modchecked", false)) { + ModLoaderBlocker.addServer(serverName); + } } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index 11e8d874..281830cf 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -29,9 +29,13 @@ import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.event.EventHandler; import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; public class ModLoaderBlocker extends BasicListener { + private static final Set BLOCKED_SERVER = new HashSet<>(); + @EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ Connection sender = e.getSender(); @@ -79,8 +83,9 @@ public class ModLoaderBlocker extends BasicListener { @EventHandler public void onServerSwitch(ServerSwitchEvent event) { - if(Subserver.getSubserver(event.getPlayer()) != null - && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA + if(((Subserver.getSubserver(event.getPlayer()) != null + && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA) + || BLOCKED_SERVER.contains(event.getPlayer().getServer().getInfo().getName())) && isFabric(event.getPlayer())) { event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER)); Message.send("MODLOADER_DENIED", event.getPlayer()); @@ -90,4 +95,8 @@ public class ModLoaderBlocker extends BasicListener { public static boolean isFabric(ProxiedPlayer player) { return Storage.fabricPlayers.contains(player); } + + public static void addServer(String server) { + BLOCKED_SERVER.add(server); + } }