NPE with Bell#ring()

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • CraftBukkit version 3753-Spigot-7d7b241-b346a5f
    • just my test plugin
    • Yes

      When using Bell#ring(), an NPE is thrown due to BlockFace being null

      Code to test:

       

      Block targetBlockExact = player.getTargetBlockExact(10);
      if (targetBlockExact != null) {
          BlockState state = targetBlockExact.getState();
          if (state instanceof Bell bell) {
              bell.ring();
          }
      } 

      error:

       

       

      [18:59:47] [Server thread/ERROR]: null
      org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin TestPlugin v1.0-SNAPSHOT
      	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      	at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:844) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at org.bukkit.craftbukkit.v1_19_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:50) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:?]
      	at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:312) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:296) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1957) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.network.PlayerConnection.lambda$18(PlayerConnection.java:1919) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:67) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
      	at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1154) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.bi(MinecraftServer.java:1133) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1126) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.i_(MinecraftServer.java:1110) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1021) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at java.lang.Thread.run(Thread.java:833) ~[?:?]
      Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.block.BlockFace.ordinal()" because "face" is null
      	at org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock.blockFaceToNotch(CraftBlock.java:313) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at org.bukkit.craftbukkit.v1_19_R3.block.CraftBell.ring(CraftBell.java:31) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at org.bukkit.craftbukkit.v1_19_R3.block.CraftBell.ring(CraftBell.java:48) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
      	at a.b.c.command.TestCommand.onCommand(TestCommand.java:55) ~[?:?]
      	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      	... 23 more 

       

       

      test plugin included to test

      Steps to reproduce:

      • Place a bell block on the ground
      • while facing it, run command "/test ring"
      • check console to see error

            Assignee:
            Unassigned
            Reporter:
            Shane Bee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: