Add more complete resource pack API
Dieser Commit ist enthalten in:
Ursprung
7603bda87f
Commit
9216a46316
114
Spigot-API-Patches/0021-Complete-resource-pack-API.patch
Normale Datei
114
Spigot-API-Patches/0021-Complete-resource-pack-API.patch
Normale Datei
@ -0,0 +1,114 @@
|
||||
From 1fe05b39f496bf67557f4b3141be6df53b3875fa Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
Date: Sat, 4 Apr 2015 22:59:54 -0400
|
||||
Subject: [PATCH] Complete resource pack API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index b9c9af0..b7496a3 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -1099,7 +1099,9 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
|
||||
* @throws IllegalArgumentException Thrown if the URL is null.
|
||||
* @throws IllegalArgumentException Thrown if the URL is too long. The
|
||||
* length restriction is an implementation specific arbitrary value.
|
||||
+ * @deprecated use {@link #setResourcePack(String, String)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
public void setResourcePack(String url);
|
||||
|
||||
/**
|
||||
@@ -1427,6 +1429,57 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
|
||||
*/
|
||||
public void setViewDistance(int viewDistance);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Request that the player's client download and switch resource packs.
|
||||
+ * <p>
|
||||
+ * The player's client will download the new resource pack asynchronously
|
||||
+ * in the background, and will automatically switch to it once the
|
||||
+ * download is complete. If the client has downloaded and cached the same
|
||||
+ * resource pack in the past, it will perform a quick timestamp check
|
||||
+ * over the network to determine if the resource pack has changed and
|
||||
+ * needs to be downloaded again. When this request is sent for the very
|
||||
+ * first time from a given server, the client will first display a
|
||||
+ * confirmation GUI to the player before proceeding with the download.
|
||||
+ * <p>
|
||||
+ * Notes:
|
||||
+ * <ul>
|
||||
+ * <li>Players can disable server resources on their client, in which
|
||||
+ * case this method will have no affect on them.
|
||||
+ * <li>There is no concept of resetting resource packs back to default
|
||||
+ * within Minecraft, so players will have to relog to do so.
|
||||
+ * </ul>
|
||||
+ *
|
||||
+ * @param url The URL from which the client will download the resource
|
||||
+ * pack. The string must contain only US-ASCII characters and should
|
||||
+ * be encoded as per RFC 1738.
|
||||
+ * @param hash A 40 character hexadecimal and lowercase SHA-1 digest of
|
||||
+ * the resource pack file.
|
||||
+ * @throws IllegalArgumentException Thrown if the URL is null.
|
||||
+ * @throws IllegalArgumentException Thrown if the URL is too long. The
|
||||
+ * length restriction is an implementation specific arbitrary value.
|
||||
+ */
|
||||
+ void setResourcePack(String url, String hash);
|
||||
+
|
||||
+ /**
|
||||
+ * @return the most recent resource pack status received from the player,
|
||||
+ * or null if no status has ever been received from this player.
|
||||
+ */
|
||||
+ org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus();
|
||||
+
|
||||
+ /**
|
||||
+ * @return the most recent resource pack hash received from the player,
|
||||
+ * or null if no hash has ever been received from this player.
|
||||
+ */
|
||||
+ String getResourcePackHash();
|
||||
+
|
||||
+ /**
|
||||
+ * @return true if the last resource pack status received from this player
|
||||
+ * was {@link org.bukkit.event.player.PlayerResourcePackStatusEvent.Status#SUCCESSFULLY_LOADED}
|
||||
+ */
|
||||
+ boolean hasResourcePack();
|
||||
+ // Paper end
|
||||
+
|
||||
// Spigot start
|
||||
public class Spigot extends Entity.Spigot
|
||||
{
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
||||
index 4c49801..4c83851 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
||||
@@ -10,13 +10,28 @@ import org.bukkit.event.HandlerList;
|
||||
public class PlayerResourcePackStatusEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
+ private final String hash; // Paper
|
||||
private final Status status;
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus) {
|
||||
super(who);
|
||||
+ this.hash = null; // Paper
|
||||
this.status = resourcePackStatus;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus, String hash) {
|
||||
+ super(who);
|
||||
+ this.hash = hash; // Paper
|
||||
+ this.status = resourcePackStatus;
|
||||
+ }
|
||||
+
|
||||
+ public String getHash() {
|
||||
+ return this.hash;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the status of this pack.
|
||||
*
|
||||
--
|
||||
2.7.2
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 6c5782ef743e2ba3172cd49d459ed793d1f0fa5d Mon Sep 17 00:00:00 2001
|
||||
From 6823e7158ffb446622cb0bcba3f4a801e8fa4964 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 21:09:10 -0600
|
||||
Subject: [PATCH] mc-dev imports
|
||||
@ -4778,6 +4778,44 @@ index 0000000..f82ea80
|
||||
+
|
||||
+ public void b(int i, BlockPosition blockposition, int j) {}
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java b/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java
|
||||
new file mode 100644
|
||||
index 0000000..30ca225
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+
|
||||
+public class PacketPlayInResourcePackStatus implements Packet<PacketListenerPlayIn> {
|
||||
+
|
||||
+ private String a;
|
||||
+ public PacketPlayInResourcePackStatus.EnumResourcePackStatus status;
|
||||
+
|
||||
+ public PacketPlayInResourcePackStatus() {}
|
||||
+
|
||||
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
+ this.a = packetdataserializer.c(40);
|
||||
+ this.status = (PacketPlayInResourcePackStatus.EnumResourcePackStatus) packetdataserializer.a(PacketPlayInResourcePackStatus.EnumResourcePackStatus.class);
|
||||
+ }
|
||||
+
|
||||
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
+ packetdataserializer.a(this.a);
|
||||
+ packetdataserializer.a((Enum) this.status);
|
||||
+ }
|
||||
+
|
||||
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
|
||||
+ packetlistenerplayin.a(this);
|
||||
+ }
|
||||
+
|
||||
+ public static enum EnumResourcePackStatus {
|
||||
+
|
||||
+ SUCCESSFULLY_LOADED, DECLINED, FAILED_DOWNLOAD, ACCEPTED;
|
||||
+
|
||||
+ private EnumResourcePackStatus() {}
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalFloat.java b/src/main/java/net/minecraft/server/PathfinderGoalFloat.java
|
||||
new file mode 100644
|
||||
index 0000000..1a20dbf
|
||||
|
90
Spigot-Server-Patches/0081-Complete-resource-pack-API.patch
Normale Datei
90
Spigot-Server-Patches/0081-Complete-resource-pack-API.patch
Normale Datei
@ -0,0 +1,90 @@
|
||||
From 9b4bc274753dc6714b5614577905400cab043360 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/PacketPlayInResourcePackStatus.java b/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java
|
||||
index 30ca225..148141d 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayInResourcePackStatus.java
|
||||
@@ -4,7 +4,7 @@ import java.io.IOException;
|
||||
|
||||
public class PacketPlayInResourcePackStatus implements Packet<PacketListenerPlayIn> {
|
||||
|
||||
- private String a;
|
||||
+ public String a; // Paper - make public
|
||||
public PacketPlayInResourcePackStatus.EnumResourcePackStatus status;
|
||||
|
||||
public PacketPlayInResourcePackStatus() {}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index d141307..d58f05b 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -1018,7 +1018,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
||||
// CraftBukkit start
|
||||
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
|
||||
- this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
|
||||
+ //this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()])); // Paper - comment
|
||||
+ // Paper start
|
||||
+ PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.x());
|
||||
+ final PlayerResourcePackStatusEvent.Status status = PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()];
|
||||
+ this.getPlayer().setResourcePackStatus(status, packetplayinresourcepackstatus.a);
|
||||
+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), status, packetplayinresourcepackstatus.a));
|
||||
+ // paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 51c971f..fd17df9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -72,6 +72,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, EntityPlayer entity) {
|
||||
super(server, entity);
|
||||
@@ -1519,6 +1523,33 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void setViewDistance(int viewDistance) {
|
||||
((WorldServer) getHandle().world).getPlayerChunkMap().updateViewDistance(getHandle(), viewDistance);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void setResourcePack(String url, String hash) {
|
||||
+ Validate.notNull(url, "Resource pack URL cannot be null");
|
||||
+ Validate.notNull(hash, "Hash cannot be null");
|
||||
+ this.getHandle().setResourcePack(url, hash);
|
||||
+ }
|
||||
+
|
||||
+ @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, String hash) {
|
||||
+ this.resourcePackStatus = status;
|
||||
+ this.resourcePackHash = hash;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
// Spigot start
|
||||
--
|
||||
2.7.2
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren