Search in sources :

Example 26 with BossBar

use of org.bukkit.boss.BossBar in project solinia3-core by mixxit.

the class ScoreboardUtils method UpdateScoreboard.

public static void UpdateScoreboard(Player player, int maxmp, int mana) {
    if (player != null) {
        BossBar bossbar = StateManager.getInstance().getBossBar(player.getUniqueId());
        if (bossbar == null) {
            bossbar = Bukkit.createBossBar(player.getUniqueId().toString(), BarColor.BLUE, BarStyle.SOLID);
            bossbar.addPlayer(player);
            StateManager.getInstance().setBossBar(player.getUniqueId(), bossbar);
        }
        try {
            boolean found = false;
            for (Player bossbarplayer : bossbar.getPlayers()) {
                if (bossbarplayer == player) {
                    found = true;
                }
            }
            if (found == false)
                bossbar.addPlayer(player);
            double maxmana = maxmp;
            bossbar.setTitle("MANA: " + mana + " ");
            double progress = (double) ((double) mana / (double) maxmana);
            if (progress < 0d)
                progress = 0d;
            if (progress > 1d)
                progress = 1d;
            bossbar.setProgress(progress);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) BossBar(org.bukkit.boss.BossBar) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Example 27 with BossBar

use of org.bukkit.boss.BossBar in project EliteMobs by MagmaGuy.

the class CustomBossBossBar method removeTrackingPlayer.

public void removeTrackingPlayer(Player player) {
    trackingPlayers.remove(player);
    BossBar bossBar = bossBars.remove(player);
    if (bossBar != null)
        bossBar.removeAll();
}
Also used : BossBar(org.bukkit.boss.BossBar)

Example 28 with BossBar

use of org.bukkit.boss.BossBar in project Ublisk by Derkades.

the class DoubleXP method startDoubleXP.

public static void startDoubleXP(final UPlayer player) {
    if (DoubleXP.isActive()) {
        Bukkit.broadcastMessage(Message.DOUBLE_XP_ALREADY_ACTIVE.toString());
        new URunnable() {

            public void run() {
                startDoubleXP(player);
            }
        }.runLater(5 * 60 * 20);
        return;
    }
    Ublisk.broadcastPrefixedMessage("Double XP started thanks to " + player.getName());
    DoubleXP.DOUBLE_XP_PROGRESS = 1.0f;
    DoubleXP.DOUBLE_XP_SECONDS_LEFT = DoubleXP.DOUBLE_XP_TOTAL_SECONDS;
    final BossBar bar = Ublisk.createBossBar("Double XP - " + player.getName(), BarColor.GREEN, BarStyle.SOLID);
    Ublisk.showBossBar(bar, DoubleXP.DOUBLE_XP_TOTAL_SECONDS * 20, Ublisk.getOnlinePlayers());
    new BukkitRunnable() {

        public void run() {
            // Every second: remove 0.2 seconds from `DOUBLE_XP_SECONDS_LEFT` and recalculate percentage (0.2 seconds because this is ran 5 times every second).
            DoubleXP.DOUBLE_XP_SECONDS_LEFT -= 0.2;
            float percent = ((float) DoubleXP.DOUBLE_XP_SECONDS_LEFT) / ((float) DoubleXP.DOUBLE_XP_TOTAL_SECONDS);
            DoubleXP.DOUBLE_XP_PROGRESS = percent;
            Logger.log(LogLevel.DEBUG, "Seconds left: " + DoubleXP.DOUBLE_XP_SECONDS_LEFT + " | Total seconds: " + DoubleXP.DOUBLE_XP_TOTAL_SECONDS + " | Percentage float: " + DoubleXP.DOUBLE_XP_PROGRESS);
            if (DoubleXP.DOUBLE_XP_SECONDS_LEFT == 0) {
                this.cancel();
                DoubleXP.DOUBLE_XP_PROGRESS = 0.0f;
                Ublisk.broadcastPrefixedMessage("Double XP has ended.");
            }
            // Update bossbar
            bar.setProgress(DOUBLE_XP_PROGRESS);
        }
    }.runTaskTimer(Main.getInstance(), 0L, 4);
}
Also used : URunnable(xyz.derkades.ublisk.utils.URunnable) BossBar(org.bukkit.boss.BossBar) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 29 with BossBar

use of org.bukkit.boss.BossBar in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            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 : BossBar(org.bukkit.boss.BossBar) CraftBossBar(org.bukkit.craftbukkit.v1_10_R1.boss.CraftBossBar) BossBattleServer(net.minecraft.server.v1_10_R1.BossBattleServer) ReportedException(net.minecraft.server.v1_10_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 30 with BossBar

use of org.bukkit.boss.BossBar in project Citizens2 by CitizensDev.

the class BossBarTrait method run.

@Override
public void run() {
    if (!npc.isSpawned() || !isBoss(npc.getEntity()))
        return;
    BossBar bar = NMSImpl.getBossBar(npc.getEntity());
    bar.setVisible(visible);
    if (color != null) {
        bar.setColor(color);
    }
    if (title != null) {
        bar.setTitle(title);
    }
    for (BarFlag flag : BarFlag.values()) {
        bar.removeFlag(flag);
    }
    for (BarFlag flag : flags) {
        bar.addFlag(flag);
    }
}
Also used : BarFlag(org.bukkit.boss.BarFlag) BossBar(org.bukkit.boss.BossBar)

Aggregations

BossBar (org.bukkit.boss.BossBar)33 UUID (java.util.UUID)6 Location (org.bukkit.Location)5 BarFlag (org.bukkit.boss.BarFlag)5 Player (org.bukkit.entity.Player)5 Vector (org.bukkit.util.Vector)5 ArmorStand (org.bukkit.entity.ArmorStand)4 Seat (me.legofreak107.vehicles.objects.Seat)3 Vehicle (me.legofreak107.vehicles.objects.Vehicle)3 CommandException (net.citizensnpcs.api.command.exception.CommandException)3 EntityArmorStand (net.minecraft.server.v1_12_R1.EntityArmorStand)3 PacketPlayInSteerVehicle (net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle)3 BarColor (org.bukkit.boss.BarColor)3 BarStyle (org.bukkit.boss.BarStyle)3 CraftArmorStand (org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand)3 PlayerInventory (org.bukkit.inventory.PlayerInventory)3 java.util (java.util)2 LivingEntity (org.bukkit.entity.LivingEntity)2 EulerAngle (org.bukkit.util.EulerAngle)2 Denizen (com.denizenscript.denizen.Denizen)1