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

isSimilar broken for base64 textured skulls

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • CraftBukkit version git-Spigot-8faa8b4-fba9f48 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
    • Yes

      Getting a null pointer when using ItemStack isSimilar on skulls using base64 textures. 

       

      Using the following code:

      public class Main extends JavaPlugin {
      
         @Override
         public void onEnable() {
            ItemStack head1 = new ItemStack(Material.PLAYER_HEAD);
      
            UUID uuid = UUID.randomUUID();
            GameProfile profile1 = new GameProfile(uuid, null);
            profile1.getProperties().put("textures", new Property("textures", "some random skin value"));
      
            setProfile(head1, profile1);
      
            ItemStack head2 = head1.clone();
      
            if(head1.isSimilar(head2)) { // NPE here  
                System.out.println("Is similar");  
            }
      
         }
      
         private void setProfile(ItemStack item, GameProfile profile) {
            ItemMeta meta = item.getItemMeta();
            try {
               Field field = meta.getClass().getDeclaredField("profile");
               field.setAccessible(true);
               field.set(meta, profile);
            } catch (NoSuchFieldException | IllegalAccessException ex) {
               ex.printStackTrace();
            }
            item.setItemMeta(meta);
         }
      }
      

       

      NOTE: Code works fine using 1.14.4

            Unassigned Unassigned
            Tango Jack Tango
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: