Trouble with SheepDyeWoolEvent

Discussion in 'Bukkit Discussion' started by AlpacaGaming, Jan 4, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    AlpacaGaming

    So, I'm currently writing a ClaimSystem. For those who don't know: It's basically a Plugin which controls what piece of land is yours and prevents griefing among players. Now I ran into the following problem:
    I want to prevent other players from dyeing (and yes, I meant "dyeing" (changing color), not "dying" or killing) others sheep. There is a SheepDyeWoolEvent. However, the event doesn't provide the player that dyes the sheep. It only provides the sheep that is dyed and the new color. What I need is a player and the location of the sheep, so that i can check whether or not the Player that wants to dye the sheep has the permission to do so.
    My first idea was to get the player from another event where there is a player. For exmple the PlayerInteractEvent (or PlayerInteractAtEntityEvent or similar). I could wait for a player to right-click an entity while having dye in either his main- or off-hand and save the UUID of the player and the UUID of the sheep in some variable. Then I could simply wait a few ingame ticks (maybe 1 or 2) for the SheepDyeWoolEvent to fire and simply check whether the UUID of the sheep with which the SheepDyeWoolEvent has been called, matches the UUID from the sheep interacted with in the PlayerInteractEvent.
    The Problem is, that it could be, that the SheepDyeWoolEvent could be called before the PlayerInteractEvent EVEN if I were to use EventPrioritys, since they are different Events and thus, not in the same HandlerList.

    Does anyone know another workaround for this?
    Thanks in regards and sorry for the long text :p
     
Thread Status:
Not open for further replies.

Share This Page