Java Code Examples for org.bukkit.boss.BarStyle#SOLID

The following examples show how to use org.bukkit.boss.BarStyle#SOLID . 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: BukkitBossBarFactory.java    From helper with MIT License 6 votes vote down vote up
private static BarStyle convertStyle(BossBarStyle style) {
    switch (style) {
        case SOLID:
            return BarStyle.SOLID;
        case SEGMENTED_6:
            return BarStyle.SEGMENTED_6;
        case SEGMENTED_10:
            return BarStyle.SEGMENTED_10;
        case SEGMENTED_12:
            return BarStyle.SEGMENTED_12;
        case SEGMENTED_20:
            return BarStyle.SEGMENTED_20;
        default:
            return convertStyle(BossBarStyle.defaultStyle());
    }
}
 
Example 2
Source File: EffCreateModernBossBar.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@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 3
Source File: BossBarSource.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
default BarStyle barStyle(Player viewer) {
    return BarStyle.SOLID;
}
 
Example 4
Source File: Stats.java    From CardinalPGM with MIT License 4 votes vote down vote up
public void updateDisplay(final Player player) {
    if (!shouldShow(player)) return;

    final int kills = getKills(player.getUniqueId());
    final int deaths = getDeaths(player.getUniqueId());
    final String kd = format.format((double)kills / Math.max(deaths, 1)).replace(",", ".");

    switch (Settings.getSettingByName("Stats").getValueByPlayer(player).getValue()) {
        case "sidebar":
            if (!sidebarView.contains(player.getUniqueId())) {
                sidebarView.add(player.getUniqueId());
                sendTeamPackets(player, true);
            }
            sendSlotPackets(player, true);
            String prefix = "K:" + ChatColor.GREEN + Math.min(kills, 999);
            String suffix = "" + Math.min(deaths, 999) + ChatColor.WHITE + " K/D:" + ChatColor.AQUA + kd;
            PacketUtils.sendPacket(player, new PacketPlayOutScoreboardTeam(2, "scoreboard-stats", "scoreboard-stats", prefix, suffix, -1, "never", "never", 0, Collections.singletonList(scoreboardEntry)));
            break;
        case "boss bar":
            if (!bossBars.containsKey(player.getUniqueId())) {
                LocalizedBossBar bossBar = new LocalizedBossBar(new UnlocalizedChatMessage(""), BarColor.PURPLE, BarStyle.SOLID);
                bossBar.addPlayer(player);
                bossBars.put(player.getUniqueId(), bossBar);
            }
            bossBars.get(player.getUniqueId()).setTitle(getLocalizedMessage(kills, deaths, kd));
            break;
        case "action bar":
            if (actionBarTasks.containsKey(player.getUniqueId())) {
                Bukkit.getScheduler().cancelTask(actionBarTasks.get(player.getUniqueId()));
            }
            actionBarTasks.put(player.getUniqueId(), Bukkit.getScheduler().scheduleSyncRepeatingTask(Cardinal.getInstance(), new Runnable() {

                private int tick;

                @Override
                public void run() {
                    if (tick > 40) {
                        if (actionBarTasks.containsKey(player.getUniqueId())) {
                            Bukkit.getScheduler().cancelTask(actionBarTasks.get(player.getUniqueId()));
                            actionBarTasks.remove(player.getUniqueId());
                        }
                    } else {
                        sendActionBarPacket(player, kills, deaths, kd);
                        tick++;
                    }
                }
            }, 1L, 1L));
            break;
    }
}