mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 21:19:00 +01:00
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.
This commit is contained in:
parent
f4836fb428
commit
f377a7680f
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user