Solved cast block to sign

Discussion in 'Spigot Plugin Development' started by TheZettel, Jun 25, 2016.

  1. Hey!

    I need help with casting a block to a sign.
    Everytime the console says something with ClassCastException, I know what this means, but i have no solution for it.

    Here's the code:
    Code (Text):
    Sign sign = (Sign) Bukkit.getWorld(signs.get(s).getWorld().getName()).getBlockAt(signs.get(s));
    Here's the error:
    Code (Text):
    [15:56:30 ERROR]: Error occurred while enabling SignSystem v1.0 (Is it up to date?)
    java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R1.block.CraftBlock cannot be cast to org.bukkit.block.Sign
            at de.galaxio.signsystem.handler.ServerHandler.refresh(ServerHandler.java:53) ~[?:?]
            at de.galaxio.signsystem.Core.onEnable(Core.java:29) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:356) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:316) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.reload(CraftServer.java:746) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.Bukkit.reload(Bukkit.java:534) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchServerCommand(CraftServer.java:632) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at net.minecraft.server.v1_8_R1.DedicatedServer.aM(DedicatedServer.java:353) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:317) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
     
  2. Use the getState() method then cast it to a sign.
     
  3. I will try. Thanks :)