diff --git a/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java b/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java index 7e8156ec..1565aa85 100644 --- a/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java +++ b/src/main/java/de/oliver/fancyholograms/listeners/PlayerListener.java @@ -65,7 +65,7 @@ public void onWorldChange(@NotNull final PlayerChangedWorldEvent event) { @EventHandler(priority = EventPriority.MONITOR) public void onResourcePackStatus(@NotNull final PlayerResourcePackStatusEvent event) { final UUID playerUniqueId = event.getPlayer().getUniqueId(); - final UUID packUniqueId = event.getID(); + final UUID packUniqueId = getResourcePackID(event); // Adding accepted resource-pack to the list of currently loading resource-packs for that player. if (event.getStatus() == Status.ACCEPTED) loadingResourcePacks.computeIfAbsent(playerUniqueId, (___) -> new ArrayList<>()).add(packUniqueId); @@ -84,4 +84,15 @@ else if (event.getStatus() == Status.SUCCESSFULLY_LOADED || event.getStatus() == } } + // For 1.20.2 and higher this method returns actual pack identifier, while for older versions, the identifier is a dummy UUID full of zeroes. + // Versions prior 1.20.2 supports sending and receiving only one resource-pack and a dummy, constant identifier can be used as a key. + private static @NotNull UUID getResourcePackID(final @NotNull PlayerResourcePackStatusEvent event) { + try { + event.getClass().getMethod("getID"); + return event.getID(); + } catch (final @NotNull NoSuchMethodException e) { + return new UUID(0,0); + } + } + }