diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index bc7aef61e1..f977efb6aa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -36,6 +36,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -670,6 +671,26 @@ public final class CraftServer implements Server { return this.configuration.getBoolean("settings.query-plugins"); } + @Override + public String getResourcePack() { + return this.getServer().getResourcePack(); + } + + @Override + public String getResourcePackHash() { + return this.getServer().getResourcePackHash().toUpperCase(Locale.ROOT); + } + + @Override + public String getResourcePackPrompt() { + return CraftChatMessage.fromComponent(this.getServer().getResourcePackPrompt()); + } + + @Override + public boolean isResourcePackRequired() { + return this.getServer().isResourcePackRequired(); + } + @Override public boolean hasWhitelist() { return this.getProperties().whiteList.get(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index e857e5c1b6..44fcc736f9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1306,18 +1306,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setResourcePack(String url) { - Validate.notNull(url, "Resource pack URL cannot be null"); - - getHandle().sendTexturePack(url, "null", false, null); + setResourcePack(url, null); } @Override public void setResourcePack(String url, byte[] hash) { - Validate.notNull(url, "Resource pack URL cannot be null"); - Validate.notNull(hash, "Resource pack hash cannot be null"); - Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length); + setResourcePack(url, hash, false); + } - getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null); + @Override + public void setResourcePack(String url, byte[] hash, String prompt) { + setResourcePack(url, hash, prompt, false); + } + + @Override + public void setResourcePack(String url, byte[] hash, boolean force) { + setResourcePack(url, hash, null, force); + } + + @Override + public void setResourcePack(String url, byte[] hash, String prompt, boolean force) { + Validate.notNull(url, "Resource pack URL cannot be null"); + + if (hash != null) { + Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length); + + getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), force, CraftChatMessage.fromStringOrNull(prompt, true)); + } else { + getHandle().sendTexturePack(url, "", force, CraftChatMessage.fromStringOrNull(prompt, true)); + } } public void addChannel(String channel) {