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 9092bac3..a9dcc1c5 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 @@ -42,4 +42,9 @@ public class ListenerInfo * transferred depending on the host they connect to. */ private final Map forcedHosts; + /** + * Get the texture pack used for servers connected to this proxy. May be + * null. + */ + private final TexturePackInfo texturePack; } diff --git a/api/src/main/java/net/md_5/bungee/api/config/TexturePackInfo.java b/api/src/main/java/net/md_5/bungee/api/config/TexturePackInfo.java new file mode 100644 index 00000000..3021ba41 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/config/TexturePackInfo.java @@ -0,0 +1,17 @@ +package net.md_5.bungee.api.config; + +import lombok.Data; + +@Data +public class TexturePackInfo +{ + + /** + * The URL of the texture pack. + */ + private final String url; + /** + * The square dimension of this texture pack. + */ + private final int size; +} diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 4eb9fb26..b797a407 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.config.TexturePackInfo; import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.scoreboard.Objective; import net.md_5.bungee.api.scoreboard.Score; @@ -19,6 +20,7 @@ import net.md_5.bungee.packet.Packet9Respawn; import net.md_5.bungee.packet.PacketCDClientStatus; import net.md_5.bungee.packet.PacketCEScoreboardObjective; import net.md_5.bungee.packet.PacketCFScoreboardScore; +import net.md_5.bungee.packet.PacketFAPluginMessage; import net.md_5.bungee.packet.PacketFDEncryptionRequest; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketHandler; @@ -90,6 +92,12 @@ public class ServerConnector extends PacketHandler (byte) user.getPendingConnection().getListener().getTabListSize() ); user.ch.write( modLogin ); ch.write( BungeeCord.getInstance().registerChannels() ); + + TexturePackInfo texture = user.getPendingConnection().getListener().getTexturePack(); + if ( texture != null ) + { + ch.write( new PacketFAPluginMessage( "MC|TPack", ( texture.getUrl() + "\00" + texture.getSize() ).getBytes() ) ); + } } else { bungee.getTabListHandler().onServerChange( user ); 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 da8cd87c..214533bc 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 @@ -20,6 +20,7 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ConfigurationAdapter; import net.md_5.bungee.api.config.ListenerInfo; import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.config.TexturePackInfo; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -185,7 +186,10 @@ public class YamlConfig implements ConfigurationAdapter 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, tabListSize, defaultServer, forceDefault, forced ); + String textureURL = get( "texture_url", null, val ); + int textureSize = get( "texture_size", null, val ); + TexturePackInfo texture = ( textureURL == null ) ? null : new TexturePackInfo( textureURL, textureSize ); + ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, forceDefault, forced, texture ); ret.add( info ); } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index e73df465..9b0b4c80 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -152,6 +152,11 @@ public class DownstreamBridge extends PacketHandler throw new CancelSendSignal(); } + if ( pluginMessage.tag.equals( "MC|TPack" ) && con.getPendingConnection().getListener().getTexturePack() != null ) + { + throw new CancelSendSignal(); + } + if ( pluginMessage.tag.equals( "BungeeCord" ) ) { ByteArrayDataOutput out = ByteStreams.newDataOutput();