Add texture pack API

This commit is contained in:
md_5 2013-05-12 09:28:36 +10:00
parent 49ea7f908f
commit 202dab5c98
3 changed files with 16 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package net.md_5.bungee.api.connection;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo; 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, * 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 * @param message the message to say
*/ */
public void chat(String message); 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);
} }

View File

@ -21,6 +21,7 @@ import lombok.Setter;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo; 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.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PermissionCheckEvent; import net.md_5.bungee.api.event.PermissionCheckEvent;
import net.md_5.bungee.api.event.ServerConnectEvent; 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!" ); Preconditions.checkState( this.clientEntityId == 0, "Client entityId already set!" );
this.clientEntityId = clientEntityId; this.clientEntityId = clientEntityId;
} }
@Override
public void setTexturePack(TexturePackInfo pack)
{
sendPacket( new PacketFAPluginMessage( "MC|TPack", ( pack.getUrl() + "\00" + pack.getSize() ).getBytes() ) );
}
} }

View File

@ -35,7 +35,7 @@ public class UpstreamBridge extends PacketHandler
TexturePackInfo texture = con.getPendingConnection().getListener().getTexturePack(); TexturePackInfo texture = con.getPendingConnection().getListener().getTexturePack();
if ( texture != null ) if ( texture != null )
{ {
con.sendPacket( new PacketFAPluginMessage( "MC|TPack", ( texture.getUrl() + "\00" + texture.getSize() ).getBytes() ) ); con.setTexturePack( texture );
} }
} }