1.16.5 Entity conflict with existing plugin

Discussion in 'Spigot Plugin Development' started by tommyokie, Jan 21, 2021.

  1. I have a Minecraft server and I just finished programming a plugin that uses custom villagers (summoned by commands) that allow you to teleport from place to place. The problem is that the villagers are conflicting with the "Shopkeepers" plugin, which also uses villagers.
    When I click on one of my villagers, instead of running my plugin's Event Handler and opening a GUI/doing the task I programmed, it opens the shopkeepers GUI.
    Shopkeepers have caused my plugin to not work at all...

    does anyone know how I can fix the conflict?

    -and pls don't just say "uninstall shopkeepers", because I'm not gonna do that, we've been using shopkeepers for over half a year now...
     
  2. Try to check the name of entity and if is true, open the inventory
     
  3. Perhaps setting the event priority of @EventHandler to high will work better.
    interacting with your custom villagers will then be higher priority (of course) and should get final say over the other plugin.
     
  4. Aren’t you storing the UUID of the villagers that you spawned?
     
  5. Do checks to see if the villager that is interacted with is yours, Like @Plochem said about storing UUID's and doing checks against them
     
  6. How could I go about doing that? That's what I was thinking about but I don't know how to do it.

    I use the spigot "Villager" class to hold the custom villager. It holds the UUID (and all the other attributes and methods for the villager).
    -I save the UUID to a file when the plugin is disabled.

    That's what I do. in the events, I test if the villager entity object equals my villager object. maybe I should just be using the UUID...?
     
  7. I just changed the plugin a bit so that the Event only tests that the UUID of the villager matches, instead of the entire Villager object matching (which requires the name, custom model data, etc.)
    and, as far as I can tell this fixed the problem...

    Thanks for the help!
     
    #7 tommyokie, Jan 21, 2021
    Last edited: Jan 21, 2021
  8. Just for future reference, you can change annotation values like so: @EventHandler(eventPriority = EventPriority.HIGH)
    Glad you could figure it out though.
     
  9. Follow up comment: Not sure how your method of comparing entities fixed your issue, but you probably actually want to use a lower event priority, so that you can cancel the interact entity event before it is handled by other plugins such as Shopkeepers. Shopkeepers' villager editor (the one that allows editing any regular villagers; i.e. not the one for editing villagers spawned by the Shopkeepers plugin itself) listens on high priority and ignores the event if it is cancelled.