DecentSoftware-eu / DecentHolograms

A lightweight but powerful hologram plugin with many features and configuration options.
https://www.spigotmc.org/resources/96927/
GNU General Public License v3.0
183 stars 82 forks source link

Can't retrieve skull texture in 1.20.4 #181

Closed PierreSchwang closed 5 months ago

PierreSchwang commented 6 months ago

Just making sure

Reproduction

In 1.20.4 the Property class in the AuthLib was changed to a record. This results in the value accessor method not being named getValue() anymore - but rather the record access style value().

java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: 'java.lang.String com.mojang.authlib.properties.Property.getValue()'
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
    at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:722) ~[?:?]
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
    at com.plotsquared.bukkit.util.task.BukkitPlotSquaredTask.runTask(BukkitPlotSquaredTask.java:39) ~[plotsquared-bukkit-7.3.1-SNAPSHOT.jar:?]
    at com.plotsquared.core.util.task.PlotSquaredTask.run(PlotSquaredTask.java:44) ~[plotsquared-bukkit-7.3.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.4.jar:git-Paper-365]
    at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480) ~[paper-1.20.4.jar:git-Paper-365]
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1639) ~[paper-1.20.4.jar:git-Paper-365]
    at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.20.4.jar:git-Paper-365]
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1518) ~[paper-1.20.4.jar:git-Paper-365]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1214) ~[paper-1.20.4.jar:git-Paper-365]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[paper-1.20.4.jar:git-Paper-365]
    at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.NoSuchMethodError: 'java.lang.String com.mojang.authlib.properties.Property.getValue()'
    at eu.decentsoftware.holograms.api.utils.items.SkullUtils.getSkullTexture(SkullUtils.java:69) ~[DecentHolograms-2.8.6.jar:?]
    at eu.decentsoftware.holograms.api.utils.items.ItemBuilder.getSkullTexture(ItemBuilder.java:309) ~[DecentHolograms-2.8.6.jar:?]
    at eu.decentsoftware.holograms.api.utils.items.HologramItem.fromItemStack(HologramItem.java:138) ~[DecentHolograms-2.8.6.jar:?]
    at eu.decentsoftware.holograms.api.DHAPI.insertHologramLine(DHAPI.java:496) ~[DecentHolograms-2.8.6.jar:?]
    at eu.decentsoftware.holograms.api.DHAPI.insertHologramLine(DHAPI.java:453) ~[DecentHolograms-2.8.6.jar:?]
    at com.plotsquared.holoplots.provider.impl.DecentHologramsProvider.updateHologram(DecentHologramsProvider.java:48) ~[HoloPlots-7.0.1-SNAPSHOT.jar:?]
    at com.plotsquared.holoplots.provider.HologramProvider.createOrUpdateHologram(HologramProvider.java:70) ~[HoloPlots-7.0.1-SNAPSHOT.jar:?]
    at com.plotsquared.holoplots.DefaultHoloPlots.lambda$updatePlot$3(DefaultHoloPlots.java:188) ~[HoloPlots-7.0.1-SNAPSHOT.jar:?]
    at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?]
    ... 11 more

Solution

https://github.com/DecentSoftware-eu/DecentHolograms/blob/main/src/main/java/eu/decentsoftware/holograms/api/utils/items/SkullUtils.java#L69

When accessing the value, the server's version should be respected and if required the new method called. Possibly one implementation using reflection and one to directly access the method. In terms of LTS, the "old" getValue() should be accessed with reflection, whereas the authlib dependency should be updated and value() called directly. AuthLib can't be upgraded as the dependency requires Java 17, whereas DH is stuck on 8. So I guess newer version have to live with reflections (which is quite a pity)

Server Version

git-Paper-365 (MC: 1.20.4)

Client Version

1.20.4

Plugin Version

v2.8.6

Log

-