From 5c1d7e1c5b6f0fb87d44cc36f36e8a43e8919351 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 4 Mar 2013 22:52:53 +1100 Subject: [PATCH] Allow setting tab list size per listener see #173 --- .../main/java/net/md_5/bungee/api/config/ListenerInfo.java | 4 ++++ proxy/src/main/java/net/md_5/bungee/UserConnection.java | 7 +++++-- proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java index 7b0f0997..9092bac3 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java @@ -24,6 +24,10 @@ public class ListenerInfo * Max amount of slots displayed on the ping page. */ private final int maxPlayers; + /** + * Number of players to be shown on the tab list. + */ + private final int tabListSize; /** * Name of the server which users will be taken to by default. */ diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index d19c720d..2673fcfc 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -27,7 +27,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.packet.*; -public class UserConnection extends GenericConnection implements ProxiedPlayer +public final class UserConnection extends GenericConnection implements ProxiedPlayer { public final Packet2Handshake handshake; @@ -119,7 +119,10 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer // Once again, first connection clientEntityId = newServer.loginPacket.entityId; serverEntityId = newServer.loginPacket.entityId; - stream.write( newServer.loginPacket ); + // Set tab list size + Packet1Login s = newServer.loginPacket; + Packet1Login login = new Packet1Login( s.entityId, s.levelType, s.gameMode, (byte) s.dimension, s.difficulty, s.unused, (byte) pendingConnection.getListener().getTabListSize() ); + stream.write( login ); stream.write( BungeeCord.getInstance().registerChannels() ); upBridge = new UpstreamBridge(); diff --git a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java index 78856d53..ded9f70d 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -181,9 +181,10 @@ public class YamlConfig implements ConfigurationAdapter String defaultServer = get( "default_server", "lobby", val ); boolean forceDefault = get( "force_default_server", false, val ); String host = get( "host", "0.0.0.0:25577", val ); + int tabListSize = get( "tab_size", 60, val ); InetSocketAddress address = Util.getAddr( host ); Map forced = get( "forced_hosts", forcedDef, val ); - ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, defaultServer, forceDefault, forced ); + ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, forceDefault, forced ); ret.add( info ); }