Java Code Examples for org.bukkit.boss.BossBar#setVisible()
The following examples show how to use
org.bukkit.boss.BossBar#setVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DurabilityBar.java From AdditionsAPI with MIT License | 6 votes |
public static void hideDurabilityBossBar(Player player, EquipmentSlot slot) { UUID uuid = player.getUniqueId(); BossBar bar; HashMap<UUID, BossBar> playersBars; if (slot.equals(EquipmentSlot.HAND)) { playersBars = playersBarsMain; } else if (slot.equals(EquipmentSlot.OFF_HAND)) { playersBars = playersBarsOff; } else { return; } if (!playersBars.containsKey(uuid)) { return; } else { bar = playersBars.get(uuid); } bar.setVisible(false); bar.setProgress(1.0D); bar.setColor(BarColor.GREEN); }
Example 2
Source File: RenderedBossBar.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override public void addPlayer(Player player) { if(!views.containsKey(player)) { final BossBar view = bossBarFactory.createBossBar(renderer.render(title, player), color, style, flags.toArray(new BarFlag[flags.size()])); view.setVisible(visibile); view.addPlayer(player); views.put(player, view); } }
Example 3
Source File: BossBarManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Hide a bossbar from the BossBarManager through the stored ID for all players * who were assigned it. * * @param id The ID text for the bossbar. */ void hideBar(String id) { BossBar bar = barMap.get(id); if (bar != null) { bar.setVisible(false); barMap.put(id, bar); } }
Example 4
Source File: BossBarManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Show a bossbar from the BossBarManager through the stored ID for all players * who were assigned it. * * @param id The ID text for the bossbar. */ void showBar(String id) { BossBar bar = barMap.get(id); if (bar != null) { bar.setVisible(true); barMap.put(id, bar); } }
Example 5
Source File: LocalizedBossBar.java From CardinalPGM with MIT License | 5 votes |
public void addPlayer(Player player) { if (!playerBossBars.containsKey(player)) { BossBar bossBar = Bukkit.createBossBar(getTitle(player.getLocale()), this.color, this.style, this.flags.toArray(new BarFlag[flags.size()])); bossBar.setVisible(this.shown); bossBar.addPlayer(player); playerBossBars.put(player, bossBar); } }
Example 6
Source File: LocalizedBossBar.java From CardinalPGM with MIT License | 5 votes |
public void setVisible(Boolean visible) { if (visible != this.shown) { this.shown = visible; for (BossBar bossbar : playerBossBars.values()) { bossbar.setVisible(visible); } } }
Example 7
Source File: DurabilityBar.java From AdditionsAPI with MIT License | 4 votes |
public static void sendDurabilityBossBar(Player player, ItemStack item, EquipmentSlot slot) { BossBarConfig config = ConfigFile.getInstance().getBossBarConfig(); if (!config.show()) return; UUID uuid = player.getUniqueId(); BossBar bar; HashMap<UUID, BossBar> playersBars; String title; if (slot.equals(EquipmentSlot.HAND)) { title = LangFileUtils.get("item_durability_main_hand"); playersBars = playersBarsMain; } else if (slot.equals(EquipmentSlot.OFF_HAND)) { title = LangFileUtils.get("item_durability_off_hand"); playersBars = playersBarsOff; } else { return; } if (!playersBars.containsKey(uuid)) { bar = Bukkit.createBossBar(title, BarColor.GREEN, BarStyle.SOLID); bar.addPlayer(player); playersBars.put(uuid, bar); } else { bar = playersBars.get(uuid); } if (item == null || item.getType() == Material.AIR) { bar.setVisible(false); bar.setProgress(1.0D); return; } int durability = 0; int durabilityMax = 0; if (AdditionsAPI.isCustomItem(item)) { if (!config.showCustomItems() || item.getType().getMaxDurability() == 0) { bar.setVisible(false); bar.setProgress(1.0D); return; } CustomItemStack cStack = new CustomItemStack(item); CustomItem cItem = cStack.getCustomItem(); if (cItem.hasFakeDurability()) { durability = cStack.getFakeDurability(); durabilityMax = cItem.getFakeDurability(); } else if (cStack.getCustomItem().isUnbreakable()) { bar.setVisible(false); bar.setProgress(1.0D); return; } else { durabilityMax = item.getType().getMaxDurability(); durability = durabilityMax - item.getDurability(); } } else if (item.getType().getMaxDurability() != 0) { if (!config.showVanillaItems()) { bar.setVisible(false); bar.setProgress(1.0D); return; } durabilityMax = item.getType().getMaxDurability(); durability = durabilityMax - item.getDurability(); } else { bar.setVisible(false); bar.setProgress(1.0D); return; } double progress = (double) durability / (double) durabilityMax; if (progress > 1) { progress = 1; } else if (progress < 0) { progress = 0; } bar.setVisible(true); if (progress < 0) progress = 0; else if (progress > 1) progress = 1; try { bar.setProgress(progress); } catch (IllegalArgumentException event) {} if (progress >= 0.5) { bar.setColor(BarColor.GREEN); bar.setTitle(title + ChatColor.GREEN + durability + " / " + durabilityMax); } else if (progress >= 0.25) { bar.setColor(BarColor.YELLOW); bar.setTitle(title + ChatColor.YELLOW + durability + " / " + durabilityMax); } else { bar.setColor(BarColor.RED); bar.setTitle(title + ChatColor.RED + durability + " / " + durabilityMax); } }
Example 8
Source File: BossBarNotifyIO.java From BetonQuest with GNU General Public License v3.0 | 4 votes |
@Override public void sendNotify(String message, Collection<? extends Player> players) { BossBar bossBar = Bukkit.createBossBar(Utils.format(message), barColor, style); if (barFlags != null) { for (BarFlag flag : barFlags) { bossBar.addFlag(flag); } } bossBar.setProgress(progress); // Show bar for (Player player : players) { bossBar.addPlayer(player); } bossBar.setVisible(true); // Remove after stay ticks new BukkitRunnable() { @Override public void run() { bossBar.removeAll(); } }.runTaskLater(BetonQuest.getInstance(), stay); // If Countdown, then divide stay by countdown and reduce progress to 0 by those intevals if (countdown > 0) { int interval = stay / countdown; double amount = progress / ((double) countdown); new BukkitRunnable() { @Override public void run() { if (countdown == 0) { cancel(); return; } countdown -= 1; progress -= amount; bossBar.setProgress(Math.max(0.0, progress)); } }.runTaskTimer(BetonQuest.getInstance(), interval, interval); } super.sendNotify(message, players); }