Similar ItemStacks are not similar with #isSimilar(...)

Discussion in 'Plugin Development' started by DutchJellyV2, Jul 6, 2020.

  1. Offline

    DutchJellyV2

    Hello,

    My plugin is comparing
    ItemStack{BLACK_STAINED_GLASS_PANE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=º7}}
    against
    ItemStack{BLACK_STAINED_GLASS_PANE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=º7}}

    As you can see, the toString() method returns equal strings. However, when I call a.isSimilar(b), it returns false. Does anyone have a clue on how to compare itemstacks on item meta? I only want to ignore the amount, which seems to be a job for #isSimilar().

    I'm thinking that it could have something to do with the api changes in 1.16. I haven't tested this tho because that would require me to setup a whole new test server and try to compile my plugin for this version.

    A really stupid and inefficient solution could be to compare the strings and filter out the amount part of the string. I really would like to find a way to compare the itemstacks properly.

    Thanks in advance.
     
  2. Offline

    knokko

    Weird stuff can happen if you don't specify an api-version in your plugin.yml. If I understand it correctly, you are using your plug-in on a 1.16 server, but compiling to a lower version of bukkit?
     

Share This Page