Paper/patches/server/0061-Complete-resource-pack-API.patch
Josh Roy bc0dd0df3d Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
716b4fce Revert SnakeYAML upgrade
ca6f8942 Update to Minecraft 1.18-rc3
57e7e952 #683: Add Player#showDemoScreen

CraftBukkit Changes:
c98abfb0 Update to Minecraft 1.18-rc3
9b258501 #960: Add Player#showDemoScreen
d9542247 Produce remapped jars after bootstrap jar
99f3ddde SPIGOT-6808: Fix RegionAccessor#getBiome

Spigot Changes:
b7a4222e Update to Minecraft 1.18-rc3
2021-11-30 19:26:33 +01:00

94 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Sat, 4 Apr 2015 23:17:52 -0400
Subject: [PATCH] Complete resource pack API
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 38909ef14fcfd4b93d83512f4cacbe2c3fe431a1..76e34fb4bb6b3d194e155bec30d36887350f3ee3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1634,8 +1634,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect"));
}
- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); // CraftBukkit
-
+ // Paper start
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
+ player.getBukkitEntity().setResourcePackStatus(packStatus);
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit
+ // Paper end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index fe6ce60db2afee9a078e45ebb76c15ddeca8b9b4..7fa9227d2336eb0987d3b5a19edf35345decbcf9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -133,6 +133,7 @@ import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.scoreboard.Scoreboard;
+import org.jetbrains.annotations.NotNull;
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
@@ -149,6 +150,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private double health = 20;
private boolean scaledHealth = false;
private double healthScale = 20;
+ // Paper start
+ private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
+ private String resourcePackHash;
+ // Paper end
public CraftPlayer(CraftServer server, ServerPlayer entity) {
super(server, entity);
@@ -1919,6 +1924,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public boolean getAffectsSpawning() {
return this.getHandle().affectsSpawning;
}
+
+ @Override
+ public void setResourcePack(@NotNull String url, @NotNull String hash) {
+ this.setResourcePack(url, hash, false, null);
+ }
+
+ @Override
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required) {
+ this.setResourcePack(url, hash, required, null);
+ }
+
+ @Override
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required, net.kyori.adventure.text.Component resourcePackPrompt) {
+ Validate.notNull(url, "Resource pack URL cannot be null");
+ Validate.notNull(hash, "Hash cannot be null");
+ net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
+ null;
+ this.getHandle().sendTexturePack(url, hash, required, promptComponent);
+ }
+
+ @Override
+ public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() {
+ return this.resourcePackStatus;
+ }
+
+ @Override
+ public String getResourcePackHash() {
+ return this.resourcePackHash;
+ }
+
+ @Override
+ public boolean hasResourcePack() {
+ return this.resourcePackStatus == org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED;
+ }
+
+ public void setResourcePackStatus(org.bukkit.event.player.PlayerResourcePackStatusEvent.Status status) {
+ this.resourcePackStatus = status;
+ }
// Paper end
@Override