Archiviert
1
0

Changed to Server Switch Event

Dieser Commit ist enthalten in:
Chaoscaot 2020-10-12 11:51:44 +02:00
Ursprung 080fae613b
Commit 2fe2074910

Datei anzeigen

@ -19,12 +19,16 @@
package de.steamwar.bungeecore.listeners.mods; package de.steamwar.bungeecore.listeners.mods;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.Connection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
public class Fabric extends BasicListener { public class Fabric extends BasicListener {
@ -41,12 +45,22 @@ public class Fabric extends BasicListener {
if(new String(e.getData()).contains("fabric")){ if(new String(e.getData()).contains("fabric")){
ProxiedPlayer p = (ProxiedPlayer) sender; ProxiedPlayer p = (ProxiedPlayer) sender;
Storage.fabricPlayers.add(p); Storage.fabricPlayers.add(p);
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast Fabric installiert. Mit Fabric kannst du nicht auf die Arenen");
} }
} }
@EventHandler @EventHandler
public void onDisconnect(PlayerDisconnectEvent e){ public void onDisconnect(PlayerDisconnectEvent e){
Storage.fabricPlayers.removeIf(player -> player == e.getPlayer()); Storage.fabricPlayers.removeIf(player -> player == e.getPlayer());
}
@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
if(Subserver.getSubserver(event.getPlayer()) != null
&& Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA
&& Storage.fabricPlayers.contains(event.getPlayer())) {
event.getPlayer().connect(event.getFrom());
BungeeCore.send(event.getPlayer(), BungeeCore.CHAT_PREFIX + "§cDu kannst nicht auf die Arena mit Fabric");
}
} }
} }