Twi5TeD/PlayTime

Unexpected token

Opened this issue · 1 comments

21.06 22:08:24 [Server] WARN Unexpected token RIGHT BRACE(}) at position 52657.
21.06 22:08:24 [Server] WARN at org.json.simple.parser.JSONParser.parse(JSONParser.java:146)
21.06 22:08:24 [Server] WARN at org.json.simple.parser.JSONParser.parse(JSONParser.java:92)
21.06 22:08:24 [Server] WARN at PlayTime-3.6.jar//me.f64.playtime.Main.writePlayer(Main.java:164)
21.06 22:08:24 [Server] WARN at PlayTime-3.6.jar//me.f64.playtime.Main.lambda$savePlayer$3(Main.java:150)
21.06 22:08:24 [Server] WARN at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101)
21.06 22:08:24 [Server] WARN at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57)
21.06 22:08:24 [Server] WARN at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
21.06 22:08:24 [Server] WARN at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
21.06 22:08:24 [Server] WARN at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
21.06 22:08:24 [Server] WARN at java.base/java.lang.Thread.run(Thread.java:833)

This is (relatively) the same issue as #17, #20, #31, and more.
This plugin does save players' playtime inside userdata.json (even though all that data are already saved in playerdata world folder).
Somehow, it does make a lot of bugs by entering somehow the wrong character. I don't understand why and when but it will probably stay until @Twi5TeD fixes the issue permanently.

How to fix the error:

A simple fix is completely delete userdata.json or find the wrong characters by yourself.
It should stop because the file actively changes when the plugin runs, so reloading should not be required.

I fix it by going to /plugins/PlayTime/userdata.json and going to the last lines and removing some lines of it to correctly fit the JSON file formatting. In most of my cases, it was overstaying }] at the end of the file or element of an array after the array 🤯.
If the error is still "making", delete the userdata.json file. Data of players will be added back whenever they leave or join.