Auxilor / EcoArmor

Custom armor sets plugin for the latest minecraft version
GNU General Public License v3.0
31 stars 27 forks source link

Items#getCustomItem returns advanced item for non-advanced items #11

Closed WolfyScript closed 2 years ago

WolfyScript commented 2 years ago

Describe the bug I recently implemented support for CustomItems from eco in WolfyUtilities (and CustomCrafting).
It simply uses the Items#getCustomItem(ItemStack) method and then gets the key from it, to later match the items in the recipes.

However, it was reported to me that when using equipment from EcoArmor, it returns the advanced key for non-advanced items.

I then tested it with the default configuration of EcoArmor. For example, the angelic set (/ecoarmor give <player> set:angelic) returns the following:

ecoarmor:set_angelic_boots_advanced
ecoarmor:set_angelic_leggings_advanced
ecoarmor:set_angelic_elytra
ecoarmor:set_angelic_chestplate
ecoarmor:set_angelic_helmet_advanced

As you can see, even though all of them are the default variant, some return advanced keys. Weirdly enough, this is not consistent between sets. In each set, there are a few items correctly identified:

To Reproduce I made a very simple test plugin to rule out any possible conflicts. That plugin simply returns the selected item when running /ecoarmortest

The simple test plugin ```java package com.wolfyscript.ecoarmortest; import com.willfp.eco.core.items.Items; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; public final class Ecoarmortest extends JavaPlugin { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (label.equalsIgnoreCase("ecoarmortest")) { if(sender instanceof Player player) { ItemStack item = player.getEquipment().getItemInMainHand(); if (!item.getType().equals(Material.AIR)) { if (Items.isCustomItem(item)) { player.sendMessage("CustomItem: " + Items.getCustomItem(item).getKey().toString()); } } } } return true; } } ``` ```yml name: Ecoarmortest version: '${project.version}' main: com.wolfyscript.ecoarmortest.Ecoarmortest api-version: 1.18 depend: [ eco, EcoArmor ] commands: ecoarmortest: usage: "/ecoarmortest" ```

Steps to reproduce the behaviour:

  1. Get any of the default sets (For example: /ecoarmor give <player> set:angelic)
  2. For each item, hold it in your hand and run /ecoarmortest
  3. Find that it returns the advanced key for non-advanced items.

Expected behavior The Items#getCustomItem(ItemStack) method should return the advanced item only if the item is advanced.
Otherwise, it should return the non-advanced item.

Server Information: This server is running CraftBukkit version 3453-Spigot-ffceeae-64db512 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT)

eco version 6.27.3 EcoArmor version 7.36.0

WillFP commented 2 years ago

Fixed in next version