2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
Date: Sat, 4 Apr 2015 22:59:54 -0400
|
|
|
|
Subject: [PATCH] Complete resource pack API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
index fd557f0ee33748362ee97e24822509a6020a2c33..2995dd0ec8f6e49f850865bbc9fc7e0f0e66f121 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
2023-12-05 18:33:18 +01:00
|
|
|
@@ -1717,7 +1717,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
2021-06-11 14:02:28 +02:00
|
|
|
* @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.
|
|
|
|
+ * @deprecated use {@link #setResourcePack(String, String)}
|
|
|
|
*/
|
|
|
|
+ @Deprecated // Paper
|
|
|
|
public void setResourcePack(@NotNull String url);
|
|
|
|
|
|
|
|
/**
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -2087,6 +2089,165 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
2023-12-09 00:13:02 +01:00
|
|
|
void setResourcePack(@NotNull UUID uuid, @NotNull String url, byte @Nullable [] hash, net.kyori.adventure.text.@Nullable Component prompt, boolean force);
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
+ // Paper start - more resource pack API
|
2021-06-11 14:02:28 +02:00
|
|
|
+ /**
|
|
|
|
+ * 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 the same
|
|
|
|
+ * resource pack in the past, it will perform a quick timestamp check
|
|
|
|
+ * over the network to determine if the resource pack has changed and
|
|
|
|
+ * 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
|
|
|
|
+ * 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.
|
|
|
|
+ * </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 A 40 character hexadecimal and lowercase SHA-1 digest of
|
|
|
|
+ * the resource pack file.
|
|
|
|
+ * @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.
|
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ default void setResourcePack(final @NotNull String url, final @NotNull String hash) {
|
|
|
|
+ this.setResourcePack(url, hash, false);
|
|
|
|
+ }
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+ /**
|
2021-07-12 21:42:17 +02:00
|
|
|
+ * 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 the same
|
|
|
|
+ * resource pack in the past, it will perform a quick timestamp check
|
|
|
|
+ * over the network to determine if the resource pack has changed and
|
|
|
|
+ * 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
|
|
|
|
+ * 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.
|
|
|
|
+ * </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 A 40 character hexadecimal and lowercase SHA-1 digest of
|
|
|
|
+ * the resource pack file.
|
|
|
|
+ * @param required Marks if the resource pack should be required by the client
|
|
|
|
+ * @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.
|
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ default void setResourcePack(final @NotNull String url, final @NotNull String hash, final boolean required) {
|
|
|
|
+ this.setResourcePack(url, hash, required, null);
|
|
|
|
+ }
|
2021-07-12 21:42:17 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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 the same
|
|
|
|
+ * resource pack in the past, it will perform a quick timestamp check
|
|
|
|
+ * over the network to determine if the resource pack has changed and
|
|
|
|
+ * 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
|
|
|
|
+ * 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.
|
|
|
|
+ * </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 A 40 character hexadecimal and lowercase SHA-1 digest of
|
|
|
|
+ * the resource pack file.
|
|
|
|
+ * @param required Marks if the resource pack should be required by the client
|
|
|
|
+ * @param resourcePackPrompt A Prompt to be displayed in the client request
|
|
|
|
+ * @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.
|
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ default void setResourcePack(final @NotNull String url, final @NotNull String hash, final boolean required, final net.kyori.adventure.text.@Nullable Component resourcePackPrompt) {
|
|
|
|
+ this.setResourcePack(UUID.nameUUIDFromBytes(url.getBytes(java.nio.charset.StandardCharsets.UTF_8)), url, hash, resourcePackPrompt, required);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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 the same
|
|
|
|
+ * resource pack in the past, it will perform a quick timestamp check
|
|
|
|
+ * over the network to determine if the resource pack has changed and
|
|
|
|
+ * 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
|
|
|
|
+ * 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.
|
|
|
|
+ * </ul>
|
|
|
|
+ *
|
|
|
|
+ * @param uuid Unique resource pack ID.
|
|
|
|
+ * @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 A 40 character hexadecimal and lowercase SHA-1 digest of
|
|
|
|
+ * the resource pack file.
|
|
|
|
+ * @param resourcePackPrompt A Prompt to be displayed in the client request
|
|
|
|
+ * @param required Marks if the resource pack should be required by the client
|
|
|
|
+ * @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.
|
|
|
|
+ */
|
|
|
|
+ void setResourcePack(@NotNull UUID uuid, @NotNull String url, @NotNull String hash, net.kyori.adventure.text.@Nullable Component resourcePackPrompt, boolean required);
|
|
|
|
+
|
2021-07-12 21:42:17 +02:00
|
|
|
+ /**
|
2023-12-09 00:13:02 +01:00
|
|
|
+ * Gets the most recent resource pack status from the player.
|
|
|
|
+ *
|
|
|
|
+ * @return the most recent status or null
|
2021-06-11 14:02:28 +02:00
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ org.bukkit.event.player.PlayerResourcePackStatusEvent.@Nullable Status getResourcePackStatus();
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+ /**
|
2023-12-09 00:13:02 +01:00
|
|
|
+ * Gets the most recent pack hash from the player.
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
2023-12-09 00:13:02 +01:00
|
|
|
+ * @return the most recent hash or null
|
2021-06-11 14:02:28 +02:00
|
|
|
+ * @deprecated This is no longer sent from the client and will always be null
|
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ @Deprecated(forRemoval = true)
|
|
|
|
+ @org.jetbrains.annotations.Contract("-> null")
|
|
|
|
+ default @Nullable String getResourcePackHash() {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+ /**
|
2023-12-09 00:13:02 +01:00
|
|
|
+ * Gets if the last resource pack status from the player
|
|
|
|
+ * was {@link org.bukkit.event.player.PlayerResourcePackStatusEvent.Status#SUCCESSFULLY_LOADED}.
|
|
|
|
+ *
|
|
|
|
+ * @return true if last status was successfully loaded
|
2021-06-11 14:02:28 +02:00
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ default boolean hasResourcePack() {
|
|
|
|
+ return this.getResourcePackStatus() == org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - more resource pack API
|
|
|
|
+
|
|
|
|
/**
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
* Request that the player's client remove a resource pack sent by the
|
|
|
|
* server.
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
2023-12-09 00:13:02 +01:00
|
|
|
index e2c4f9a0456cef345772d57b4d9c6e7d9598dd53..e4c32b21ab013703a6a1b07a1ad564d914ebe83f 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
2023-12-09 00:13:02 +01:00
|
|
|
@@ -21,6 +21,16 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
2021-06-11 14:02:28 +02:00
|
|
|
this.status = resourcePackStatus;
|
|
|
|
}
|
|
|
|
|
2023-12-09 00:13:02 +01:00
|
|
|
+ // Paper start - add hash (not used anymore)
|
2021-06-11 14:02:28 +02:00
|
|
|
+ /**
|
|
|
|
+ * @deprecated Hash does not seem to ever be set
|
|
|
|
+ */
|
2023-12-09 00:13:02 +01:00
|
|
|
+ @Deprecated(forRemoval = true)
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public String getHash() {
|
2023-12-09 00:13:02 +01:00
|
|
|
+ return null;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
/**
|
2023-12-06 22:59:39 +01:00
|
|
|
* Gets the unique ID of this pack.
|
2021-06-11 14:02:28 +02:00
|
|
|
*
|