From 2e77f4180ea515682632bbc86f3cb096dec8bfc5 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 18 Jul 2021 11:07:59 +1000 Subject: [PATCH] SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent By: md_5 --- .../event/entity/SheepDyeWoolEvent.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java index 4db826e4db..10d2466fb6 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java @@ -1,10 +1,12 @@ package org.bukkit.event.entity; import org.bukkit.DyeColor; +import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a sheep's wool is dyed @@ -13,11 +15,18 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel; private DyeColor color; + private final Player player; + @Deprecated public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color) { + this(sheep, color, null); + } + + public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color, @Nullable Player player) { super(sheep); this.cancel = false; this.color = color; + this.player = player; } @Override @@ -36,6 +45,16 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { return (Sheep) entity; } + /** + * Returns the player dyeing the sheep, if available. + * + * @return player or null + */ + @Nullable + public Player getPlayer() { + return player; + } + /** * Gets the DyeColor the sheep is being dyed *