2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-03-09 07:23:59 +01:00
|
|
|
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
|
2021-02-24 10:32:17 +01:00
|
|
|
index c9e4cb2d153fc0c6853fe520263a0073e7504e38..d1b7b0d24f15753337e211328771b3cba47bca18 100644
|
2016-03-09 07:23:59 +01:00
|
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
2021-02-24 10:32:17 +01:00
|
|
|
@@ -1173,7 +1173,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
2016-03-09 07:23:59 +01: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
|
2019-03-20 01:28:15 +01:00
|
|
|
public void setResourcePack(@NotNull String url);
|
2016-03-09 07:23:59 +01:00
|
|
|
|
|
|
|
/**
|
2021-02-24 10:32:17 +01:00
|
|
|
@@ -1635,6 +1637,60 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
2021-02-21 20:45:33 +01:00
|
|
|
default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
|
2021-02-24 00:45:26 +01:00
|
|
|
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName())));
|
2021-02-21 20:45:33 +01:00
|
|
|
}
|
|
|
|
+
|
2016-03-09 07:23:59 +01: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.
|
|
|
|
+ * <li>There is no concept of resetting resource packs back to default
|
|
|
|
+ * within Minecraft, so players will have to relog to do so.
|
|
|
|
+ * </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.
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ void setResourcePack(@NotNull String url, @NotNull String hash);
|
2016-03-09 07:23:59 +01:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return the most recent resource pack status received from the player,
|
|
|
|
+ * or null if no status has ever been received from this player.
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
2016-03-09 07:23:59 +01:00
|
|
|
+ org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return the most recent resource pack hash received from the player,
|
|
|
|
+ * or null if no hash has ever been received from this player.
|
2018-10-29 14:02:56 +01:00
|
|
|
+ *
|
|
|
|
+ * @deprecated This is no longer sent from the client and will always be null
|
2016-03-09 07:23:59 +01:00
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
2018-10-29 14:02:56 +01:00
|
|
|
+ @Deprecated
|
2016-03-09 07:23:59 +01:00
|
|
|
+ String getResourcePackHash();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return true if the last resource pack status received from this player
|
|
|
|
+ * was {@link org.bukkit.event.player.PlayerResourcePackStatusEvent.Status#SUCCESSFULLY_LOADED}
|
|
|
|
+ */
|
|
|
|
+ boolean hasResourcePack();
|
2021-02-21 20:45:33 +01:00
|
|
|
// Paper end
|
2020-01-28 20:43:57 +01:00
|
|
|
|
2021-02-21 20:45:33 +01:00
|
|
|
// Spigot start
|
2016-03-09 07:23:59 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index b98195650d49d78ec35970ca0376b6289b861e4b..4c2102a11c3d682d98f0db4ccafa35231e66bcdd 100644
|
2016-03-09 07:23:59 +01:00
|
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -11,13 +11,32 @@ import org.jetbrains.annotations.NotNull;
|
2016-03-09 07:23:59 +01:00
|
|
|
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
|
|
|
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2018-07-15 03:53:17 +02:00
|
|
|
+ @Deprecated
|
2016-03-09 07:23:59 +01:00
|
|
|
+ private final String hash; // Paper
|
|
|
|
private final Status status;
|
|
|
|
|
2019-03-20 01:28:15 +01:00
|
|
|
public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull Status resourcePackStatus) {
|
2016-03-09 07:23:59 +01:00
|
|
|
super(who);
|
|
|
|
+ this.hash = null; // Paper
|
|
|
|
this.status = resourcePackStatus;
|
|
|
|
}
|
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
+ @Deprecated // Paper
|
2016-03-09 07:23:59 +01:00
|
|
|
+ public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus, String hash) {
|
|
|
|
+ super(who);
|
|
|
|
+ this.hash = hash; // Paper
|
|
|
|
+ this.status = resourcePackStatus;
|
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 03:53:17 +02:00
|
|
|
+ @Deprecated
|
|
|
|
+ /**
|
|
|
|
+ * @deprecated Hash does not seem to ever be set
|
|
|
|
+ */
|
2016-03-09 07:23:59 +01:00
|
|
|
+ public String getHash() {
|
|
|
|
+ return this.hash;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* Gets the status of this pack.
|
|
|
|
*
|