SPIGOT-2152: Method to set resource pack + hash.

By: Max Lee <mail@moep.tv>
This commit is contained in:
Bukkit/Spigot 2017-02-14 14:00:30 +01:00
parent 6852148a0a
commit df670812cb

View file

@ -18,6 +18,7 @@ import org.bukkit.Statistic;
import org.bukkit.WeatherType; import org.bukkit.WeatherType;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.conversations.Conversable; import org.bukkit.conversations.Conversable;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
@ -968,18 +969,23 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
* The player's client will download the new texture pack asynchronously * The player's client will download the new texture pack asynchronously
* in the background, and will automatically switch to it once the * in the background, and will automatically switch to it once the
* download is complete. If the client has downloaded and cached the same * download is complete. If the client has downloaded and cached the same
* texture pack in the past, it will perform a quick timestamp check over * texture pack in the past, it will perform a file size check against
* the network to determine if the texture pack has changed and needs to * the response content to determine if the texture pack has changed and
* be downloaded again. When this request is sent for the very first time * needs to be downloaded again. When this request is sent for the very
* from a given server, the client will first display a confirmation GUI * first time from a given server, the client will first display a
* to the player before proceeding with the download. * confirmation GUI to the player before proceeding with the download.
* <p> * <p>
* Notes: * Notes:
* <ul> * <ul>
* <li>Players can disable server textures on their client, in which * <li>Players can disable server textures on their client, in which
* case this method will have no affect on them. * case this method will have no affect on them. Use the
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
* the player loaded the pack!
* <li>There is no concept of resetting texture packs back to default * <li>There is no concept of resetting texture packs back to default
* within Minecraft, so players will have to relog to do so. * within Minecraft, so players will have to relog to do so or you
* have to send an empty pack.
* <li>The request is send with "null" as the hash. This might result
* in newer versions not loading the pack correctly.
* </ul> * </ul>
* *
* @param url The URL from which the client will download the texture * @param url The URL from which the client will download the texture
@ -999,8 +1005,8 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
* The player's client will download the new resource pack asynchronously * The player's client will download the new resource pack asynchronously
* in the background, and will automatically switch to it once the * in the background, and will automatically switch to it once the
* download is complete. If the client has downloaded and cached the same * download is complete. If the client has downloaded and cached the same
* resource pack in the past, it will perform a quick timestamp check * resource pack in the past, it will perform a file size check against
* over the network to determine if the resource pack has changed and * the response content to determine if the resource pack has changed and
* needs to be downloaded again. When this request is sent for the very * needs to be downloaded again. When this request is sent for the very
* first time from a given server, the client will first display a * first time from a given server, the client will first display a
* confirmation GUI to the player before proceeding with the download. * confirmation GUI to the player before proceeding with the download.
@ -1008,9 +1014,14 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
* Notes: * Notes:
* <ul> * <ul>
* <li>Players can disable server resources on their client, in which * <li>Players can disable server resources on their client, in which
* case this method will have no affect on them. * case this method will have no affect on them. Use the
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
* the player loaded the pack!
* <li>There is no concept of resetting resource packs back to default * <li>There is no concept of resetting resource packs back to default
* within Minecraft, so players will have to relog to do so. * within Minecraft, so players will have to relog to do so or you
* have to send an empty pack.
* <li>The request is send with "null" as the hash. This might result
* in newer versions not loading the pack correctly.
* </ul> * </ul>
* *
* @param url The URL from which the client will download the resource * @param url The URL from which the client will download the resource
@ -1022,6 +1033,43 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
*/ */
public void setResourcePack(String url); public void setResourcePack(String url);
/**
* Request that the player's client download and switch resource packs.
* <p>
* The player's client will download the new resource pack asynchronously
* in the background, and will automatically switch to it once the
* download is complete. If the client has downloaded and cached a
* resource pack with the same hash in the past it will not download but
* directly apply the cached pack. When this request is sent for the very
* first time from a given server, the client will first display a
* confirmation GUI to the player before proceeding with the download.
* <p>
* Notes:
* <ul>
* <li>Players can disable server resources on their client, in which
* case this method will have no affect on them. Use the
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
* the player loaded the pack!
* <li>There is no concept of resetting resource packs back to default
* within Minecraft, so players will have to relog to do so or you
* have to send an empty pack.
* </ul>
*
* @param url The URL from which the client will download the resource
* pack. The string must contain only US-ASCII characters and should
* be encoded as per RFC 1738.
* @param hash The sha1 hash sum of the resource pack file which is used
* to apply a cached version of the pack directly without downloading
* if it is available. Hast to be 20 bytes long!
* @throws IllegalArgumentException Thrown if the URL is null.
* @throws IllegalArgumentException Thrown if the URL is too long. The
* length restriction is an implementation specific arbitrary value.
* @throws IllegalArgumentException Thrown if the hash is null.
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
* long.
*/
public void setResourcePack(String url, byte[] hash);
/** /**
* Gets the Scoreboard displayed to this player * Gets the Scoreboard displayed to this player
* *