From 0e87b48ebafeb6b0052653e9c685adbfbf526482 Mon Sep 17 00:00:00 2001 From: Jedediah Smith 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 04e52d2..2a14e1a 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 { - 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 79448eb..3837f64 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -1026,7 +1026,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 0f081b5..9da0797 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); @@ -1522,6 +1526,33 @@ public class CraftPlayer extends CraftHumanEntity implements Player { ((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; + } + // Spigot start private final Player.Spigot spigot = new Player.Spigot() { -- 2.8.0