Issue with ItemManager API not loading properly
Closed
Issue with ItemManager API not loading properly
Summary Ran into a strange issue with a plugin I'm developing (that uses MM as a dependency). Essentially, I'm attempting to get a copy mythic item's ItemStack to be used by my plugin later on. However, the issue is when the plugin loads initially, the itemstack that is returned seems to not include enchantment data. If I reload my plugin's config (essentially grabbing the itemstack copy again) the enchantments appear correctly.
Steps to reproduce
- In a plugin create a dependency for MM
- Grab an item's ItemStack
- Check the ItemStack for enchants
- Reload the plugin (NOT mythicmobs) so that the itemstack is grabbed again
- Compare ItemStack for enchants.
Relevant code:
// From Dependencies:
public static MythicBukkit getMythicMobs() {
return (MythicBukkit) getPlugin("MythicMobs");
}
if(!Dependencies.getMythicMobs().getItemManager().getItem(state).isPresent()) { // State (at this point) is a String containing "SkeletonKingSword"
Log.logInfo("Invalid mythic item tool specified/could not be found: " + state, Verbosity.HIGHEST);
return null;
}
ItemStack loadedItem = Dependencies.getMythicMobs().getItemManager().getItemStack(state);
Log.logInfo("Saving item: " + loadedItem, Verbosity.HIGHEST);
Current behavior ItemStack returned does not contain enchants, so any item comparisons w/ this itemstack are inherently false. When plugin is reloaded, the enchants are returned correctly and future comparisons work as expected.
Intended correct behavior Expect the ItemManager to return the itemstack containing the enchants.
Server log file https://pastebin.com/y3j55BrS
Debug log snippet https://pastebin.com/8NGAbRpP See line 27- the ItemStack returned by MM for SkeletonKingSword shows no enchants. However, on line 72 the same item is reloaded and contains the enchants.
Proposed fixes No clue as to what could be causing this...
Also thought I'd mention, was testing this out randomly on older versions of MC and can't replicate it on MM 5.5 running on 1.19.3
Interestingly enough, it appears that in the newer version, the UUID keys under the item attributes is also constantly changing, which makes comparisons more difficult as well. Would appreciate any insight you can provide on this issue!
added Needs Documentation label