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;
}
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));
}
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;
}
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));
}
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);
}
Aggregations