HyperScript
Docs

← All scripts

TabList.hs

The list players see when they hold Tab: your server's name on top in changing colours, a line about the server below it, the player count, their ping, the TPS and the time underneath, and every name with its rank in front.

by HyperScript TeamHyperScript 1.7.3+1 event handler2 timers108 linestab listtablistheaderfooterranksserver template
In the script list

Put the file in plugins/HyperScript/scripts and it is live. Or type /hyperscript install tablist on your server.

# ==============================================================
#  TabList.hs - a header, a footer and ranks for the tab list
# ==============================================================
#
# Requires: 1.7.3
# Author: HyperScript Team
# Tags: tab list, tablist, header, footer, ranks, server template
#
# The list players see when they hold Tab: your server's name
# on top in changing colours, a line about the server below
# it, the player count, their ping, the TPS and the time
# underneath, and every name with its rank in front.
#
# Notes
#  - Everything to set is in "options:" below: the name, the
#    line under it, the address, the colours, how often it is
#    redrawn, and which parts of the footer are shown. Put
#    false after a "show_" option to take that part out.
#  - "refresh" is how often it is redrawn. "title_speed" is how
#    long each colour of the title stays.
#  - The rank in front of a name is the one Ranks.hs gives
#    with /rank set, shown the way Ranks.hs shows it: the same
#    rank the sidebar and the chat prefixes show. It is kept
#    as {%player%.rank_prefix}. Without Ranks.hs names are
#    written in "no_rank" below, with nothing in front.
#  - Everything is drawn again every "refresh", so a rank given
#    while a player is online shows a moment later, and there
#    is no command to learn.
#  - Minecraft sorts the list by name. A script cannot change
#    the order, only what is written.

options:
    # The name on top, the line under it, and the address at the bottom.
    name: "MY SERVER"
    line: "&7Survival &8| &7Minigames &8| &7Events"
    address: "play.example.com"
    # How often it is redrawn, and how long one colour of the title stays.
    refresh: 10 ticks
    title_speed: 10 ticks
    # The colours of the footer: what a part is called, and its value.
    label: "&f"
    value: "&a"
    # Which parts of the footer are shown, and whether names get their rank.
    show_online: true
    show_ping: true
    show_tps: true
    show_time: false
    show_address: true
    show_ranks: true
    # The colour of a name, and what stands in front of one that has no rank.
    name_colour: "&f"
    no_rank: "&7"

# The title, one colour after the other.
local function title():
    set {_frames} to ["&6&l{@name}", "&e&l{@name}", "&f&l{@name}", "&e&l{@name}"]
    set {_count} to size of {_frames}
    set {_frame} to ({temp.tablist.frame} % {_count}) + 1
    return item {_frame} of {_frames}

# What stands in front of a name: the player's rank, as Ranks.hs shows it.
local function rank():
    if {%player%.rank_prefix} is set:
        set {_shown} to {%player%.rank_prefix}
        return "%{_shown}% {@name_colour}"
    return {@no_rank}

local function header():
    set {_title} to title()
    return "\n%{_title}%\n{@line}\n"

# The footer: one line of numbers with a bar between them, and one with the time and the address.
local function footer():
    set {_parts} to []
    if {@show_online} is true:
        append "{@label}Online: {@value}%server.online_players%&7/%server.max_players%" to {_parts}
    if {@show_ping} is true:
        append "{@label}Ping: &b%player.ping% ms" to {_parts}
    if {@show_tps} is true:
        set {_tps} to round(server.tps)
        append "{@label}TPS: {@value}%{_tps}%" to {_parts}
    set {_last} to []
    if {@show_time} is true:
        set {_time} to now formatted as "HH:mm"
        append "&8%{_time}%" to {_last}
    if {@show_address} is true:
        append "&e{@address}" to {_last}
    set {_first} to join {_parts} with "  &8|  "
    set {_second} to join {_last} with "  "
    return "\n%{_first}%\n%{_second}%\n"

local function show_tab():
    set tab header of player to header()
    set tab footer of player to footer()
    if {@show_ranks} is true:
        set {_rank} to rank()
        set tab name of player to "%{_rank}%%player.name%"

# One step of the title for everybody, so that every tab list changes together.
every {@title_speed}:
    add 1 to {temp.tablist.frame}

every {@refresh} for all players:
    show_tab()

on player join:
    show_tab()