Solved PlayerInteract Error

Discussion in 'Plugin Help/Development/Requests' started by malikdbuseck, Jan 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    malikdbuseck

    So I get a console error everytime I leftclick and right click a block. here is my code:

    Code:
        @EventHandler
        @SuppressWarnings("static-access")
        public void onPlayerInteract(PlayerInteractEvent event) {
    
            Action Action = event.getAction();
    
            if ((Action == Action.PHYSICAL) || (event.getItem() == null)
                    || (event.getItem().getType() == Material.AIR)){
                return;
            }
            // JOIN CLICK DO =====================================
            if (event.getItem().getType() == Material.NETHER_STAR) {
                JoinGUI.openGUI(event.getPlayer());
                return;
    HERE IS ERROR:
    Code:
    [02:34:33] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to MineofLegends v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:297) ~[Bukkit.jar:git-Bukkit-f233e7d]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Bukkit.jar:git-Bukkit-f233e7d]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [Bukkit.jar:git-Bukkit-f233e7d]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [Bukkit.jar:git-Bukkit-f233e7d]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:209) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.PlayerInteractManager.interact(PlayerInteractManager.java:458) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:693) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:50) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:80) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [Bukkit.jar:git-Bukkit-f233e7d]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_25]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_25]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:643) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:284) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:598) [Bukkit.jar:git-Bukkit-f233e7d]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:506) [Bukkit.jar:git-Bukkit-f233e7d]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R1.block.CraftBlockState cannot be cast to org.bukkit.block.Sign
        at me.malikdbuseck.Listeners.SignHit.onPlayerInteract(SignHit.java:35) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:295) ~[Bukkit.jar:git-Bukkit-f233e7d]
        ... 16 more
     
  2. Offline

    mrCookieSlime Retired Staff

    Moved to Alternatives Section.
     
  3. Offline

    Skionz

    @malikdbuseck That snippet has nothing to do with your stack-trace. Check if the Block's type is a sign before casting the Block's state to Sign.
     
  4. Offline

    malikdbuseck

    Wow Im so stupid. Should read that error more throughly. But here is the fix for anyone else

    if(event.getClickedBlock().getType() != Material.SIGN)return;
     
Thread Status:
Not open for further replies.

Share This Page