Search in sources :

Example 1 with SidebarString

use of xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.SidebarString in project Ublisk by Derkades.

the class Scoreboard method getScoreboard.

public static Sidebar getScoreboard(UPlayer player) {
    String r = ChatColor.RESET.toString();
    String redBold = RED + "" + BOLD;
    List<String> strings = new ArrayList<String>();
    strings.add(DARK_GRAY + "---------------");
    strings.add(redBold + "XP");
    strings.add(GRAY + "" + player.getXP() + " / " + CustomXP.getRequiredXP(player.getLevel() + 1));
    strings.add(r + " ");
    strings.add(redBold + "Health");
    strings.add(GRAY + "" + player.getHealth() + " / " + player.getMaxHealth());
    if (player.getFriends().size() > 1) {
        boolean displayedOnlineFriends = false;
        for (OfflinePlayer friend : player.getFriends()) {
            if (friend != null && friend.isOnline()) {
                if (!displayedOnlineFriends) {
                    strings.add(redBold + "Online Friends");
                    strings.add(r + r + r + "");
                    displayedOnlineFriends = true;
                }
                UPlayer online = new UPlayer(friend);
                strings.add(ChatColor.DARK_AQUA + friend.getName() + DARK_GRAY + ": " + ChatColor.AQUA + Math.round(online.getHealth()) + "HP");
            }
        }
    }
    strings.add(r + DARK_GRAY + "---------------");
    List<SidebarString> sidebarStrings = new ArrayList<SidebarString>();
    for (String string : strings) sidebarStrings.add(new SidebarString(string));
    String title = DARK_AQUA + "" + BOLD + "Information";
    return new Sidebar(title, Main.getInstance(), Integer.MAX_VALUE, sidebarStrings.toArray(new SidebarString[] {}));
}
Also used : SidebarString(xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.SidebarString) UPlayer(xyz.derkades.ublisk.utils.UPlayer) ArrayList(java.util.ArrayList) OfflinePlayer(org.bukkit.OfflinePlayer) SidebarString(xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.SidebarString) Sidebar(xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.Sidebar)

Aggregations

ArrayList (java.util.ArrayList)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 Sidebar (xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.Sidebar)1 SidebarString (xyz.derkades.ublisk.ext.com.coloredcarrot.api.sidebar.SidebarString)1 UPlayer (xyz.derkades.ublisk.utils.UPlayer)1