Skip to content

Commit 9bb0235

Browse files
committed
add some new features
1 parent 5598feb commit 9bb0235

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
+++
2+
title = "Handle a formatted value"
3+
+++
4+
5+
If the output of a `Value Provider` ([`Placeholder`]({{% ref "spigot/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.
6+
7+
```yml
8+
holders:
9+
example-formatted-value-provider:
10+
<your other settings>
11+
formatted: true
12+
formatted-settings: # Optional settings for the formatted value
13+
decimal-separator: "." # Change this to the decimal separator of the formatted value
14+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
+++
2+
title = "Playtime Leaderboard"
3+
+++
4+
5+
This will guide you on how to create an ~unreliable~ playtime leaderboard for your server using the built-in [`Statistic Value Provider`]({{% ref "spigot/provider/statistic" %}}) and format the value using [`Value Display`]({{% ref "spigot/extra/value_display" %}}).
6+
7+
## Add the Holder
8+
9+
Open the `config.yml` file and add the following holder:
10+
11+
```yaml
12+
holders:
13+
playtime:
14+
type: statistic
15+
statistic: PLAY_ONE_MINUTE # Or PLAY_ONE_TICK if your server is running on 1.12 or below
16+
```
17+
18+
This will create a holder named `playtime` that shows the total playtime of a player in ticks.
19+
20+
But the value is in ticks, which is not human-readable. So, we need to format it. Add the following line:
21+
22+
```yaml
23+
holders:
24+
playtime:
25+
type: statistic
26+
statistic: PLAY_ONE_MINUTE
27+
line: "&7[&b{index}&7] &b{name} &7- &b{value;time:pattern=HH:mm:ss&type=duration&unit=ticks}"
28+
```
29+
30+
We added the `line` setting to the holder and override [the default `line`]({{% ref "spigot/extra/default_value" %}}). The `{value;time:pattern=HH:mm:ss&type=duration&unit=ticks}` will format the value to a human-readable time format.
31+
32+
Now when you save and restart the server, you should see the playtime leaderboard in the `/gettop playtime` command.
33+
34+
![Command output](command_output.png)
35+
36+
## Display the Leaderboard
37+
38+
We will [display it in a hologram]({{% ref "spigot/extra/hologram" %}})
39+
40+
Here is an example of a hologram that displays the top 5 players in the leaderboard:
41+
42+
```
43+
&b&lPLAYTIME LEADERBOARD
44+
&7#1 &f%topper_playtime;top_name;1% &7- &b%topper_playtime;top_value;1;time:pattern=HH:mm:ss&type=duration&unit=ticks%
45+
&7#2 &f%topper_playtime;top_name;2% &7- &b%topper_playtime;top_value;2;time:pattern=HH:mm:ss&type=duration&unit=ticks%
46+
&7#3 &f%topper_playtime;top_name;3% &7- &b%topper_playtime;top_value;3;time:pattern=HH:mm:ss&type=duration&unit=ticks%
47+
&7#4 &f%topper_playtime;top_name;4% &7- &b%topper_playtime;top_value;4;time:pattern=HH:mm:ss&type=duration&unit=ticks%
48+
&7#5 &f%topper_playtime;top_name;5% &7- &b%topper_playtime;top_value;5;time:pattern=HH:mm:ss&type=duration&unit=ticks%
49+
```
50+
51+
![hologram](hologram.png)
105 KB
Binary file not shown.
2.27 MB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
+++
2+
title = "Value Display"
3+
+++
4+
5+
Some places like [`{value}` in `line`]({{% ref "spigot/extra/default_value" %}}) and [the `value` and `top_value` queries]({{% ref "spigot/query" %}}) can be expanded to format the value in a more readable way. This is done by specifying some settings for them like:
6+
7+
- `{value_<format>}`
8+
- `<holder>;value;<format>`
9+
- `<holder>;top_value;<position>;<format>`
10+
11+
The following section will guide you through the available formats to replace `<format>`, we will use the `<holder>;value;<format>` query as an example.
12+
13+
## Available Formats
14+
15+
### Decimal Format
16+
17+
> Format: `decimal:setting1=value1&setting2=value2`
18+
19+
| Setting | Description | Default | Example |
20+
| --- | --- | --- | --- |
21+
| `decimalSeparator` | The character used to separate the integer part from the fractional part | `.` | `decimalSeparator=.` |
22+
| `groupingSeparator` | The character used to separate groups of digits to the left of the decimal separator | | `groupingSeparator=,` |
23+
| `groupingSize` | The number of digits in each group to the left of the decimal separator | | `groupingSize=3` |
24+
| `maximumFractionDigits` | The maximum number of digits allowed in the fractional part of the number | | `maximumFractionDigits=2` |
25+
26+
Example: `jump;value;decimal:decimalSeparator=,&groupingSeparator=.&groupingSize=3&maximumFractionDigits=2`
27+
28+
### Time Format
29+
30+
> Format: `time:setting1=value1&setting2=value2`
31+
32+
| Setting | Description | Default | Example |
33+
| --- | --- | --- | --- |
34+
| `pattern` | The pattern describing the date and time format | `HH:mm:ss` | `pattern=HH:mm:ss` |
35+
| `type` | The type of the time: `duration` or `time` | `duration` | `type=duration` |
36+
| `unit` | The unit of the time: `ticks`, `nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days` | `seconds` | `unit=seconds` |
37+
38+
Example: `playtime;value;time:pattern=HH:mm:ss&type=duration&unit=ticks`

0 commit comments

Comments
 (0)