Search in sources :

Example 1 with KeyedBossBar

use of org.bukkit.boss.KeyedBossBar in project Glowstone by GlowstoneMC.

the class GlowServer method createBossBar.

@Override
@NotNull
public KeyedBossBar createBossBar(NamespacedKey key, @Nullable String title, BarColor barColor, BarStyle barStyle, BarFlag... barFlags) {
    KeyedBossBar bar = new GlowKeyedBossBar(key, title, barColor, barStyle, 1.0, barFlags);
    bossBars.put(key, bar);
    return bar;
}
Also used : GlowKeyedBossBar(net.glowstone.boss.GlowKeyedBossBar) KeyedBossBar(org.bukkit.boss.KeyedBossBar) GlowKeyedBossBar(net.glowstone.boss.GlowKeyedBossBar) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with KeyedBossBar

use of org.bukkit.boss.KeyedBossBar in project WildernessTp by AcmeProject.

the class TeleportGoneWild method focus.

static void focus(Player innocentPlayer, WorldConfig virus, int retry) {
    if (!virus.bar_enabled)
        return;
    final KeyedBossBar bossbar = auscultate(innocentPlayer, virus.bar_color_searching, virus.bar_style_searching);
    if (bossbar == null)
        return;
    int attempt = virus.retries - retry;
    bossbar.setProgress(Math.min((float) attempt / virus.retries, 1));
    bossbar.setTitle(TooWildForEnums.ATTEMPT.replace("%ATTEMPT%", "" + attempt).replace("%MAX%", "" + virus.retries));
}
Also used : KeyedBossBar(org.bukkit.boss.KeyedBossBar)

Example 3 with KeyedBossBar

use of org.bukkit.boss.KeyedBossBar in project WildernessTp by AcmeProject.

the class TeleportGoneWild method auscultate.

private static KeyedBossBar auscultate(Player sickPlayer, BarColor color, BarStyle style) {
    NamespacedKey key = cerealKiller(sickPlayer);
    KeyedBossBar bossbar = Bukkit.getBossBar(key);
    if (bossbar == null) {
        bossbar = Bukkit.createBossBar(key, "", color, style);
        bossbar.addPlayer(sickPlayer);
        bossbar.setVisible(true);
    } else {
        bossbar.setColor(color);
        bossbar.setStyle(style);
    }
    return bossbar;
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) KeyedBossBar(org.bukkit.boss.KeyedBossBar)

Example 4 with KeyedBossBar

use of org.bukkit.boss.KeyedBossBar in project WildernessTp by AcmeProject.

the class TeleportGoneWild method cure.

static void cure(Player guiltyPlayer) {
    NamespacedKey key = cerealKiller(guiltyPlayer);
    KeyedBossBar bossbar = Bukkit.getBossBar(key);
    if (bossbar == null)
        return;
    bossbar.removeAll();
    Bukkit.removeBossBar(cerealKiller(guiltyPlayer));
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) KeyedBossBar(org.bukkit.boss.KeyedBossBar)

Example 5 with KeyedBossBar

use of org.bukkit.boss.KeyedBossBar in project WildernessTp by AcmeProject.

the class TeleportGoneWild method infect.

static void infect(Player innocentPlayer, WorldConfig ebola) {
    if (!ebola.bar_enabled)
        return;
    final KeyedBossBar bossbar = auscultate(innocentPlayer, ebola.bar_color_waiting, ebola.bar_style_waiting);
    if (bossbar == null)
        return;
    final int milk = ebola.wamuppah;
    bossbar.setProgress(1);
    bossbar.setTitle(TooWildForEnums.PROCEED);
    new BukkitRunnable() {

        int i = 0;

        @Override
        public void run() {
            if (isCancelled())
                return;
            if (bossbar == null || bossbar.getPlayers().isEmpty()) {
                cancel();
                return;
            }
            // @formatter:on
            int s = milk - ++i;
            float l = Math.max((float) s / milk, 0F);
            bossbar.setProgress(l);
            bossbar.setTitle((l > 0) ? TooWildForEnums.WAIT_MSG.replace("{wait}", "" + s) : TooWildForEnums.PROCEED);
        }
    }.runTaskTimer(instace, 20, 20);
}
Also used : KeyedBossBar(org.bukkit.boss.KeyedBossBar) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Aggregations

KeyedBossBar (org.bukkit.boss.KeyedBossBar)5 NamespacedKey (org.bukkit.NamespacedKey)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 GlowKeyedBossBar (net.glowstone.boss.GlowKeyedBossBar)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1 NotNull (org.jetbrains.annotations.NotNull)1