Right clicking sign error: Null

Discussion in 'Plugin Development' started by InsertNameHere, Jun 20, 2019.

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

    InsertNameHere

    Hey all,

    I'm coding a wilderness plugin for practice and I have an event that's supposed to arbitrarily teleport the player when they right-click the wilderness sign. This is the code I have so far:

    Code:
    @EventHandlerpublic void onSignInteraction(PlayerInteractEvent event) {
          if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (event.getClickedBlock().getType() == Material.OAK_WALL_SIGN) {
                      Sign sign = (Sign) event.getClickedBlock().getState();
                      if (sign.getLine(1).equalsIgnoreCase("[Wild TP"))
                            event.getPlayer().sendMessage("You have clicked the sign!");}
                }
          }
    }
    
    However, every time I right click the sign, it brings up an error in console.

    Code:
    [15:56:22 ERROR]: Could not pass event PlayerInteractEvent to AdvancedWilderness v1.0-SNAPSHOT
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:66) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:507) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:492) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at org.bukkit.craftbukkit.v1_13_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:304) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.PlayerInteractManager.a(PlayerInteractManager.java:458) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.PlayerConnection.a(PlayerConnection.java:1222) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.PacketPlayInUseItem.a(PacketPlayInUseItem.java:1) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:9) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
            at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
            at net.minecraft.server.v1_13_R2.SystemUtils.a(SourceFile:199) [spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:896) [spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:417) [spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:831) [spigot.jar:git-Spigot-1a3504a-dfa7583]
            at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:729) [spigot.jar:git-Spigot-1a3504a-dfa7583]
            at java.lang.Thread.run(Thread.java:835) [?:?]
    Caused by: java.lang.NoSuchFieldError: OAK_WALL_SIGN
            at me.recordtime.advancedwilderness.Events.SignInteraction.onSignInteraction(SignInteraction.java:15) ~[?:?]
            at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
            at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
            at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
            at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:312) ~[spigot.jar:git-Spigot-1a3504a-dfa7583]
            ... 17 more
    
    I believe it's the Material.OAK_WALL_SIGN that's causing the error. But whenever I replace it with Material.OAK_SIGN, the same error pops up. I have no idea how to fix this. Any help is appreciated
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    InsertNameHere

    @timtower Do you mean this line:
    Code:
     api-version: 1.13 
    in plugin.yml?
     
  4. Online

    timtower Administrator Administrator Moderator

    That line indeed.
     
  5. Offline

    InsertNameHere

    @timtower Why does that line matter though? Is is not supposed to say 1.13?
     
  6. Online

    timtower Administrator Administrator Moderator

    It is, but if you don't have it then it will use legacy material names.
    Make something that just prints the material when you click something, then you might get the actual name.
     
  7. Offline

    InsertNameHere

    @timtower Okay I've tried doing what you said and it still doesn't work. Whenever I run the code
    Code:
    @EventHandlerpublic void onSignInteraction(PlayerInteractEvent event) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            event.getPlayer().sendMessage("You clicked " + event.getClickedBlock() + "Type: " + event.getClickedBlock().getType());
        }
    }
    
    It outputs WALL_SIGN. But whenever I add the extra statement

    Code:
    @EventHandlerpublic void onSignInteraction(PlayerInteractEvent event) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            event.getPlayer().sendMessage("You clicked " + event.getClickedBlock() + "Type: " + event.getClickedBlock().getType());
            if (event.getClickedBlock().getType() == Material.OAK_WALL_SIGN) {
                event.getPlayer().sendMessage("Success");
            }
        }
    }
    
    It brings up the error in my question and doesn't print success. I still don't understand what's going on...
     
  8. Offline

    KarimAKL

    @InsertNameHere If it the type is 'WALL_SIGN' and you are checking for 'OAK_WALL_SIGN' then of course it doesn't go through. :p
     
  9. Offline

    InsertNameHere

    @KarimAKL Okay, but every time I type Material.WALL_SIGN the only option that pops up is Material.OAK_WALL_SIGN. Am I going crazy here?
     
  10. Online

    timtower Administrator Administrator Moderator

    @InsertNameHere Are you building on the same version as you are running?
     
  11. Offline

    InsertNameHere

    @timtower I believe so. I'm running Minecraft 1.13.2 and the plugin Minecraft 1.13.2 iirc. I made it a while ago though and only recently started working on the right-click sign event.
     
  12. Offline

    KarimAKL

    @InsertNameHere You should be able to see the file used by navigating to the project build path.
     
  13. Offline

    InsertNameHere

    @KarimAKL How do I do that? Is it in Project Structures?
     
  14. Offline

    KarimAKL

  15. Offline

    InsertNameHere

  16. Offline

    KarimAKL

    @InsertNameHere I use Eclipse myself so i'm not sure how to do it with IntelliJ IDEA, but i found a video that might help.
    It's only 48 seconds long.
     
Thread Status:
Not open for further replies.

Share This Page