Search in sources :

Example 1 with EnderDragonBattle

use of net.minecraft.server.v1_14_R1.EnderDragonBattle in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            try {
                bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
            } catch (NoSuchFieldError ex) {
                bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
            }
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            try {
                bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity))).bossBattle;
            } catch (NoSuchFieldError ex) {
                bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
            }
        }
    } catch (Exception e) {
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
    } catch (Exception e) {
    }
    return ret;
}
Also used : EnderDragonBattle(net.minecraft.server.v1_13_R2.EnderDragonBattle) CraftBossBar(org.bukkit.craftbukkit.v1_13_R2.boss.CraftBossBar) BossBar(org.bukkit.boss.BossBar) BossBattleServer(net.minecraft.server.v1_13_R2.BossBattleServer) ReportedException(net.minecraft.server.v1_13_R2.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 2 with EnderDragonBattle

use of net.minecraft.server.v1_14_R1.EnderDragonBattle in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
            if (battleObject == null) {
                return null;
            }
            bserver = ((EnderDragonBattle) battleObject).bossBattle;
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return ret;
}
Also used : EnderDragonBattle(net.minecraft.server.v1_16_R3.EnderDragonBattle) BossBar(org.bukkit.boss.BossBar) CraftBossBar(org.bukkit.craftbukkit.v1_16_R3.boss.CraftBossBar) DataWatcherObject(net.minecraft.server.v1_16_R3.DataWatcherObject) BossBattleServer(net.minecraft.server.v1_16_R3.BossBattleServer)

Example 3 with EnderDragonBattle

use of net.minecraft.server.v1_14_R1.EnderDragonBattle in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
            if (battleObject == null) {
                return null;
            }
            bserver = ((EnderDragonBattle) battleObject).bossBattle;
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return ret;
}
Also used : EnderDragonBattle(net.minecraft.server.v1_15_R1.EnderDragonBattle) CraftBossBar(org.bukkit.craftbukkit.v1_15_R1.boss.CraftBossBar) BossBar(org.bukkit.boss.BossBar) DataWatcherObject(net.minecraft.server.v1_15_R1.DataWatcherObject) BossBattleServer(net.minecraft.server.v1_15_R1.BossBattleServer)

Example 4 with EnderDragonBattle

use of net.minecraft.server.v1_14_R1.EnderDragonBattle in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
            if (battleObject == null) {
                return null;
            }
            bserver = ((EnderDragonBattle) battleObject).bossBattle;
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return ret;
}
Also used : EnderDragonBattle(net.minecraft.server.v1_14_R1.EnderDragonBattle) BossBar(org.bukkit.boss.BossBar) CraftBossBar(org.bukkit.craftbukkit.v1_14_R1.boss.CraftBossBar) DataWatcherObject(net.minecraft.server.v1_14_R1.DataWatcherObject) BossBattleServer(net.minecraft.server.v1_14_R1.BossBattleServer)

Aggregations

BossBar (org.bukkit.boss.BossBar)4 CommandException (net.citizensnpcs.api.command.exception.CommandException)1 BossBattleServer (net.minecraft.server.v1_13_R2.BossBattleServer)1 EnderDragonBattle (net.minecraft.server.v1_13_R2.EnderDragonBattle)1 ReportedException (net.minecraft.server.v1_13_R2.ReportedException)1 BossBattleServer (net.minecraft.server.v1_14_R1.BossBattleServer)1 DataWatcherObject (net.minecraft.server.v1_14_R1.DataWatcherObject)1 EnderDragonBattle (net.minecraft.server.v1_14_R1.EnderDragonBattle)1 BossBattleServer (net.minecraft.server.v1_15_R1.BossBattleServer)1 DataWatcherObject (net.minecraft.server.v1_15_R1.DataWatcherObject)1 EnderDragonBattle (net.minecraft.server.v1_15_R1.EnderDragonBattle)1 BossBattleServer (net.minecraft.server.v1_16_R3.BossBattleServer)1 DataWatcherObject (net.minecraft.server.v1_16_R3.DataWatcherObject)1 EnderDragonBattle (net.minecraft.server.v1_16_R3.EnderDragonBattle)1 CraftBossBar (org.bukkit.craftbukkit.v1_13_R2.boss.CraftBossBar)1 CraftBossBar (org.bukkit.craftbukkit.v1_14_R1.boss.CraftBossBar)1 CraftBossBar (org.bukkit.craftbukkit.v1_15_R1.boss.CraftBossBar)1 CraftBossBar (org.bukkit.craftbukkit.v1_16_R3.boss.CraftBossBar)1