org.bukkit.boss.BarColor Java Examples
The following examples show how to use
org.bukkit.boss.BarColor.
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: TimedPhase.java From VoxelGamesLibv2 with MIT License | 7 votes |
@Override public void enable() { super.enable(); originalTicks = ticks; log.finer("enable timed phase with name " + getName()); bossBar = Bukkit.createBossBar(getName(), BarColor.BLUE, BarStyle.SEGMENTED_20); getGame().getPlayers().forEach(u -> bossBar.addPlayer(u.getPlayer())); getGame().getSpectators().forEach(u -> bossBar.addPlayer(u.getPlayer())); started = true; }
Example #2
Source File: TicketDisplay.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
private void updateArena(Arena arena) { final Game game = games.byId(arena.game_id()); int minPlayers = 0; if(arena.next_server_id() != null) { minPlayers = servers.byId(arena.next_server_id()).min_players(); } final BaseComponent text; final double progress; if(minPlayers > 0 && arena.num_queued() < minPlayers) { text = gameFormatter.queued(game, minPlayers - arena.num_queued()); progress = (double) arena.num_queued() / (double) minPlayers; } else { text = gameFormatter.joining(game); progress = 1; } bars.getUnchecked(arena).update(text, progress, BarColor.YELLOW, BarStyle.SOLID, Collections.emptySet()); }
Example #3
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String setLobbyBossBarColor(String color) { color = color.toUpperCase(); BarColor c = null; if (!color.equalsIgnoreCase("default")) { try { c = BarColor.valueOf(color); } catch (Exception e) { return i18n("admin_command_invalid_bar_color"); } } game.setLobbyBossBarColor(c); return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name()) .replace("%type%", "LOBBY"); }
Example #4
Source File: TimeNotifications.java From CardinalPGM with MIT License | 6 votes |
@Override public void run() { if (GameHandler.getGameHandler().getMatch().isRunning()) { int timeLimit = TimeLimit.getMatchTimeLimit(); double time = MatchTimer.getTimeInSeconds(); if (timeLimit > 0) { double timeRemaining = timeLimit - time; BossBars.setProgress(bossBar, timeRemaining / timeLimit); if (lastSecond != (int) time) { lastSecond = (int) time; BossBars.setTitle(bossBar, new UnlocalizedChatMessage(ChatColor.AQUA + "{0} " + ChatUtil.getTimerColor(timeRemaining) + "{1}", new LocalizedChatMessage(ChatConstant.UI_TIMER), new UnlocalizedChatMessage(Strings.formatTime(timeRemaining + 1)))); if (timeRemaining < 30) { BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.RED); } else if (timeRemaining < 60) { BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.YELLOW); } else { BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.GREEN); } } } else if (lastSecond != (int) time) { lastSecond = (int) time; if ((int)time % 300 == 0) sendTimeElapsedMessage(time); } } }
Example #5
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String setGameBossBarColor(String color) { color = color.toUpperCase(); BarColor c = null; if (!color.equalsIgnoreCase("default")) { try { c = BarColor.valueOf(color); } catch (Exception e) { return i18n("admin_command_invalid_bar_color"); } } game.setGameBossBarColor(c); return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name()) .replace("%type%", "GAME"); }
Example #6
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String setGameBossBarColor(String color) { color = color.toUpperCase(); BarColor c = null; if (!color.equalsIgnoreCase("default")) { try { c = BarColor.valueOf(color); } catch (Exception e) { return i18n("admin_command_invalid_bar_color"); } } game.setGameBossBarColor(c); return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name()) .replace("%type%", "GAME"); }
Example #7
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
private String setLobbyBossBarColor(String color) { color = color.toUpperCase(); BarColor c = null; if (!color.equalsIgnoreCase("default")) { try { c = BarColor.valueOf(color); } catch (Exception e) { return i18n("admin_command_invalid_bar_color"); } } game.setLobbyBossBarColor(c); return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name()) .replace("%type%", "LOBBY"); }
Example #8
Source File: BukkitBossBarFactory.java From helper with MIT License | 6 votes |
private static BarColor convertColor(BossBarColor color) { switch (color) { case PINK: return BarColor.PINK; case BLUE: return BarColor.BLUE; case RED: return BarColor.RED; case GREEN: return BarColor.GREEN; case YELLOW: return BarColor.YELLOW; case PURPLE: return BarColor.PURPLE; case WHITE: return BarColor.WHITE; default: return convertColor(BossBarColor.defaultColor()); } }
Example #9
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 #10
Source File: FlagBossbar.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Override public void onFlagAdd(Game game) { baseTitle = getI18N().getVarString(Messages.Broadcast.BOSSBAR_PLAYING_ON) .setVariable("game", game.getName()) .toString(); baseColor = new SafeContainer<>(BarColor.GREEN); bossBar = new SafeContainer<>(Bukkit.getServer().createBossBar(baseTitle, baseColor.value, BarStyle.SOLID)); bossBar.value.setProgress(DEFAULT_PROGRESS); }
Example #11
Source File: BossBars.java From CardinalPGM with MIT License | 5 votes |
public static UUID addBroadcastedBossBar(ChatMessage bossBarTitle, BarColor color, BarStyle style, Boolean shown, BarFlag... flags) { UUID id = UUID.randomUUID(); LocalizedBossBar bossBar = new LocalizedBossBar(bossBarTitle, color, style, flags); bossBar.setVisible(shown); for (Player player : Bukkit.getOnlinePlayers()) { bossBar.addPlayer(player); } broadcastedBossBars.put(id, bossBar); return id; }
Example #12
Source File: BossBarMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
View(BossBarSource source, Player viewer) { this.source = source; this.viewer = viewer; this.bar = bossBarFactory.createBossBar(Components.blank(), BarColor.WHITE, BarStyle.SOLID); render(); bar.addPlayer(viewer); }
Example #13
Source File: TimeLimitCountdown.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override public BarColor barColor(Player viewer) { long seconds = remaining.getSeconds(); if(seconds > 60) { return BarColor.GREEN; } else if(seconds > 30) { return BarColor.YELLOW; } else { return BarColor.RED; } }
Example #14
Source File: Messages.java From Harbor with MIT License | 5 votes |
private static BarColor getBarColor(final String enumString) { BarColor barColor; try { barColor = BarColor.valueOf(enumString.toUpperCase().trim()); } catch (IllegalArgumentException e) { barColor = BarColor.BLUE; } return barColor; }
Example #15
Source File: CraftBossBar.java From Kettle with GNU General Public License v3.0 | 5 votes |
public CraftBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) { this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags) : EnumSet.noneOf(BarFlag.class); this.color = color; this.style = style; handle = new BossInfoServer( CraftChatMessage.fromString(title, true)[0], convertColor(color), convertStyle(style) ); updateFlags(); }
Example #16
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static BarColor loadBossBarColor(String color) { try { return BarColor.valueOf(color); } catch (Exception e) { return null; } }
Example #17
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static BarColor loadBossBarColor(String color) { try { return BarColor.valueOf(color); } catch (Exception e) { return null; } }
Example #18
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 #19
Source File: RenderedBossBar.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override public void update(BaseComponent title, double progress, BarColor color, BarStyle style, Set<BarFlag> flags) { this.title = title; this.progress = progress; this.color = color; this.style = style; this.flags.clear(); this.flags.addAll(flags); views.entrySet().forEach(entry -> entry.getValue().update(renderer.render(title, entry.getKey()), progress, color, style, flags)); }
Example #20
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 #21
Source File: BossBarManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Changed the color of a bossbar from the BossBarManager through the stored ID. * * @param id The ID text for the bossbar. * @param color The BarColor to be used. */ void changeColor(String id, BarColor color) { BossBar bar = barMap.get(id); if (bar != null) { bar.setColor(color); barMap.put(id, bar); } }
Example #22
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 #23
Source File: BossBarOptions.java From FunnyGuilds with Apache License 2.0 | 5 votes |
public Builder color(String barColor) { for (BarColor loopColor : BarColor.values()) { if (loopColor.name().equalsIgnoreCase(barColor)) { this.barColor = loopColor; break; } } return this; }
Example #24
Source File: MonumentModes.java From CardinalPGM with MIT License | 5 votes |
public MonumentModes(int after, final Pair<Material, Integer> material, final String name, int showBefore) { this.after = after; this.material = material; this.name = name; this.showBefore = showBefore; this.ran = false; this.bossBar = BossBars.addBroadcastedBossBar(new UnlocalizedChatMessage(""), BarColor.BLUE, BarStyle.SOLID, false); }
Example #25
Source File: LocalizedBossBar.java From CardinalPGM with MIT License | 5 votes |
public LocalizedBossBar(ChatMessage bossBarTitle, BarColor color, BarStyle style, BarFlag... flags) { this.bossBarTitle = bossBarTitle; this.color = color; this.style = style; this.shown = true; this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags):EnumSet.noneOf(BarFlag.class); }
Example #26
Source File: LocalizedBossBar.java From CardinalPGM with MIT License | 5 votes |
public void setColor(BarColor color) { if (color != this.color) { this.color = color; for (BossBar bossbar : playerBossBars.values()) { bossbar.setColor(color); } } }
Example #27
Source File: Poll.java From CardinalPGM with MIT License | 5 votes |
protected Poll(int id, CommandSender sender, String command, int time, boolean any) { this.id = id; this.sender = sender; this.command = command; this.any = any; this.time = time * 20; this.originalTime = this.time; this.bossBar = BossBars.addBroadcastedBossBar(new UnlocalizedChatMessage(""), BarColor.YELLOW, BarStyle.SOLID, true); taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Cardinal.getInstance(), new Runnable() { @Override public void run() { Poll.this.update(); } }, 0L, 1L); }
Example #28
Source File: BossBar19.java From BedWars with GNU Lesser General Public License v3.0 | 4 votes |
public BossBar19() { this.boss = Bukkit.createBossBar("", BarColor.PURPLE, BarStyle.SOLID); }
Example #29
Source File: BossBar19.java From BedWars with GNU Lesser General Public License v3.0 | 4 votes |
@Override public BarColor getColor() { return boss.getColor(); }
Example #30
Source File: BossBar19.java From BedWars with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setColor(BarColor color) { boss.setColor(color); }