SteamWar/BungeeCore
Archiviert
13
2

Add Static Server Fabric Check

Dieser Commit ist enthalten in:
Chaoscaot 2021-03-04 21:14:19 +01:00
Ursprung b5b6a624c6
Commit 3ea273767d
2 geänderte Dateien mit 14 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}
}

Datei anzeigen

@ -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<String> 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);
}
}