Complete resource pack API

This commit is contained in:
Jedediah Smith 2015-04-04 23:17:52 -04:00
parent b465659461
commit f55b057ffb
2 changed files with 17 additions and 5 deletions

View file

@ -174,7 +174,7 @@
@Override
public void handleResourcePackResponse(ServerboundResourcePackPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, (BlockableEventLoop) this.server);
@@ -104,11 +202,30 @@
@@ -104,11 +202,34 @@
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), packet.id());
this.disconnect((Component) Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
@ -190,7 +190,11 @@
+ callback.packEventReceived(packet.id(), net.kyori.adventure.resource.ResourcePackStatus.valueOf(packet.action().name()), this.getCraftPlayer());
+ }
+ // Paper end
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()])); // CraftBukkit
+ // Paper start - store last pack status
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()];
+ player.getBukkitEntity().resourcePackStatus = packStatus;
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), packStatus)); // CraftBukkit
+ // Paper end - store last pack status
}
@ -205,7 +209,7 @@
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
}
@@ -116,7 +233,7 @@
@@ -116,7 +237,7 @@
Profiler.get().push("keepAlive");
long i = Util.getMillis();
@ -214,7 +218,7 @@
if (this.keepAlivePending) {
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
} else if (this.checkIfClosed(i)) {
@@ -156,6 +273,14 @@
@@ -156,6 +277,14 @@
}
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
@ -229,7 +233,7 @@
if (packet.isTerminal()) {
this.close();
}
@@ -175,20 +300,72 @@
@@ -175,20 +304,72 @@
}
}

View file

@ -213,6 +213,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private double healthScale = 20;
private CraftWorldBorder clientWorldBorder = null;
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API
public CraftPlayer(CraftServer server, ServerPlayer entity) {
super(server, entity);
@ -2121,6 +2122,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end - adventure
// Paper start - more resource pack API
@Override
public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() {
return this.resourcePackStatus;
}
// Paper end - more resource pack API
@Override
public void removeResourcePack(UUID id) {
Preconditions.checkArgument(id != null, "Resource pack id cannot be null");