markhughes / FactionsFramework

Build a Factions plugin for every version of Factions and not have to worry about version upgrades and changes.
GNU General Public License v3.0
5 stars 3 forks source link

ClassCastException: CraftChunk cannot be cast to Comparable #21

Open ItsHarry opened 7 years ago

ItsHarry commented 7 years ago

Not sure how nobody else has reported this before. You can't add an object to a TreeSet if it does not implement Comparable.

[15:18:24] [Server thread/ERROR]: Could not pass event LandClaimEvent to FactionsFramework v1.2.0
org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at com.massivecraft.factions.zcore.persist.MemoryFPlayer.attemptClaim(MemoryFPlayer.java:801) [FactionsUUID.jar:?]
    at com.massivecraft.factions.cmd.CmdAutoClaim.perform(CmdAutoClaim.java:48) [FactionsUUID.jar:?]
    at com.massivecraft.factions.zcore.MCommand.execute(MCommand.java:130) [FactionsUUID.jar:?]
    at com.massivecraft.factions.cmd.FCommand.execute(FCommand.java:53) [FactionsUUID.jar:?]
    at com.massivecraft.factions.zcore.MCommand.execute(MCommand.java:116) [FactionsUUID.jar:?]
    at com.massivecraft.factions.cmd.FCommand.execute(FCommand.java:53) [FactionsUUID.jar:?]
    at com.massivecraft.factions.zcore.MCommand.execute(MCommand.java:134) [FactionsUUID.jar:?]
    at com.massivecraft.factions.zcore.MPlugin.handleCommand(MPlugin.java:299) [FactionsUUID.jar:?]
    at com.massivecraft.factions.zcore.MPlugin.handleCommand(MPlugin.java:262) [FactionsUUID.jar:?]
    at com.massivecraft.factions.P.handleCommand(P.java:189) [FactionsUUID.jar:?]
    at com.massivecraft.factions.P.onCommand(P.java:200) [FactionsUUID.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:143) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1189) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1001) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_45]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_45]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.CraftChunk cannot be cast to java.lang.Comparable
    at java.util.TreeMap.compare(TreeMap.java:1290) ~[?:1.8.0_45]
    at java.util.TreeMap.put(TreeMap.java:538) ~[?:1.8.0_45]
    at java.util.TreeSet.add(TreeSet.java:255) ~[?:1.8.0_45]
    at me.markeh.factionsframework.layer.layer_1_6.Events_1_6.onEventFactionsChunksChange(Events_1_6.java:90) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[PaperSpigot.jar:git-PaperSpigot-"8b18730"]
    ... 31 more
markhughes commented 7 years ago

Looks like the issue is here: https://github.com/MarkehMe/FactionsFramework/blob/master/layers/Layer_1_6/src/main/java/me/markeh/factionsframework/layer/layer_1_6/Events_1_6.java#L90

I will have to change the type, thanks for reporting! 😄

ItsHarry commented 7 years ago

There are more occurrences, also with other types like FPlayer and Faction which don't seem to implement Comparable, not sure how the plugin even works unless I'm missing something

markhughes commented 7 years ago

I've only found it being miss-used with chunk. I believe natural ordering is used as a fallback? Not sure.

It may be helpful if I implement Comparable onto all the frameworks entities. But I'm currently in the process of making FactionsFramework2 (complete rewrite)

markhughes commented 7 years ago

Trying to work out why I did this with Chunk. 😨

prosavage commented 6 years ago

I fixed it