Java Code Examples for org.bukkit.boss.BossBar#addPlayer()
The following examples show how to use
org.bukkit.boss.BossBar#addPlayer() .
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: LugolsIodineDisplay.java From CraftserveRadiation with Apache License 2.0 | 6 votes |
private void add(Player player, LugolsIodineEffect.Effect effect) { Objects.requireNonNull(player, "player"); Objects.requireNonNull(effect, "effect"); BossBar bossBar = this.displayMap.computeIfAbsent(player.getUniqueId(), playerId -> this.createBossBar()); bossBar.setProgress(effect.getSecondsLeft() / (double) effect.getInitialSeconds()); bossBar.addPlayer(player); }
Example 2
Source File: PlayerListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void join(final PlayerJoinEvent event) { Player player = event.getPlayer(); resetPlayer(player); event.getPlayer().addAttachment(lobby, Permissions.OBSERVER, true); if (player.hasPermission("lobby.overhead-news")) { final String datacenter = minecraftService.getLocalServer().datacenter(); final Component news = new Component(ChatColor.GREEN) .extra(new TranslatableComponent( "lobby.news", new Component(ChatColor.GOLD, ChatColor.BOLD).extra(generalFormatter.publicHostname()) )); final BossBar bar = bossBarFactory.createBossBar(renderer.render(news, player), BarColor.BLUE, BarStyle.SOLID); bar.setProgress(1); bar.addPlayer(player); bar.show(); } if(!player.hasPermission("lobby.disabled-permissions-exempt")) { for(PermissionAttachmentInfo attachment : player.getEffectivePermissions()) { if(config.getDisabledPermissions().contains(attachment.getPermission())) { attachment.getAttachment().setPermission(attachment.getPermission(), false); } } } int count = lobby.getServer().getOnlinePlayers().size(); if(!lobby.getServer().getOnlinePlayers().contains(event.getPlayer())) count++; minecraftService.updateLocalServer(new SignUpdate(count)); }
Example 3
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 4
Source File: TicketDisplay.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@HandleModel public void ticketUpdated(@Nullable Ticket before, @Nullable Ticket after, Ticket latest) { final Arena arena = arenas.byId(latest.arena_id()); updateArena(arena); final Player player = userStore.find(latest.user()); if(player != null) { final BossBar bar = bars.getUnchecked(arena); if(after != null && after.server_id() == null) { bar.addPlayer(player); } else { bar.removePlayer(player); } } }
Example 5
Source File: BossBarUtilsBukkitImpl.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
/** * Creates a boss bar if doesn't exist * * @param player the player * @return the boss bar */ private BossBar createIfNotExists(Player player) { if(bossBars.containsKey(player.getUniqueId())) { return getBossBar(player); } BossBar bossBar = Bukkit.getServer().createBossBar("", Config.BOSSBAR_RAIDBAR_COLOR.toEnum(BarColor.class), Config.BOSSBAR_RAIDBAR_STYLE.toEnum(BarStyle.class)); bossBar.addPlayer(player); bossBars.put(player.getUniqueId(), bossBar); return bossBar; }
Example 6
Source File: BossBarManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Add an array of players to a bossbar in the BossBarManager through the stored ID. * * @param id The ID text for the bossbar. * @param players Array of players to be added to the bossbar */ void addPlayers(String id, Player[] players) { BossBar bar = barMap.get(id); if (bar != null) { for (Player p : players) { bar.addPlayer(p); } barMap.put(id, bar); } }
Example 7
Source File: EffCreateModernBossBar.java From skRayFall with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(Event evt) { BarStyle barStyle = BarStyle.SOLID; BarColor barColor = BarColor.PURPLE; if (style != null) { barStyle = style.getSingle(evt).getKey(); } if (color != null) { barColor = color.getSingle(evt).getKey(); } BossBar bar; if (flag != null) { bar = Bukkit.createBossBar(title.getSingle(evt).replace("\"", ""), barColor, barStyle, flag.getSingle(evt).getKey()); } else { bar = Bukkit.createBossBar(title.getSingle(evt).replace("\"", ""), barColor, barStyle); } if (value != null) { double vol = value.getSingle(evt).doubleValue(); if (vol > 100) { vol = 100; } else if (vol < 0) { vol = 0; } bar.setProgress(vol / 100); } for (Player p : players.getAll(evt)) { bar.addPlayer(p); } Core.bossbarManager.createBossBar(id.getSingle(evt).replace("\"", ""), bar); }
Example 8
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 9
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 10
Source File: Compat111.java From RedProtect with GNU General Public License v3.0 | 4 votes |
static void sendBarMsg(String msg, String color, Player p) { BossBar bar = Bukkit.createBossBar(msg, BarColor.valueOf(color), BarStyle.SEGMENTED_10); bar.addPlayer(p); removeBar(bar, p); }
Example 11
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); }
Example 12
Source File: BossAnnouncer.java From HubBasics with GNU Lesser General Public License v3.0 | 4 votes |
private void setBossBar(Player player, BossBar bossBar) { this.remBossBar(player); bossBar.addPlayer(player); this.playerBars.put(player.getUniqueId(), bossBar); }