Closed patrickdundas closed 4 months ago
Does your plugin include Plan code by accident by any chance?
Could you send a copy of your plugin jar so that I can try reproduce the issue?
Sure, here is a link to my jar: https://drive.google.com/file/d/1Oy84qE1ooBExAjHqawebiiAnl3D_xkdq/view?usp=sharing
If you want to see the complete source code I can share that with you privately. The plugin does not accidentally contain any of Plan's code, it just imports it in the pom as described in the Plan API documentation. The only files related to plan are the files outlined in the Guide I linked above - I haven't changed any of the guide code aside from adding logs trying to track down the issue. Other than that, I have 1 line of code which uses getSessionCount
from the guide's example QueryAPIAccessor class. I noticed this line of code was failing since the Optional<QueryAPIAccessor>
was null, so I started adding logs to track down the issue, which led me here. Thank you for your responses so far!
Are there any factors which would make the Query API inaccessible when QueryService.getInstance()
is run? I know for a fact that this is the section of code which is causing the issues, so I'm attempting to look into any factors which would cause this to fail, but it's a bit of a black box. Are there any ports or Plan plugin configurations that I should be validating on my server? What are the dependencies or failure points of QueryService.getInstance()
which might be incorrectly configured for this function to work on my machine (if you know them)
The QueryService singleton is registered here https://github.com/plan-player-analytics/Plan/blob/master/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java#L180 during the enable process - it should have registered at least according to the logs.
Only thing I can think of is that on fabric the enable order is slightly different and Plan enables during ServerLifecycleEvents.SERVER_STARTING instead of onInitializeServer
Another thing that comes to mind is that since it's using an AtomicReference that is not volatile (https://github.com/plan-player-analytics/Plan/blob/master/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java#L153) the Thread from your plugin may not yet see changes to the singleton when your code is running.
One way to test this would be to delay registering the Plan hook with a Bukkit Runnable
I haven't been able to reproduce this. Could you send the full exception stack trace for the IllegalStateException if this is still relevant?
Describe the issue
I am following the Query API Getting Started guide and am having the following error. The below code in PlanHook.java throws the warning that Plan is not enabled (IllegalStateException):
In plugin.yml, I've tried making Plan both a soft and regular dependency:
depend: [Plan]
In pom.xml, I have confirmed that the plan API for 5.5.2391 is loaded correctly, and I have the same Jar running on my server. I've confirmed that Plan enables before my plugin in the startup logs: