r4g3baby / SimpleScore

A simple animated scoreboard plugin for your minecraft server.
https://www.spigotmc.org/resources/simplescore.23243/
MIT License
68 stars 34 forks source link

Could not apply PlaceholderAPI placeholders (async sussy) #30

Closed brayjamin closed 2 years ago

brayjamin commented 2 years ago

Hey, I'm running a server with SimpleScore and grakkit, a plugin for coding in JS...

[21:58:39] [Craft Scheduler Thread - 102 - SimpleScore/WARN]: [SimpleScore] Could not apply PlaceholderAPI placeholders
java.lang.IllegalStateException: Multi threaded access requested by thread Thread[Craft Scheduler Thread - 102 - SimpleScore,5,main] but is not allowed for language(s) js.
    at com.oracle.truffle.polyglot.PolyglotEngineException.illegalState(PolyglotEngineException.java:129) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.PolyglotContextImpl.throwDeniedThreadAccess(PolyglotContextImpl.java:940) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.PolyglotContextImpl.checkAllThreadAccesses(PolyglotContextImpl.java:799) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.PolyglotContextImpl.enterThreadChanged(PolyglotContextImpl.java:629) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.PolyglotEngineImpl.enterCached(PolyglotEngineImpl.java:1885) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:112) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.api.impl.DefaultCallTarget.callDirectOrIndirect(DefaultCallTarget.java:85) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.api.impl.DefaultCallTarget.call(DefaultCallTarget.java:102) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.api.impl.DefaultRuntimeAccessor$DefaultRuntimeSupport.callProfiled(DefaultRuntimeAccessor.java:147) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.canInvoke(PolyglotValueDispatch.java:2389) ~[grakkit-5.0.4.paper.jar:?]
    at org.graalvm.polyglot.Value.canInvokeMember(Value.java:910) ~[grakkit-5.0.4.paper.jar:?]
    at com.oracle.truffle.host.adapters.HostAdapterServices.hasMethod(HostAdapterServices.java:115) ~[?:?]
    at com.oracle.truffle.host.adapters.PlaceholderExpansion$$Adapter.onPlaceholderRequest(Unknown Source) ~[?:?]
    at me.clip.placeholderapi.PlaceholderHook.onRequest(PlaceholderHook.java:32) ~[PlaceholderAPI-2.11.1.jar:?]
    at com.oracle.truffle.host.adapters.PlaceholderExpansion$$Adapter.onRequest(Unknown Source) ~[?:?]
    at me.clip.placeholderapi.replacer.CharsReplacer.apply(CharsReplacer.java:161) ~[PlaceholderAPI-2.11.1.jar:?]
    at me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:70) ~[PlaceholderAPI-2.11.1.jar:?]
    at me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:98) ~[PlaceholderAPI-2.11.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.placeholders.PlaceholderReplacer.applyPlaceholderAPI(PlaceholderReplacer.kt:22) ~[SimpleScore-3.9.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.placeholders.PlaceholderReplacer.replace(PlaceholderReplacer.kt:12) ~[SimpleScore-3.9.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.placeholders.PlaceholderReplacer.replacePlaceholders(PlaceholderReplacer.kt:53) ~[SimpleScore-3.9.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.models.conditions.Equals.check(Equals.kt:14) ~[SimpleScore-3.9.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.models.Scoreboard.canSee(Scoreboard.kt:12) ~[SimpleScore-3.9.1.jar:?]
    at com.r4g3baby.simplescore.scoreboard.tasks.ScoreboardTask.run(ScoreboardTask.kt:68) ~[SimpleScore-3.9.1.jar:?]
    at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.18.1.jar:git-Paper-155]
    at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.18.1.jar:git-Paper-155]
    at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.18.1.jar:git-Paper-155]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

I'm quite knowledgeable on Grakkit JS, and this error happens when multiple calls happen to the JS program from separate threads.. However it shouldn't happen. I have async-placeholders disabled in SS's config.. Not sure why this is happening :(

I'm running the latest version of SimpleScore, ProtocolLib, PlaceholderAPI & grakkit.

I have a feeling this is more of an issue with grakkit than anything else, let alone SimpleScore. I apologize for that, but you wouldn't happen to know what's going on, would you?

r4g3baby commented 2 years ago

Hey, ok so what seems to be happening here is that you are using placeholders on conditions, am I right?

Conditions run async so that's most likely the issue, this is kinda misleading considering the config doesn't specify that the option only controls async behaviour for displaying placeholders.

I'll mark this issue has a bug and try to implement a fix as soon as I have some free time but until then the only workaround is to not use those placeholders on conditions.

brayjamin commented 2 years ago

Yep, I'm using conditions! I ended up registering several placeholders to handle it, for the time being. Thank you so much man!

brayjamin commented 2 years ago

wait i didnt mean to close sry

r4g3baby commented 2 years ago

Commit f61b238 should fix this, I'll be releasing a new version on spigot over the next few days with this fix and some other ones but until then you can use the link bellow to download the latest dev version if you want. https://wormhole.app/6p0a3#WHCE6cR7v00zBlCGpLYwwA