Question Weird java bug only with 1.20.6 (only on paper)

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

Black_Eyes

New member
Jun 11, 2024
1
0
1
So, I have a particle API in my plugin that uses some reflections. Don't worry, that's not the main topic, even I don't understand reflection totally.
I have an 1.20.4 test server using jdk 22, and an 1.20.6 test server using the same JDK.

My plugin works from 1.8 to 1.20.4.
On 1.20.6, I have this issue:
Code:
[21:26:49 ERROR]: Error occurred while enabling LootChest v2.4.0 (Is it up to date?)
java.lang.ExceptionInInitializerError: null
        at LootChest.jar/fr.black_eyes.lootchest.particles.ParticleTypes.<clinit>(ParticleTypes.java:18) ~[LootChest.jar:?]
        at LootChest.jar/fr.black_eyes.lootchest.particles.ParticleType.of(ParticleType.java:16) ~[LootChest.jar:?]
        at LootChest.jar/fr.black_eyes.lootchest.particles.Particle.<init>(Particle.java:215) ~[LootChest.jar:?]
        at LootChest.jar/fr.black_eyes.lootchest.particles.Particle.<clinit>(Particle.java:29) ~[LootChest.jar:?]
        at LootChest.jar/fr.black_eyes.lootchest.Main.initParticles(Main.java:521) ~[LootChest.jar:?]
        at LootChest.jar/fr.black_eyes.lootchest.Main.onEnable(Main.java:223) ~[LootChest.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:519) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:604) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:553) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:675) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:437) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:323) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1136) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[paper-1.20.6.jar:1.20.6-138-906df69]
        at java.base/java.lang.Thread.run(Thread.java:1570) ~[?:?]
Caused by: java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 22
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) ~[?:?]
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) ~[?:?]
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) ~[?:?]
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) ~[?:?]
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) ~[?:?]
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112) ~[?:?]
        at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349) ~[?:?]        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4914) ~[?:?]
        at java.base/java.lang.String.substring(String.java:2876) ~[?:?]
        at java.base/java.lang.String.substring(String.java:2849) ~[?:?]
        at LootChest.jar/fr.black_eyes.lootchest.particles.FastReflection.<clinit>(FastReflection.java:18) ~[LootChest.jar:?]
        ... 18 more

Here is the line of code referenced by the error, the first "static final Class<?>" is the 18th line, the one referenced by the error

Java:
    static final Class<?> BLOCK_DATA_CLASS = FastReflection.optionalClass("org.bukkit.block.data.BlockData").orElse(null);
    static final Class<?> DUST_OPTIONS_CLASS = FastReflection.optionalClass("org.bukkit.Particle$DustOptions").orElse(null);
    static final Class<?> DUST_TRANSITION_CLASS = FastReflection.optionalClass("org.bukkit.Particle$DustTransition").orElse(null);
    static final Map<Class<?>, Class<?>> DATA_ADAPTERS = new HashMap<>();
    static final boolean LEGACY = !FastReflection.optionalClass("org.bukkit.Particle").isPresent();

Does someone knows why a line like this would cause this weird error in this specific minecraft version? This doesn't occurs on spigot
 
Last edited: