Search in sources :

Example 1 with EnderDragonChangePhaseEvent

use of org.bukkit.event.entity.EnderDragonChangePhaseEvent in project Arclight by IzzelAliz.

the class PhaseManagerMixin method setPhase.

// @formatter:on
/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public void setPhase(PhaseType<?> phaseIn) {
    if (this.phase == null || phaseIn != this.phase.getType()) {
        if (this.phase != null) {
            this.phase.removeAreaEffect();
        }
        EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent((CraftEnderDragon) ((EntityBridge) this.dragon).bridge$getBukkitEntity(), (this.phase == null) ? null : CraftEnderDragon.getBukkitPhase(this.phase.getType()), CraftEnderDragon.getBukkitPhase(phaseIn));
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
        phaseIn = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
        this.phase = this.getPhase(phaseIn);
        if (!this.dragon.world.isRemote) {
            this.dragon.getDataManager().set(EnderDragonEntity.PHASE, phaseIn.getId());
        }
        LOGGER.debug("Dragon is now in phase {} on the {}", phaseIn, this.dragon.world.isRemote ? "client" : "server");
        this.phase.initPhase();
    }
}
Also used : EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) EnderDragonChangePhaseEvent(org.bukkit.event.entity.EnderDragonChangePhaseEvent) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)1 EnderDragonChangePhaseEvent (org.bukkit.event.entity.EnderDragonChangePhaseEvent)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1