Commits

Matthew Steglinski authored and md_5 committed 5fe510da591
SPIGOT-1934: Expand EnderDragon API - implement dragon phases
No tags

nms-patches/DragonControllerManager.patch

Added
1 +--- a/net/minecraft/server/DragonControllerManager.java
2 ++++ b/net/minecraft/server/DragonControllerManager.java
3 +@@ -2,32 +2,44 @@
4 +
5 + import org.apache.logging.log4j.LogManager;
6 + import org.apache.logging.log4j.Logger;
7 ++import org.bukkit.craftbukkit.entity.CraftEnderDragon;
8 ++import org.bukkit.entity.EnderDragon;
9 ++import org.bukkit.event.entity.EnderDragonChangePhaseEvent;
10 +
11 + public class DragonControllerManager {
12 +
13 + private static final Logger a = LogManager.getLogger();
14 +- private final EntityEnderDragon b;
15 +- private final IDragonController[] c = new IDragonController[DragonControllerPhase.c()];
16 +- private IDragonController d;
17 ++ private final EntityEnderDragon b; // PAIL: Rename enderDragon
18 ++ private final IDragonController[] c = new IDragonController[DragonControllerPhase.c()]; // PAIL: Rename dragonControllers
19 ++ private IDragonController d; // PAIL: Rename currentDragonController
20 +
21 + public DragonControllerManager(EntityEnderDragon entityenderdragon) {
22 + this.b = entityenderdragon;
23 + this.a(DragonControllerPhase.k);
24 + }
25 +
26 +- public void a(DragonControllerPhase<?> dragoncontrollerphase) {
27 +- if (this.d == null || dragoncontrollerphase != this.d.i()) {
28 ++ public void a(DragonControllerPhase<?> dragoncontrollerphase) { // PAIL: Rename setControllerPhase
29 ++ if (this.d == null || dragoncontrollerphase != this.d.i()) { // PAIL: Rename getControllerPhase
30 + if (this.d != null) {
31 +- this.d.e();
32 ++ this.d.e(); // PAIL: Rename
33 + }
34 +
35 +- this.d = this.b(dragoncontrollerphase);
36 ++ // CraftBukkit start - Call EnderDragonChangePhaseEvent
37 ++ EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent((CraftEnderDragon) this.b.getBukkitEntity(), this.d == null ? null : CraftEnderDragon.getBukkitPhase(this.d.i()), CraftEnderDragon.getBukkitPhase(dragoncontrollerphase));
38 ++ this.b.world.getServer().getPluginManager().callEvent(event);
39 ++ if (event.isCancelled()) {
40 ++ return;
41 ++ }
42 ++ dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
43 ++ // CraftBukkit end
44 ++
45 ++ this.d = this.b(dragoncontrollerphase); // PAIL: Rename getDragonController
46 + if (!this.b.world.isClientSide) {
47 +- this.b.getDataWatcher().set(EntityEnderDragon.a, Integer.valueOf(dragoncontrollerphase.b()));
48 ++ this.b.getDataWatcher().set(EntityEnderDragon.a, Integer.valueOf(dragoncontrollerphase.b())); // PAIL: Rename getId
49 + }
50 +
51 + DragonControllerManager.a.debug("Dragon is now in phase {} on the {}", new Object[] { dragoncontrollerphase, this.b.world.isClientSide ? "client" : "server"});
52 +- this.d.d();
53 ++ this.d.d(); // PAIL: Rename reset
54 + }
55 + }
56 +
57 +@@ -42,6 +54,6 @@
58 + this.c[i] = dragoncontrollerphase.a(this.b);
59 + }
60 +
61 +- return this.c[i];
62 ++ return (T) this.c[i];
63 + }
64 + }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut