Module: leaderboard
Overview
This module defining a leaderboard.
The score provider of a leaderboard can be a placeholder, statistics or objective.
The time window of a leaderboard can be hourly, daily, weekly, monthly, yearly and all_time.
You can display the leaderboard using placeholders or commands.
Color Boxes
◉ How it works?
-
You need to define a
leaderboardin the config file. -
The defined
leaderboardswill beupdatedif:
2.a. All leaderboards will be updated when a player joins or leaves the server.
2.b. All leaderboards will be updated when the Leaderboard Updater Job is fired.
2.c. You can use /leaderboard update-all command to update manually.
- You can
displaythe leaderboard in various ways.
3.a. You can use placeholders to display the leaderboard.
3.b. You can use commands to display the leaderboard.
◉ You can use a placeholder to fetch data from statistics.
For example:
-
%player:statistic_raw minecraft:deaths% -
%player:statistic_raw minecraft:killed minecraft:zombie%
See more statistics in: https://minecraft.wiki/w/Statistics
◉ You can use a placeholder to fetch data from objective.
For example: %player:objective [objective]%
◉ How to define a leaderboard?
To define a leaderboard, you need to specify:
-
Leaderboard ID: The unique name for this leaderboard. -
Score Provider: It's a string which evaluates to anumeric value. (Typically aplaceholder)
◉ What is the lowest N and highest N.
For any leaderboard, all its scores are sorted in natural order.
The natural order is the order that from lowest to highest. (e.g. 0, 1, 2, 3 ...)
You can use a lowest placeholder to select the lowest N score.
You can use a highest placeholder to select the highest N score.
For example, you may want to select the lowest score for death-board, and highest score for zombie-kill-board.
-
%fuji:lowest_n_score death-board 1 all_time% -
%fuji:highest_n_score zombie-kill-board 1 all_time%
◉ List the specified leaderboard with lowest first order.
Issue: /leaderboard lowest death-board ALL_TIME
◉ List the specified leaderboard with highest first order.
Issue: /leaderboard highest zombie-kill-board ALL_TIME
◉ List the specified leaderboard with highest first order and daily time window.
Issue: /leaderboard highest zombie-kill-board DAILY
◉ Award the top player.
Issue:
-
/run as console send-broadcast The greatest zombie killer this week is %fuji:highest_n_name zombie-kill-board 1 weekly% -
/run as console give %fuji:highest_n_name zombie-kill-board 1 weekly% minecraft:diamond 1
Configurations
The following JSON content is provided for reference only. It must NOT be copied directly into the configuration directory, as it does not represent valid JSON syntax.
- File Name:
config.json - File Content:
Click to see the default content...
{
/* The `text` to display when there is no data for specified `lowest N` or `highest N` player. */
"leaderboard_no_player_text": "<red>None Player"
/* The `text` to display when there is no data for specified `score`. */,
"leaderboard_no_score_text": "<yellow>---"
/* The beginning of the week used for `weekly` time window. */,
"beginning_of_the_week": "SUNDAY"
/* The `default page size` for `/leaderboard lowest` and `/leaderboard highest` commands. */,
"page_size": 10
/* A `leaderboard descriptor` is used to define a `leaderboard`. */,
"leaderboard_descriptors": [
{
/* The `unique` id for this `leaderboard`. */
"leaderboard_id": "death-board",
"display_name": "<dark_red>Death Board</dark_red>"
/* This option is a `string` which will be evaluated to a `numeric value`.
The `string` value is typically a `placeholder`. */,
"score_provider": "%player:statistic_raw minecraft:deaths%"
},
{
/* The `unique` id for this `leaderboard`. */
"leaderboard_id": "zombie-kill-board",
"display_name": "<blue>Zombie Kills</blue>"
/* This option is a `string` which will be evaluated to a `numeric value`.
The `string` value is typically a `placeholder`. */,
"score_provider": "%player:statistic_raw minecraft:killed minecraft:zombie%"
}
]
}
- File Name:
leaderboard-data.json - File Content:
Click to see the default content...
{
"leaderboard_data": []
}
Jobs
- Job Name:
UpdateLeaderboardsJob - Document: This
jobis used to execute/leaderboard update-allcommand automatically.
Commands
-
Command Syntax:
/leaderboard highest <LeaderBoardDescriptor leaderboard> <LeaderBoardTimeWindow timeWindow> [Integer pageSize] -
Document: List the highest N players for specified leaderboard.
-
Can be executed by console:
false -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/leaderboard lowest <LeaderBoardDescriptor leaderboard> <LeaderBoardTimeWindow timeWindow> [Integer pageSize] -
Document: List the lowest N players for specified leaderboard.
-
Can be executed by console:
false -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/leaderboard update-all -
Document: Update all
leaderboardsforonline players. -
Can be executed by console:
true -
Required Level Permission:
4 -
Required String Permission:
null
Placeholders
-
Placeholder Name:
fuji:lowest_n_name -
Document: Returns the
lowest Nplayer name of specifiedleaderboard id.The syntax is
%fuji:lowest_n_name <leaderboard-id> <n> <time-window>The
time windowcan behourly,daily,weekly,monthly,yearlyandall_time.For example:
The
%fuji:lowest_n_name death-board 1 all_time%returnsthe name of the player with the least number of deathfrom the leaderboard with the iddeath-board.
-
Placeholder Name:
fuji:highest_n_name -
Document: Returns the
highest Nplayer name of specifiedleaderboard id.The syntax is
%fuji:highest_n_name <leaderboard-id> <n> <time-window>The
time windowcan behourly,daily,weekly,monthly,yearlyandall_time.For example:
The
%fuji:highest_n_name zombie-kill-board 1 all_time%returnsthe name of the player with the highest number of zombie killsfrom the leaderboard with the idzombie-kill-board.
-
Placeholder Name:
fuji:lowest_n_score -
Document: Returns the
lowest Nscore of specifiedleaderboard id.The syntax is
%fuji:lowest_n_score <leaderboard-id> <n> <time-window>The
time windowcan behourly,daily,weekly,monthly,yearlyandall_time.For example:
The
%fuji:lowest_n_score death-board 1 all_time%returns thethe least number of death scorefrom the leaderboard with the iddeath-board.
-
Placeholder Name:
fuji:highest_n_score -
Document: Returns the
highest Nscore of specifiedleaderboard id.The syntax is
%fuji:highest_n_score <leaderboard-id> <n> <time-window>The
time windowcan behourly,daily,weekly,monthly,yearlyandall_time.For example:
The
%fuji:highest_n_score zombie-kill-board 1 all_time%returnsthe highest zombie kill scorefrom the leaderboard with the idzombie-kill-board.
Argument Types
- Argument Type Name:
[leaderboard] - Argument Type Class:
[LeaderBoardDescriptor]
- Argument Type Name:
[leaderboard-time-window] - Argument Type Class:
[LeaderBoardTimeWindow]