BannerMeta lose its data between an Inventory and InventoryClickEvent

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None

      VERSION: lastest from the BuildTools.

      [14:43:39 INFO]: This server is running CraftBukkit version git-Spigot-3fb9445-6e3cec8 (MC: 1.11.2) (Implementing API version 1.11.2-R0.1-SNAPSHOT)
      [14:43:39 INFO]: Checking version, please wait...
      [14:43:39 INFO]: You are 20 version(s) behind
      

       

       

      To reproduce this bug, it's pretty easy: 

      ItemStack is = new ItemStack(Material.BANNER);
      BannerMeta meta = (BannerMeta) is.getItemMeta();
      meta.setDisplayName("§bTeam aqua");
      meta.setBaseColor(DyeColr.CYAN);
      is.setItemMeta(meta);
      System.out.println(is);
      // Output: ItemStack{BANNER x 1, BANNER_META:{meta-type=BANNER, display-name=§bTeam aqua, base-color=CYAN}}
      

      Now in the InventoryClickEvent, there is no base-color:

       

       

      System.out.println(event.getCurrentItem());
      // Output: ItemStack{BANNER x 1, BANNER_META:{meta-type=BANNER, display-name=§bTeam aqua}}

       

      It's a very important bug (already see it into 1.10.x versions)

       

          [SPIGOT-3268] BannerMeta lose its data between an Inventory and InventoryClickEvent

          md_5 added a comment -

          Maybe, but its how Minecraft currently stores things

          md_5 added a comment - Maybe, but its how Minecraft currently stores things

          Vinetos added a comment -

          But it's deprecated :/ It will be removed in the future no ?

          Vinetos added a comment - But it's deprecated :/ It will be removed in the future no ?

          md_5 added a comment -

          >DyeColor.XXX.getDyeData()

          That doesn't require any hardcoded numbers

          md_5 added a comment - >DyeColor.XXX.getDyeData() That doesn't require any hardcoded numbers

          Vinetos added a comment -

          Oh yeah ! My bad !

          Is there an alternative to DyeColor.XXX.getDyeData() ? (To set the durability without 0, or 1, 2 etc..)

          Vinetos added a comment - Oh yeah ! My bad ! Is there an alternative to DyeColor.XXX.getDyeData() ? (To set the durability without 0, or 1, 2 etc..)

          md_5 added a comment -

          == will ALWAYS be false.
          Use .equals
          You should set the color with a damage value if you are maintaining a reference to compare

          md_5 added a comment - == will ALWAYS be false. Use .equals You should set the color with a damage value if you are maintaining a reference to compare

          Vinetos added a comment -

          Ok but how we compare two ItemStack ?

          ItemStack banner = ... // Banner with base color
          
          @EventHandler
          public void etc(InventoryClickEvent event) {
              if(event.getCurrentItem() == banner) // will be always false because banner has base color into its meta
          }

          Vinetos added a comment - Ok but how we compare two ItemStack ? ItemStack banner = ... // Banner with base color @EventHandler public void etc(InventoryClickEvent event) { if (event.getCurrentItem() == banner) // will be always false because banner has base color into its meta }

          md_5 added a comment -

          This is correct.
          I have added a deprecation notice. You should get the dye values from the itemstack damage now instead.

          md_5 added a comment - This is correct. I have added a deprecation notice. You should get the dye values from the itemstack damage now instead.

          Black Hole added a comment -

          For banner items the base color is encoded as the damage value of the item.
          I don't know if BannerMeta should parse that value.

          Black Hole added a comment - For banner items the base color is encoded as the damage value of the item. I don't know if BannerMeta should parse that value.

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

              Created:
              Updated:
              Resolved: