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
leaderboard
in the config file. -
The defined
leaderboards
will beupdated
if:
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
display
the 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": [
{
"leaderboard_id": "death-board",
"display_name": "<dark_red>Death Board</dark_red>",
"score_provider": "%player:statistic_raw minecraft:deaths%"
},
{
"leaderboard_id": "zombie-kill-board",
"display_name": "<blue>Zombie Kills</blue>",
"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
job
is used to execute/leaderboard update-all
command 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
leaderboards
foronline 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 N
player name of specifiedleaderboard id
.The syntax is
%fuji:lowest_n_name <leaderboard-id> <n> <time-window>
The
time window
can behourly
,daily
,weekly
,monthly
,yearly
andall_time
.For example:
The
%fuji:lowest_n_name death-board 1 all_time%
returnsthe name of the player with the least number of death
from the leaderboard with the iddeath-board
.
-
Placeholder Name:
fuji:highest_n_name
-
Document: Returns the
highest N
player name of specifiedleaderboard id
.The syntax is
%fuji:highest_n_name <leaderboard-id> <n> <time-window>
The
time window
can behourly
,daily
,weekly
,monthly
,yearly
andall_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 kills
from the leaderboard with the idzombie-kill-board
.
-
Placeholder Name:
fuji:lowest_n_score
-
Document: Returns the
lowest N
score of specifiedleaderboard id
.The syntax is
%fuji:lowest_n_score <leaderboard-id> <n> <time-window>
The
time window
can behourly
,daily
,weekly
,monthly
,yearly
andall_time
.For example:
The
%fuji:lowest_n_score death-board 1 all_time%
returns thethe least number of death score
from the leaderboard with the iddeath-board
.
-
Placeholder Name:
fuji:highest_n_score
-
Document: Returns the
highest N
score of specifiedleaderboard id
.The syntax is
%fuji:highest_n_score <leaderboard-id> <n> <time-window>
The
time window
can behourly
,daily
,weekly
,monthly
,yearly
andall_time
.For example:
The
%fuji:highest_n_score zombie-kill-board 1 all_time%
returnsthe highest zombie kill score
from 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]