From d699f639ab274d7ec76702c2b9408b7e51dd600e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 11 Oct 2020 22:54:36 +0200 Subject: [PATCH 1/4] Allow Fabric --- src/de/steamwar/bungeecore/Fabric.java | 33 ++++++++++++++++++++++ src/de/steamwar/bungeecore/Persistent.java | 1 + src/de/steamwar/bungeecore/Storage.java | 6 ++-- src/de/steamwar/bungeecore/Subserver.java | 4 +++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/bungeecore/Fabric.java 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); From 0fcaec50b22f0573d9f646b2c8dee44b54bdb5cb Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 12 Oct 2020 11:30:38 +0200 Subject: [PATCH 2/4] Moved Fabric Class --- src/de/steamwar/bungeecore/Fabric.java | 33 ---------------------- src/de/steamwar/bungeecore/Persistent.java | 1 - 2 files changed, 34 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/Fabric.java diff --git a/src/de/steamwar/bungeecore/Fabric.java b/src/de/steamwar/bungeecore/Fabric.java deleted file mode 100644 index 753bb42..0000000 --- a/src/de/steamwar/bungeecore/Fabric.java +++ /dev/null @@ -1,33 +0,0 @@ -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 c9fcbc4..07fd262 100644 --- a/src/de/steamwar/bungeecore/Persistent.java +++ b/src/de/steamwar/bungeecore/Persistent.java @@ -49,7 +49,6 @@ public class Persistent extends Plugin { PluginUtils.loadPlugin(new File(getProxy().getPluginsFolder(), "BungeeCore.jar")); } }); - getProxy().getPluginManager().unregisterListener(new Fabric()); } @Override From 0baf6fba07293eb97e16a14e2e72b07a75648bde Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 12 Oct 2020 11:34:16 +0200 Subject: [PATCH 3/4] Moved Fabric Class --- src/de/steamwar/bungeecore/Subserver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index 667506f..9cb3454 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -105,7 +105,7 @@ public class Subserver implements Runnable { } public void sendPlayer(ProxiedPlayer p){ - if(type == Servertype.ARENA) { + if(type == Servertype.ARENA && Storage.fabricPlayers.contains(p)) { p.sendMessage(Persistent.getPrefix() + "§cDu darfst mit Fabric nicht auf Arenen Server!"); return; } From 0974dec815112aa720462cd130ef850b1b0c8bb0 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 12 Oct 2020 11:52:11 +0200 Subject: [PATCH 4/4] Moved to Server Switch Event --- src/de/steamwar/bungeecore/Subserver.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index 9cb3454..201968d 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -105,10 +105,6 @@ public class Subserver implements Runnable { } public void sendPlayer(ProxiedPlayer p){ - if(type == Servertype.ARENA && Storage.fabricPlayers.contains(p)) { - 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);