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 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
|
2023-08-06 02:21:59 +02:00
|
|
|
index c69a2da951af082b8dc90baf35b7e020ffda0b5e..cad7df80d4914b533ce9db1a10b5923b5ffe578b 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -1760,8 +1760,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
2021-06-12 02:57:04 +02:00
|
|
|
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
2022-06-07 21:55:39 +02:00
|
|
|
this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
2021-06-12 02:57:04 +02:00
|
|
|
}
|
|
|
|
- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); // CraftBukkit
|
|
|
|
-
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
|
|
|
|
+ player.getBukkitEntity().setResourcePackStatus(packStatus);
|
2021-06-12 02:57:04 +02:00
|
|
|
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2021-06-12 02:57:04 +02:00
|
|
|
@Override
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-08-06 02:21:59 +02:00
|
|
|
index 3ec282a272257996fad17c3ac23b334aca344bb0..87c597ad5e7cc76db7a5da4e3d97e044ce9f8594 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -189,6 +189,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
private double healthScale = 20;
|
2022-04-16 10:29:50 +02:00
|
|
|
private CraftWorldBorder clientWorldBorder = null;
|
|
|
|
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
|
|
|
|
+ private String resourcePackHash;
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
|
|
|
super(server, entity);
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -2357,6 +2361,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
public boolean getAffectsSpawning() {
|
|
|
|
return this.getHandle().affectsSpawning;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
2021-07-12 21:42:17 +02:00
|
|
|
+ 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) {
|
2023-06-13 01:51:45 +02:00
|
|
|
+ Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
|
|
|
|
+ Preconditions.checkArgument(hash != null, "Hash cannot be null");
|
2021-07-12 21:42:17 +02:00
|
|
|
+ net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
|
|
|
|
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
|
2021-10-01 02:56:22 +02:00
|
|
|
+ null;
|
2021-07-12 21:42:17 +02:00
|
|
|
+ this.getHandle().sendTexturePack(url, hash, required, promptComponent);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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
|