diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java index 32d25e3..b2c3300 100644 --- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java +++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java @@ -20,11 +20,14 @@ package de.steamwar.bungeecore.comms; public class PacketIdManager { + private PacketIdManager(){} //0x0(X) Standalone Packets - public final static byte PING_PACKET = 0x01; + public static final byte PING_PACKET = 0x01; + public static final byte TABLIST_NAME = 0x02; + //0x1(X) Bungee Inventory - public final static byte INVENTORY_PACKET = 0x10; - public final static byte INVENTORY_CALLBACK_PACKET = 0x11; - public final static byte INVENTORY_CLOSE_PACKET = 0x12; + public static final byte INVENTORY_PACKET = 0x10; + public static final byte INVENTORY_CALLBACK_PACKET = 0x11; + public static final byte INVENTORY_CLOSE_PACKET = 0x12; } diff --git a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java index 9a8da48..b18b3a0 100644 --- a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java +++ b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.comms; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import de.steamwar.bungeecore.comms.handlers.InventoryCallbackHandler; +import de.steamwar.bungeecore.comms.handlers.TablistNameHandler; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; @@ -53,5 +54,6 @@ public class SpigotReceiver extends BasicListener { static { registerHandler(PacketIdManager.INVENTORY_CALLBACK_PACKET, new InventoryCallbackHandler()); + registerHandler(PacketIdManager.TABLIST_NAME, new TablistNameHandler()); } } diff --git a/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java b/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java new file mode 100644 index 0000000..6f04943 --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/handlers/TablistNameHandler.java @@ -0,0 +1,17 @@ +package de.steamwar.bungeecore.comms.handlers; + +import com.google.common.io.ByteArrayDataInput; +import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.comms.SpigotHandler; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class TablistNameHandler implements SpigotHandler { + + @Override + public void handle(ByteArrayDataInput byteArrayDataInput) { + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUuid()); + Subserver.getSubserver(player).getTablistNames().put(player, byteArrayDataInput.readUTF()); + } +} diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 74f2e3c..d3cb3fb 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -197,6 +197,13 @@ public class TablistManager extends BasicListener { } private String getTablistName(ProxiedPlayer p, boolean sameServer) { + Subserver server = Subserver.getSubserver(p); + if(server != null){ + String tablistName = server.getTablistNames().get(p); + if(tablistName != null) + return tablistName; + } + StringBuilder st = new StringBuilder(); SteamwarUser.UserGroup group = SteamwarUser.UserGroup.getUserGroupByPermission(p);