[SPIGOT-3268] BannerMeta lose its data between an Inventory and InventoryClickEvent Created: 24/May/17  Updated: 25/May/17  Resolved: 25/May/17

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Vinetos Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

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)

 



 Comments   
Comment by md_5 [ 25/May/17 ]

Maybe, but its how Minecraft currently stores things

Comment by Vinetos [ 25/May/17 ]

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

Comment by md_5 [ 25/May/17 ]

>DyeColor.XXX.getDyeData()

That doesn't require any hardcoded numbers

Comment by Vinetos [ 25/May/17 ]

Oh yeah ! My bad !

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

Comment by md_5 [ 25/May/17 ]

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

Comment by Vinetos [ 25/May/17 ]

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
}
Comment by md_5 [ 25/May/17 ]

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

Comment by Black Hole [ 24/May/17 ]

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.

Generated at Sat Dec 13 11:52:35 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.