Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-1129

Spawning a LeashHitch with World#spawn(Location, LeashHitch.class) throws a NPE when no block is next to the fence post

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Windows 7 64 bit, Java 1.8.0_51-b16

    • my own plugin

      Whenever I want to spawn a LeashHitch on a fence and there is no block besides the fence block I get a NPE.

      LeashHitch hitch = null;
      			try
      			{
      				hitch = loc.getWorld().spawn(loc, LeashHitch.class);
      			}
      			catch(Exception ex)
      			{
      				ex.printStackTrace();
      			}
      
      java.lang.NullPointerException
             at org.bukkit.craftbukkit.v1_8_R3.CraftWorld.createEntity(CraftWorld.java:1083)
             at org.bukkit.craftbukkit.v1_8_R3.CraftWorld.spawn(CraftWorld.java:1137)
             at org.bukkit.craftbukkit.v1_8_R3.CraftWorld.spawn(CraftWorld.java:862)
             at skill.chopping.TreeInstance.buildTree(TreeInstance.java:362)
             at skill.chopping.TreeInstance.<init>(TreeInstance.java:106)
             at skill.chopping.TreeInstanceManager.addTreeInstanceFromResultSet(TreeInstanceManager.java:70)
             at skill.chopping.TreeInstanceManager.loadFromDatabase(TreeInstanceManager.java:47)
             at skill.chopping.TreeInstanceManager.<init>(TreeInstanceManager.java:26)
             at skill.Chopping.setUpTrees(Chopping.java:147)
             at skill.Chopping.<init>(Chopping.java:61)
             at skill.SkillManager.registerSkills(SkillManager.java:85)
             at skill.SkillManager.<init>(SkillManager.java:42)
             at main.UnleashedSkills.setUpSkills(UnleashedSkills.java:216)
             at main.UnleashedSkills.onEnable(UnleashedSkills.java:58)
             at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)
             at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)
             at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
             at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:356)
             at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:316)
             at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:742)
             at org.bukkit.Bukkit.reload(Bukkit.java:534)
             at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25)
             at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
             at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:642)
             at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:628)
             at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:404)
             at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:368)
             at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657)
             at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560)
             at java.lang.Thread.run(Unknown Source)
      

      I attached 2 images showing the result of running the posted code at 2 different locations, one location has another block to the side, the other location has no blocks to the side.

            Unassigned Unassigned
            domisum Dominik
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: