mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Complete resource pack API
This commit is contained in:
parent
b465659461
commit
f55b057ffb
2 changed files with 17 additions and 5 deletions
|
@ -174,7 +174,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleResourcePackResponse(ServerboundResourcePackPacket packet) {
|
public void handleResourcePackResponse(ServerboundResourcePackPacket packet) {
|
||||||
PacketUtils.ensureRunningOnSameThread(packet, this, (BlockableEventLoop) this.server);
|
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());
|
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), packet.id());
|
||||||
this.disconnect((Component) Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
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());
|
+ callback.packEventReceived(packet.id(), net.kyori.adventure.resource.ResourcePackStatus.valueOf(packet.action().name()), this.getCraftPlayer());
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // 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);
|
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +233,7 @@
|
@@ -116,7 +237,7 @@
|
||||||
Profiler.get().push("keepAlive");
|
Profiler.get().push("keepAlive");
|
||||||
long i = Util.getMillis();
|
long i = Util.getMillis();
|
||||||
|
|
||||||
|
@ -214,7 +218,7 @@
|
||||||
if (this.keepAlivePending) {
|
if (this.keepAlivePending) {
|
||||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
||||||
} else if (this.checkIfClosed(i)) {
|
} else if (this.checkIfClosed(i)) {
|
||||||
@@ -156,6 +273,14 @@
|
@@ -156,6 +277,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
|
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
|
||||||
|
@ -229,7 +233,7 @@
|
||||||
if (packet.isTerminal()) {
|
if (packet.isTerminal()) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
@@ -175,20 +300,72 @@
|
@@ -175,20 +304,72 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
private double healthScale = 20;
|
private double healthScale = 20;
|
||||||
private CraftWorldBorder clientWorldBorder = null;
|
private CraftWorldBorder clientWorldBorder = null;
|
||||||
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
||||||
|
public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API
|
||||||
|
|
||||||
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
|
@ -2121,6 +2122,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
}
|
}
|
||||||
// Paper end - adventure
|
// 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
|
@Override
|
||||||
public void removeResourcePack(UUID id) {
|
public void removeResourcePack(UUID id) {
|
||||||
Preconditions.checkArgument(id != null, "Resource pack id cannot be null");
|
Preconditions.checkArgument(id != null, "Resource pack id cannot be null");
|
||||||
|
|
Loading…
Reference in a new issue