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
|
2021-06-16 01:41:38 +02:00
|
|
|
index b5f72467b924d2bb7871b5af547ee794b8080803..cbd7e9b6b3d0cd5cb87ed8b2657daee9368424a0 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
|
2021-06-13 07:13:07 +02:00
|
|
|
@@ -1641,8 +1641,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
|
2021-06-16 01:41:38 +02:00
|
|
|
index 161fcf68dc85fc6d7b0034f137b1a5aee26cbb69..03b2fd38b31de911ef107006a3d10c5534989247 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
|
2021-06-13 07:13:07 +02:00
|
|
|
@@ -142,6 +142,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);
|
2021-06-16 01:41:38 +02:00
|
|
|
@@ -1896,6 +1900,32 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
public boolean getAffectsSpawning() {
|
|
|
|
return this.getHandle().affectsSpawning;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setResourcePack(String url, String hash) {
|
|
|
|
+ Validate.notNull(url, "Resource pack URL cannot be null");
|
|
|
|
+ Validate.notNull(hash, "Hash cannot be null");
|
2021-06-12 02:57:04 +02:00
|
|
|
+ this.getHandle().sendTexturePack(url, hash, false, new net.minecraft.network.chat.TextComponent(""));
|
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
|