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
|
2022-03-16 16:57:51 +01:00
|
|
|
index 44039e85bbb53e7bf89f9572c29c21fb4b147cc7..1ff86d507700ac39752efcbfbbc9b29dcbeb1fc1 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
|
2022-03-16 16:57:51 +01:00
|
|
|
@@ -1654,8 +1654,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-12 02:57:04 +02:00
|
|
|
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
|
|
|
|
-
|
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
|
2022-03-01 04:00:17 +01:00
|
|
|
index 44d732b3f17c4848f5ce99f3120f87dd9fe2b6c0..ccf555c97ee9364c965c5194939602f91d46043f 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
|
2022-02-12 14:20:33 +01:00
|
|
|
@@ -139,6 +139,7 @@ import org.bukkit.plugin.Plugin;
|
2021-07-12 21:42:17 +02:00
|
|
|
import org.bukkit.plugin.messaging.StandardMessenger;
|
2022-02-12 14:20:33 +01:00
|
|
|
import org.bukkit.profile.PlayerProfile;
|
2021-07-12 21:42:17 +02:00
|
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
|
|
|
|
|
2022-02-12 14:20:33 +01:00
|
|
|
@@ -155,6 +156,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
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);
|
2022-03-01 04:00:17 +01:00
|
|
|
@@ -2017,6 +2022,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) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ Validate.notNull(url, "Resource pack URL cannot be null");
|
|
|
|
+ Validate.notNull(hash, "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
|