Chapter 7

Extra

Extra tutorials for common features and tasks.

Note

Parts of the tutorials in this section assume that you’ve done the Quick Start. If there is anything you don’t understand from the tutorials, you may want to go back and do the Quick Start.

Subsections of Extra

Change default values

You can change the default values, returned by some queries and commands, by adding some settings to your holder settings.

holders:
  jump:
    <your other settings>
    null-name: "---" # Default value for the name
    null-uuid: "---" # Default value for the uuid
    null-value: "---" # Default value for the value
    line: "&7[&b{index}&7] &b{name} &7- &b{value}" # Default format for the top line in the top list

Create a Hologram

Note

Requires PlaceholderAPI and a hologram plugin that supports PlaceholderAPI such as DecentHolograms

You can use the top_name and top_value placeholders to display players in the leaderboard.

Here is an example of a hologram that displays the top 5 players in the leaderboard:

&b&lJUMP LEADERBOARD
&7#1 &f%topper_jump;top_name;1% &7- &b%topper_jump;top_value;1%
&7#2 &f%topper_jump;top_name;2% &7- &b%topper_jump;top_value;2%
&7#3 &f%topper_jump;top_name;3% &7- &b%topper_jump;top_value;3%
&7#4 &f%topper_jump;top_name;4% &7- &b%topper_jump;top_value;4%
&7#5 &f%topper_jump;top_name;5% &7- &b%topper_jump;top_value;5%

hologram hologram

Create a Top Block

Note

Create a Top Skull

  1. Prepare a skull template named jump_skull that returns the UUID of the player at the specific {index} of the jump leaderboard
/varblocks template add jump_skull %topper_jump;top_key;{index}%
  1. Place the skull skull1 skull1

  2. While looking at the skull, run the following command to assign the jump_skull template to the skull

/varblocks block add jump_1 skull jump_skull
  1. Set the {index} of the skull to 1 to display the top player
/varblocks block argument jump_1 index 1
  1. Create another skull for the second player
/varblocks block add jump_2 skull jump_skull
/varblocks block argument jump_2 index 2

skull2 skull2

Create a Top Sign

  1. Prepare a sign template named jump_sign that displays the player’s name and value at the specific {index} of the jump leaderboard
/varblocks template add jump_sign
/varblocks template add jump_sign &6#{index}&7: &f%topper_jump;top_name;{index}%
/varblocks template add jump_sign &e%topper_jump;top_value;{index}%
/varblocks template add jump_sign
  1. Place the sign sign1 sign1

  2. While looking at the sign, run the following command to assign the jump_sign template to the sign

/varblocks block add jump_sign_1 sign jump_sign
  1. Set the {index} of the sign to 1 to display the top player
/varblocks block argument jump_sign_1 index 1
  1. Create another sign for the second player
/varblocks block add jump_sign_2 sign jump_sign
/varblocks block argument jump_sign_2 index 2

sign2 sign2

Create an NPC

Note
  1. Create a player NPC
/npc create %topper_jump;top_name;1%
  1. Set the skin of the NPC
/npc skin %topper_jump;top_name;1%

The NPC will display the skin of the top player of the jump leaderboard.

Handle a formatted value

If the output of a Value Provider (Placeholder for example) is a formatted value and you are confident that you can get the raw value from it with a simple method of taking only numbers and the decimal separator, you can enable the formatted option in your Holder Setting.

holders:
  example-formatted-value-provider:
    <your other settings>
    formatted: true
    formatted-settings: # Optional settings for the formatted value
      decimal-separator: "." # Change this to the decimal separator of the formatted value

Ignore Permission

You can specify a set of permissions so that the Holder will skip updating the value of the player if they have one of the permissions.

holders:
  jump:
    <your other settings>
    ignore-permission: exclude.permission
Note

In some Value Providers like Placeholder, you may need to ensure that it would take the value of online players only (For example, by setting online to true in Placeholder Value Provider)

Migrate from 2.X

  1. Download and install Topper 3.0.0 here
  2. Install VarBlocks if you use Top Signs or Top Skulls here
  3. Run the server and let Topper convert your data
  4. You’re done! Enjoy the new features of Topper 3.0.0!

Playtime Leaderboard

This will guide you on how to create an unreliable playtime leaderboard for your server using the built-in Statistic Value Provider and format the value using Value Display.

Add the Holder

Open the config.yml file and add the following holder:

holders:
  playtime:
    type: statistic
    statistic: PLAY_ONE_MINUTE # Or PLAY_ONE_TICK if your server is running on 1.12 or below

This will create a holder named playtime that shows the total playtime of a player in ticks.

But the value is in ticks, which is not human-readable. So, we need to format it. Add the following line:

holders:
  playtime:
    type: statistic
    statistic: PLAY_ONE_MINUTE
    line: "&7[&b{index}&7] &b{name} &7- &b{value_time:pattern=HH:mm:ss&type=duration&unit=ticks}"

We added the line setting to the holder and override the default line. The {value_time:pattern=HH:mm:ss&type=duration&unit=ticks} will format the value to a human-readable time format.

Now when you save and restart the server, you should see the playtime leaderboard in the /gettop playtime command.

Command output Command output

Display the Leaderboard

We will display it in a hologram

Here is an example of a hologram that displays the top 5 players in the leaderboard:

&b&lPLAYTIME LEADERBOARD
&7#1 &f%topper_playtime;top_name;1% &7- &b%topper_playtime;top_value;1;time:pattern=HH:mm:ss&type=duration&unit=ticks%
&7#2 &f%topper_playtime;top_name;2% &7- &b%topper_playtime;top_value;2;time:pattern=HH:mm:ss&type=duration&unit=ticks%
&7#3 &f%topper_playtime;top_name;3% &7- &b%topper_playtime;top_value;3;time:pattern=HH:mm:ss&type=duration&unit=ticks%
&7#4 &f%topper_playtime;top_name;4% &7- &b%topper_playtime;top_value;4;time:pattern=HH:mm:ss&type=duration&unit=ticks%
&7#5 &f%topper_playtime;top_name;5% &7- &b%topper_playtime;top_value;5;time:pattern=HH:mm:ss&type=duration&unit=ticks%

hologram hologram

Reversed Leaderboard

By default, the top leaderboard is measured by the player with the highest value first. If you want to change that (e.g. show the player with the least value first), you can set reverse to true.

holders:
  jump:
    <your other settings>
    reverse: true

Value Display

Some places like {value} in line and the value and top_value queries can be expanded to format the value in a more readable way. This is done by specifying some settings for them like:

  • {value_<format>}
  • <holder>;value;<format>
  • <holder>;top_value;<position>;<format>

The following section will guide you through the available formats to replace <format>, we will use the <holder>;value;<format> query as an example.

Available Formats

Decimal Format

Format: decimal:setting1=value1&setting2=value2

SettingDescriptionDefaultExample
decimalSeparatorThe character used to separate the integer part from the fractional part.decimalSeparator=.
groupingSeparatorThe character used to separate groups of digits to the left of the decimal separatorgroupingSeparator=,
groupingSizeThe number of digits in each group to the left of the decimal separatorgroupingSize=3
maximumFractionDigitsThe maximum number of digits allowed in the fractional part of the numbermaximumFractionDigits=2

Example: jump;value;decimal:decimalSeparator=,&groupingSeparator=.&groupingSize=3&maximumFractionDigits=2

Time Format

Format: time:setting1=value1&setting2=value2

SettingDescriptionDefaultExample
patternThe pattern describing the date and time formatHH:mm:sspattern=HH:mm:ss
typeThe type of the time: duration or timedurationtype=duration
unitThe unit of the time: ticks, nanoseconds, microseconds, milliseconds, seconds, minutes, hours, dayssecondsunit=seconds

Example: playtime;value;time:pattern=HH:mm:ss&type=duration&unit=ticks