From cbae6bdef1e60d2e6a931bc5d59540dee89022e1 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 12 Jul 2019 15:47:51 +0200 Subject: [PATCH] Adding server list --- .../steamwar/bungeecore/PlayerListener.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/PlayerListener.java b/src/de/steamwar/bungeecore/PlayerListener.java index 79d0cbb7..c6044663 100644 --- a/src/de/steamwar/bungeecore/PlayerListener.java +++ b/src/de/steamwar/bungeecore/PlayerListener.java @@ -1,7 +1,5 @@ package de.steamwar.bungeecore; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; import de.steamwar.bungeecore.commands.BauCommand; import de.steamwar.bungeecore.sql.BannedUserIPs; import de.steamwar.bungeecore.sql.WarkingUser; @@ -13,13 +11,12 @@ import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.config.ServerInfo; -import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.*; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; -import java.util.Arrays; +import java.util.Iterator; import java.util.List; public class PlayerListener implements Listener { @@ -113,10 +110,22 @@ public class PlayerListener implements Listener { break; } + for(Subserver subserver : Subserver.getServerList()){ + if(subserver.getType() == Servertype.ARENA){ + Iterator it = subserver.getServer().getPlayers().iterator(); + if(it.hasNext()){ + TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §ehier§7, um §e" + subserver.getServer().getName() + " §7beizutreten"); + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eArena beitreten").create())); + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + it.next().getName())); + player.sendMessage(tc); + } + } + } + if(player.getPendingConnection().getVersion() < 335){ player.sendMessage(BungeeCore.ChatPrefix + "§cWir empfehlen die Minecraft-Version 1.12.2"); } - +/* ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeUTF("FML|HS"); @@ -128,7 +137,7 @@ public class PlayerListener implements Listener { player.sendData("REGISTER", output.toByteArray()); } - player.sendData("FML|HS", new byte[]{0, 2, 0, 0, 0, 0}); + player.sendData("FML|HS", new byte[]{0, 2, 0, 0, 0, 0});*/ } /** To redirect players to the lobby in case of server closure. */ @@ -249,7 +258,7 @@ public class PlayerListener implements Listener { } } - @EventHandler + /*@EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ System.out.println(e.getSender().getAddress().getHostString() + " " + e.getTag() + " " + Arrays.toString(e.getData())); @@ -336,5 +345,5 @@ public class PlayerListener implements Listener { } while ((read & 0b10000000) != 0); return numRead; - } + }*/ }