Search in sources :

Example 1 with BossBar

use of com.palmergames.adventure.bossbar.BossBar in project SiegeWar by TownyAdvanced.

the class BossBarUtil method updateBattleSessionBossBar.

public static void updateBattleSessionBossBar() {
    BattleSession session = BattleSession.getBattleSession();
    TextComponent comp = Component.text(Translation.of("bossbar_msg_battle_time_remaining", session.getFormattedTimeRemainingUntilBattleSessionEnds()));
    float remaining = getRemainder(session.getScheduledEndTime(), SiegeWarSettings.getWarSiegeBattleSessionsDurationMinutes() * 60000);
    for (Player player : Bukkit.getOnlinePlayers()) {
        Resident resident = TownyAPI.getInstance().getResident(player);
        if (resident == null || ResidentMetaDataController.getBossBarsDisabled(resident))
            continue;
        BossBar bossBar = bossBarBattleSessionMap.containsKey(player) ? bossBarBattleSessionMap.get(player) : BossBar.bossBar(comp, 0, Color.WHITE, Overlay.PROGRESS);
        bossBar.progress((float) (remaining / 100.0));
        bossBar.name(comp);
        if (!bossBarBattleSessionMap.containsKey(player)) {
            bossBarBattleSessionMap.put(player, bossBar);
            Towny.getAdventure().player(player).showBossBar(bossBar);
        }
    }
}
Also used : BattleSession(com.gmail.goosius.siegewar.objects.BattleSession) TextComponent(com.palmergames.adventure.text.TextComponent) Player(org.bukkit.entity.Player) Resident(com.palmergames.bukkit.towny.object.Resident) BossBar(com.palmergames.adventure.bossbar.BossBar)

Example 2 with BossBar

use of com.palmergames.adventure.bossbar.BossBar in project SiegeWar by TownyAdvanced.

the class BossBarUtil method updateBannerCapBossBar.

public static void updateBannerCapBossBar(Player player, String msg, BannerControlSession bannerControlSession) {
    Resident resident = TownyAPI.getInstance().getResident(player);
    if (resident == null || ResidentMetaDataController.getBossBarsDisabled(resident))
        return;
    TextComponent comp = Component.text(msg);
    float remaining = getRemainder(bannerControlSession.getSessionEndTime(), SiegeWarSettings.getWarSiegeBannerControlSessionDurationMinutes());
    BossBar bossBar = bossBarBannerCapMap.containsKey(player) ? bossBarBannerCapMap.get(player) : BossBar.bossBar(comp, 0, Color.WHITE, Overlay.PROGRESS);
    bossBar.progress(remaining);
    bossBar.name(comp);
    if (!bossBarBannerCapMap.containsKey(player)) {
        bossBarBannerCapMap.put(player, bossBar);
        Towny.getAdventure().player(player).showBossBar(bossBar);
    }
}
Also used : TextComponent(com.palmergames.adventure.text.TextComponent) Resident(com.palmergames.bukkit.towny.object.Resident) BossBar(com.palmergames.adventure.bossbar.BossBar)

Aggregations

BossBar (com.palmergames.adventure.bossbar.BossBar)2 TextComponent (com.palmergames.adventure.text.TextComponent)2 Resident (com.palmergames.bukkit.towny.object.Resident)2 BattleSession (com.gmail.goosius.siegewar.objects.BattleSession)1 Player (org.bukkit.entity.Player)1