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