1.14.4 Detect ItemStack Update (ItemStack Meta Change)?

Discussion in 'Spigot Plugin Development' started by TDStuart, Mar 12, 2020.

  1. Is this even possible and is there any events I can use to check the inventory that will not cause a strain on the server?
     
  2. Store the itemMeta in your custom storage and check if itemMeta from storage equal itemMeta in your inventory
     
  3. There isn't many vanilla things that can do that,things that can affect meta are the anvil and the enchanting table(possible grinder in newer versions) you could check the events from them

    The only problem might be if its directly changed through code..


    Also if you dont mind tell us what you want to achieve
     
  4. I was hoping to detect when an enchantment is applied to an item. Specifically by other plugins or the /enchant command.
    I have custom enchants that I got to work with /enchant but I need to find a way to apply the lore.
     
  5. Hello,

    If you want to check in game enchantments (with enchantment table), you can listen to the ItemEnchantEvent.
    For other enchantments (plugins/commands), the best solution would be for others plugins to call an ItemEnchantEvent so you can detect the enchantment.. If it's not possible, then the only solution I see is to run a loop (BukkitScheduler#runTaskTimer) which will iterate over all players and all item in their inventory to handle the enchantments.
     
  6. Ya I was more looking if there is an event or something that fires when a player inventory is updated. I am trying to get it to work with essentials and add a custom lore when my custom enchantment is applied. Thanks for the idea though.