3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 13:00:06 +01:00
Paper/nms-patches/ItemDye.patch
2019-04-23 12:00:00 +10:00

31 Zeilen
1.2 KiB
Diff

--- a/net/minecraft/server/ItemDye.java
+++ b/net/minecraft/server/ItemDye.java
@@ -3,6 +3,8 @@
import com.google.common.collect.Maps;
import java.util.Map;
+import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit
+
public class ItemDye extends Item {
private static final Map<EnumColor, ItemDye> a = Maps.newEnumMap(EnumColor.class);
@@ -20,7 +22,17 @@
EntitySheep entitysheep = (EntitySheep) entityliving;
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) {
- entitysheep.setColor(this.b);
+ // CraftBukkit start
+ byte bColor = (byte) this.b.getColorIndex();
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+
+ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData()));
+ // CraftBukkit end
itemstack.subtract(1);
}