CodeCrafter47 / BungeeTabListPlus

GNU General Public License v3.0
147 stars 70 forks source link

SpongeBridge broken on API 5 & 6 #275

Closed MarkL4YG closed 7 years ago

MarkL4YG commented 7 years ago
java.lang.ClassCastException: me.lucko.luckperms.sponge.service.proxy.api6.SubjectProxy cannot be cast to org.spongepowered.api.service.permission.SubjectReference
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_77]
    at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) ~[?:1.8.0_77]
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_77]
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) ~[?:1.8.0_77]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[?:1.8.0_77]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:1.8.0_77]
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) ~[?:1.8.0_77]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_77]
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) ~[?:1.8.0_77]
    at de.codecrafter47.data.sponge.sponge7.Sponge7.getPrimaryGroup(Sponge7.java:32) ~[Sponge7.class:?]
    at de.codecrafter47.data.api.AbstractDataAccess.lambda$addProvider$0(AbstractDataAccess.java:30) ~[AbstractDataAccess.class:?]
    at de.codecrafter47.data.api.AbstractDataAccess.get(AbstractDataAccess.java:44) ~[AbstractDataAccess.class:?]
    at de.codecrafter47.data.sponge.AbstractSpongeDataAccess.get(AbstractSpongeDataAccess.java:35) ~[AbstractSpongeDataAccess.class:?]
    at de.codecrafter47.data.api.JoinedDataAccess.get(JoinedDataAccess.java:40) ~[JoinedDataAccess.class:?]
    at de.codecrafter47.bungeetablistplus.bridge.AbstractBridge.updatePlayerData(AbstractBridge.java:381) ~[AbstractBridge.class:?]
    at de.codecrafter47.bungeetablistplus.bridge.AbstractBridge.updateData(AbstractBridge.java:316) ~[AbstractBridge.class:?]
    at codecrafter47.bungeetablistplus.spongebridge.SpongePlugin.lambda$onServerStart$3(SpongePlugin.java:146) ~[SpongePlugin.class:?]
    at org.spongepowered.api.scheduler.Task$Builder.lambda$execute$0(Task.java:139) ~[Task$Builder.class:1.10.2-5.2.0-BETA-0]
    at org.spongepowered.common.scheduler.SchedulerBase.lambda$startTask$0(SchedulerBase.java:183) ~[SchedulerBase.class:1.10.2-5.2.0-BETA-0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_77]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_77]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_77]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_77]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_77]

Apparently the bridge uses the Sponge7 class to get the primary group of players although it's loaded on API 5 OR 6. (Hint: SubjectReference does not exist in 5 or 6. It's Subject there)

CodeCrafter47 commented 7 years ago

Are you certain you're Sponge version is API version 5 or 6? You can use the /sponge version command to check.

MarkL4YG commented 7 years ago

Yes I am. This occurs on SpongeVanilla for MC1.10.2 (there's no API 7 for that MC version) and the stable-5 branch of Sponge.

CodeCrafter47 commented 7 years ago

Figured it out. LuckPerms includes a copy of the org.spongepowered.api.service.permission.SubjectReference class in it's jar which tricks BungeeTabListPlus into thinking it's running on Sponge API 7. I'll probably have to find another way to detect the API version.

MarkL4YG commented 7 years ago

Yeah that sounds reasonable. I guess LuckyPerms had to ship the interface in order not to crash by CNF exceptions...

It's kinda unsatisfying that there seems to be no Sponge-supported way of getting the API version / build.

CodeCrafter47 commented 7 years ago

Well there probably is a way to get the version from SpongeAPI, I just prefer checking whether a class is present, because it's quite simple to do and more resilient in case they change the API or the versioning scheme or someone uses a fork or custom build. Checking the version number will work fine for too, so I should be able to do that.

MarkL4YG commented 7 years ago

If someone forks Sponge incompatible to BTLP it's really their responsibility ^^

CodeCrafter47 commented 7 years ago

The latest dev-build should fix your issue.

MarkL4YG commented 7 years ago

Thanks, I will test in a few hours.

MarkL4YG commented 7 years ago

Quick test shows: Yep - no exception this time. Rank and Balance available.

I'm going to call that fixed - Thanks šŸ‘