Block setType Null Pointer Exception

Discussion in 'Plugin Development' started by mocswiatla320, Feb 14, 2020.

  1. Offline

    mocswiatla320

    Hello, I have a problem namely when doing: block.setType (Material.BEDROCK); this crashes into the NullPointerException console.
    I heard that in 1.15 setType works somehow differently. If someone could provide the code that sets the block variable type to Material.BEDROCK.
    Thanks in advance.

    CODE:
    Code:
    package test.abc.test;
    
            import org.bukkit.Bukkit;
            import org.bukkit.Material;
            import org.bukkit.event.EventHandler;
            import org.bukkit.event.Listener;
            import org.bukkit.event.block.BlockPlaceEvent;
            import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener {
    
        public static Main instance;
    
        public void onEnable() {
            instance = this;
            Bukkit.getPluginManager().registerEvents(this, this);
        }
    
        @EventHandler
        public void onPlace(BlockPlaceEvent event) {
            event.getBlock().setType(Material.BEDROCK);
        }
    ERROR:
    Code:
    [23:23:27 ERROR]: Could not pass event BlockPlaceEvent to test v1.0
    java.lang.NullPointerException: null
    at org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData.newData(CraftBlockData.java:544) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.createBlockData(CraftServer.java:1934) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.createBlockData(CraftServer.java:1909) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.Bukkit.createBlockData(Bukkit.java:1390) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.Material.createBlockData(Material.java:3380) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock.setType(CraftBlock.java:164) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock.setType(CraftBlock.java:158) ~[patched_1.15.2.jar:git-Paper-67]
    at test.abc.test.Main.onPlace(Main.java:21) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor20.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.15.2.jar:git-Paper-67]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:545) ~[patched_1.15.2.jar:git-Paper-67]
    at org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory.callBlockPlaceEvent(CraftEventFactory.java:333) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.ItemStack.placeItem(ItemStack.java:236) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.PlayerInteractManager.a(PlayerInteractManager.java:506) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1373) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:27) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:1038) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:1031) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:1015) ~[patched_1.15.2.jar:git-Paper-67]
    at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:938) ~[patched_1.15.2.jar:git-Paper-67]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
     
  2. Offline

    KarimAKL

  3. Offline

    mocswiatla320

    Can anything be done about it?
     
  4. Online

    timtower Moderator Moderator

    @mocswiatla320
     
  5. Offline

    mocswiatla320

    I use the latest version of paperspigot, maybe it's his fault?

    Can you send this spigot file because I tried to do as you did this spigot-1.15.2 engine, but putting blocks doesn't work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 16, 2020
  6. Online

    timtower Moderator Moderator

    That would be against the DMCA.
     
  7. Offline

    mocswiatla320

    Oh okey you are from the usa I understand. In that case, I'm waiting for someone who has a problem with it and I can fix it.
     
  8. Online

    timtower Moderator Moderator

    I am not, but that does not mean that I am willing to break rules where I see them.
     

Share This Page