Skip to content

Commit

Permalink
fix(spigot): opening book programmatically
Browse files Browse the repository at this point in the history
Fixes #435
  • Loading branch information
diogotcorreia committed Jul 31, 2024
1 parent 42e4e86 commit 03a02d3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ private void setupPacketHandlers() {
}
packetHandlers.put(PacketType.Play.Server.WINDOW_ITEMS, asAsync(this::handleWindowItems));
packetHandlers.put(PacketType.Play.Server.SET_SLOT, asAsync(this::handleSetSlot));
// Nothing to translate, but register listener to ensure order in async mode
packetHandlers.put(PacketType.Play.Server.OPEN_BOOK, asAsync(this::handleNop));
if (MinecraftVersion.CAVES_CLIFFS_2.atOrAbove()) { // 1.18+
// While the villager merchant interface redesign was on 1.14, the Bukkit API only has all fields on 1.18
packetHandlers.put(PacketType.Play.Server.OPEN_WINDOW_MERCHANT, asAsync(this::handleMerchantItems));
Expand Down Expand Up @@ -723,6 +725,14 @@ private void handleDeathScreen(PacketEvent packet, SpigotLanguagePlayer language
packet.getPacket().getChatComponents().writeSafely(0, component);
}

/**
* No-operation function, used to simply register a packet listener in order to ensure certain packets
* are sent in order when using async mode.
*/
private void handleNop(PacketEvent packet, SpigotLanguagePlayer languagePlayer) {
// nop
}

/* PROTOCOL LIB */

@Override
Expand Down

0 comments on commit 03a02d3

Please sign in to comment.