summaryrefslogtreecommitdiffstats
path: root/nms-patches/ItemDye.patch
blob: ab3d4cd2d171b248bb28926b7051aa113d532ed3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--- 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);
@@ -19,7 +21,17 @@
             EntitySheep entitysheep = (EntitySheep) entityliving;
 
             if (!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);
             }