summaryrefslogtreecommitdiffstats
path: root/nms-patches/DragonControllerManager.patch
blob: d637a25db8502ea62052ed6790a3a109855bce6c (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
31
32
33
34
35
36
37
38
39
40
41
--- a/net/minecraft/server/DragonControllerManager.java
+++ b/net/minecraft/server/DragonControllerManager.java
@@ -2,6 +2,10 @@
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEnderDragon;
+import org.bukkit.event.entity.EnderDragonChangePhaseEvent;
+// CraftBukkit end
 
 public class DragonControllerManager {
 
@@ -21,6 +25,19 @@
                 this.currentDragonController.e();
             }
 
+            // CraftBukkit start - Call EnderDragonChangePhaseEvent
+            EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent(
+                    (CraftEnderDragon) this.enderDragon.getBukkitEntity(),
+                    (this.currentDragonController == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentDragonController.getControllerPhase()),
+                    CraftEnderDragon.getBukkitPhase(dragoncontrollerphase)
+            );
+            this.enderDragon.world.getServer().getPluginManager().callEvent(event);
+            if (event.isCancelled()) {
+                return;
+            }
+            dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
+            // CraftBukkit end
+
             this.currentDragonController = this.b(dragoncontrollerphase);
             if (!this.enderDragon.world.isClientSide) {
                 this.enderDragon.getDataWatcher().set(EntityEnderDragon.PHASE, Integer.valueOf(dragoncontrollerphase.b()));
@@ -42,6 +59,6 @@
             this.dragonControllers[i] = dragoncontrollerphase.a(this.enderDragon);
         }
 
-        return this.dragonControllers[i];
+        return (T) this.dragonControllers[i]; // CraftBukkit - decompile error
     }
 }