BGHDDevelopment / PlayerBalancer

The repository for the plugin PlayerBalancer
https://www.spigotmc.org/resources/55011/
MIT License
28 stars 25 forks source link

JsonIOException in PlayerBalancer Plugin on Waterfall 1.20-562 with JDK 21 #41

Closed WitheredWinter closed 4 months ago

WitheredWinter commented 5 months ago

Issue Description

I encountered a JsonIOException while using the PlayerBalancer plugin on the Waterfall server version 1.20-562. This issue occurred on a system running Windows 10 with JDK 21.

Steps to Reproduce

  1. Use Waterfall 1.20-562 on Windows 10 and JDK 21.
  2. Make sure using PlayerBalancer-2.3.5.
  3. Also install BungeeGuard1.3.3, PartyandFriendsAddon-2.3.5 and partyandfriends1.0.240-E plugin.
  4. Start the Waterfall server.
  5. Make sure your backend server is on and reachable.
  6. Observe the error in the server console/logs.

Expected Behavior

The PlayerBalancer plugin should function without any serialization/deserialization issues.

Actual Behavior

The server logs show a JsonIOException related to the Gson library's handling of a private field in the java.awt.Color class. Here is the detailed error message:

[04:17:27 ERROR]: Task BungeeTask(sched=net.md_5.bungee.scheduler.BungeeScheduler@5633dafd, id=59818, owner=com.jaimemartz.playerbalancer.PlayerBalancer@3d9f0a5, task=com.jaimemartz.playerbalancer.ping.PingTactic$1$$Lambda/0x000002044744a960@6c5558a6, delay=0, period=0, running=true) encountered an exception
com.google.gson.JsonIOException: Failed making field 'java.awt.Color#value' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
        ...
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @33cb5951
        ...

Environment

Additional Context

I ask ChatGPT4 for help with the log, and it tells me that this issue seems to be related to Java's module system introduced in Java 9, which enforces strong encapsulation. Gson appears to be unable to access a private field in a core Java class due to these module system rules. I will attach the full log and the conf of PlayerBalance. latest.log.txt plugin.conf.txt

GPT4's answer

GPT4_s answer.png

BGHDDevelopment commented 4 months ago

Sorry for the delay please test this jar: PBBETA.zip

BGHDDevelopment commented 4 months ago

Tested and confirmed on Discord. Released.