From f377a7680fb29ac55870fb6f73c2b5262241b8ef Mon Sep 17 00:00:00 2001 From: Wojciech Stryjewski Date: Tue, 9 Oct 2012 15:57:39 -0500 Subject: [PATCH] Add API to allow plugins to request players switch to a texture pack. Adds BUKKIT-2579 The setTexturePack method causes the player's client to download and switch to a texture pack specified by a URL. Note: Players can disable server textures on their client, in which case this API would not affect them. --- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 750e950977..beb62a00b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -47,6 +47,7 @@ import org.bukkit.inventory.InventoryView.Property; import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.messaging.Messenger; import org.bukkit.plugin.messaging.StandardMessenger; @DelegateDeserialization(CraftOfflinePlayer.class) @@ -782,6 +783,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } + public void setTexturePack(String url) { + Validate.notNull(url, "Texture pack URL cannot be null"); + + byte[] message = (url + "\0" + "16").getBytes(); + Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long"); + + getHandle().playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", message)); + } + public void addChannel(String channel) { if (channels.add(channel)) { server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel));