diff --git a/src/de/steamwar/bungeecore/Fabric.java b/src/de/steamwar/bungeecore/Fabric.java new file mode 100644 index 0000000..753bb42 --- /dev/null +++ b/src/de/steamwar/bungeecore/Fabric.java @@ -0,0 +1,33 @@ +package de.steamwar.bungeecore; + +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PlayerDisconnectEvent; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; + +public class Fabric implements Listener { + + @EventHandler + public void onPluginMessageEvent(PluginMessageEvent e){ + Connection sender = e.getSender(); + if(!(sender instanceof ProxiedPlayer)) + return; + + if(!e.getTag().equals("minecraft:brand")) + return; + + if(new String(e.getData()).contains("fabric")){ + ProxiedPlayer p = (ProxiedPlayer) sender; + //p.disconnect(BungeeCore.stringToText("§7Die Verwendung von Fabric ist auf §eSteam§8War §7nicht gestattet.")); + Storage.fabricPlayers.add(p); + } + } + + @EventHandler + public void onDisconnect(PlayerDisconnectEvent e){ + Storage.fabricPlayers.removeIf(player -> player == e.getPlayer()); + + } +} diff --git a/src/de/steamwar/bungeecore/Persistent.java b/src/de/steamwar/bungeecore/Persistent.java index 07fd262..c9fcbc4 100644 --- a/src/de/steamwar/bungeecore/Persistent.java +++ b/src/de/steamwar/bungeecore/Persistent.java @@ -49,6 +49,7 @@ public class Persistent extends Plugin { PluginUtils.loadPlugin(new File(getProxy().getPluginsFolder(), "BungeeCore.jar")); } }); + getProxy().getPluginManager().unregisterListener(new Fabric()); } @Override diff --git a/src/de/steamwar/bungeecore/Storage.java b/src/de/steamwar/bungeecore/Storage.java index ffea3c7..aa14aa9 100644 --- a/src/de/steamwar/bungeecore/Storage.java +++ b/src/de/steamwar/bungeecore/Storage.java @@ -22,9 +22,7 @@ package de.steamwar.bungeecore; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class Storage { private Storage(){} @@ -38,4 +36,6 @@ public class Storage { public static final Map sessions = new HashMap<>(); // Contains session start timestamp public static final Map eventServer = new HashMap<>(); // TeamID -> Subserver map + + public static final Set fabricPlayers = new HashSet<>(); } diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index 201968d..667506f 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -105,6 +105,10 @@ public class Subserver implements Runnable { } public void sendPlayer(ProxiedPlayer p){ + if(type == Servertype.ARENA) { + p.sendMessage(Persistent.getPrefix() + "§cDu darfst mit Fabric nicht auf Arenen Server!"); + return; + } if(!started){ p.sendMessage(Persistent.getPrefix() + "§7Der Server wird gestartet, einen Moment bitte..."); cachedPlayers.add(p);