SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2021-07-18 11:07:59 +10:00
parent ba6c523bf3
commit 2e77f4180e

View File

@ -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
*