From 202dab5c98f0a7c457bdc93764b162b1ad384c7a Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 12 May 2013 09:28:36 +1000 Subject: [PATCH] Add texture pack API --- .../net/md_5/bungee/api/connection/ProxiedPlayer.java | 8 ++++++++ proxy/src/main/java/net/md_5/bungee/UserConnection.java | 7 +++++++ .../java/net/md_5/bungee/connection/UpstreamBridge.java | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index dd029e4e..c89daf06 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -2,6 +2,7 @@ package net.md_5.bungee.api.connection; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.config.TexturePackInfo; /** * Represents a player who's connection is being connected to somewhere else, @@ -69,4 +70,11 @@ public interface ProxiedPlayer extends Connection, CommandSender * @param message the message to say */ public void chat(String message); + + /** + * Send a request to change the players texture pack. + * + * @param pack the pack to request + */ + public void setTexturePack(TexturePackInfo pack); } 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 143df985..16b8fe5d 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -21,6 +21,7 @@ import lombok.Setter; 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.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PermissionCheckEvent; import net.md_5.bungee.api.event.ServerConnectEvent; @@ -314,4 +315,10 @@ public final class UserConnection implements ProxiedPlayer Preconditions.checkState( this.clientEntityId == 0, "Client entityId already set!" ); this.clientEntityId = clientEntityId; } + + @Override + public void setTexturePack(TexturePackInfo pack) + { + sendPacket( new PacketFAPluginMessage( "MC|TPack", ( pack.getUrl() + "\00" + pack.getSize() ).getBytes() ) ); + } } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 90d60e31..b1991461 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -35,7 +35,7 @@ public class UpstreamBridge extends PacketHandler TexturePackInfo texture = con.getPendingConnection().getListener().getTexturePack(); if ( texture != null ) { - con.sendPacket( new PacketFAPluginMessage( "MC|TPack", ( texture.getUrl() + "\00" + texture.getSize() ).getBytes() ) ); + con.setTexturePack( texture ); } }