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

Skull BlockState causes NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version 4231-Spigot-1aabe50-5e46f1c (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
    • TestPlugin
    • Yes

      If you set the type of a block to Material.PLAYER_HEAD a Nullpointer will occour.
      The exception also occoures if you use setOwnerProfile(null) on Skull then the CraftSkull will set the internal Profile to null but the constructor of ResolvableProfile requires a non null GameProfile.

      How to reproduce:

      @EventHandler
      public void on(PlayerInteractEvent e) {
          if (e.getHand() != EquipmentSlot.HAND) return;
      
          Block block = e.getClickedBlock();
          block.setType(Material.PLAYER_HEAD);
          block.getState().setType(Material.PLAYER_HEAD);
          //optional. The NPE can be forced this way
          //But it also shows without this line
          //((Skull) block.getState()).setOwnerProfile(null);
          block.getState().update(true);
      }

       

      The topic came up after this thread:
      https://www.spigotmc.org/threads/gameprofile-is-null.652027/

            Unassigned Unassigned
            Player_Schark Simon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: