You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plasmid/statistics.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,44 +1,44 @@
1
1
# Implementing statistics
2
2
3
3
!!! warning
4
-
The final statistics API is only available on 0.5 for 1.17, as some things have changed since the initial implementation in plasmid 0.4
4
+
The final statistics API is only available on Plasmid 0.5 for 1.17 and higher, as some things have changed since the initial implementation in Plasmid 0.4
5
5
6
6
Plasmid provides an API for allowing minigames to record statistics for their players, and can be implemented to allow leaderboards to be generated for games (soon™).
7
7
8
8
## Before you begin
9
-
This guide assumes that you have a minigame already implemented and want to add support for tracking statistics. If you simply would like to create a minigame, see the [Getting Started guide](/plasmid/01_getting_started).
9
+
This guide assumes that you have a minigame already implemented and want to add support for tracking statistics. If you simply would like to create a minigame, see the [Getting Started guide](/plasmid/getting-started/).
10
10
11
-
It also expects that you are on the latest version of plasmid 0.5 with statistics support.
11
+
It also expects that you are on the latest version of Plasmid 0.5 with statistics support.
12
12
13
13
## Bundles of fun
14
14
(Well it might not seem fun, but its the first step for implementing statistics into your game.)
15
15
16
-
The first step for implementing statistics is getting your hands on a `GameStatisticsBundle`, which is a class provided by plasmid that holds per-player and global statistics for your current game. You can do this quite easily within the constructor of your `GameActive` class like this:
16
+
The first step for implementing statistics is getting your hands on a `GameStatisticBundle`, which is a class provided by plasmid that holds per-player and global statistics for your current game. You can do this quite easily within the constructor of your `GameActive` class like this:
17
17
```java
18
18
publicclassMyGameActive {
19
19
/* other fields */
20
-
publicfinalGameStatisticsBundle statistics;
20
+
publicfinalGameStatisticBundle statistics;
21
21
22
22
privateMyGameActive(GameSpacegameSpace, /* other parameters */) {
23
23
/* other initialization logic */
24
24
25
25
// The value passed to getStatistics should usually be the ID of your minigame/mod
You also need to provide a translation for the name of your bundle, with the translation key in the form `statistic.bundle.<namespace>`. This `namespace` is whatever you passed into `gameSpace.getStatistics()`, so double check it matches.
33
+
You also need to provide a translation for the name of your bundle, with the translation key in the form `statistic.bundle.<namespace>`. This `namespace` is whatever you passed into `gameSpace.getStatistics().bundle()`, so double check it matches.
34
34
35
35
## Getting some keys
36
36
Time to get implementi- Oh, we still need to do something else first :/
37
37
38
38
Once you have a `GameStatisticsBundle`, the next step is to actually increment some statistics, and this is where the specifics can become different between games, as every game is somewhat unique.
39
39
40
40
!!! note "What are StatisticKeys?"
41
-
`StatisticKey`s are a type-safe identifier for a specific statistic, and internally store both an `Identifier` and a `StorageType`.
41
+
`StatisticKey`s are a type-safe identifier for a specific statistic, and internally store both an `Identifier`.
42
42
43
43
### Standard keys
44
44
Plasmid provides several built in `StatisticKey`s in a conveniently named `StatisticKeys` class. Here are some examples:
@@ -54,7 +54,7 @@ You can create your own `StatisticKey`s and store them in `public static final`
@@ -85,7 +85,7 @@ The final step is to scatter these increments around your minigame and collect s
85
85
## Finished!
86
86
And then that's it, your minigame now has statistics support 🎉!
87
87
88
-
If you need a hand implementing or don't understand something, feel free to [join the Discord](https://nucleoid.xyz/discord/) and speak to me (@Tom_The_Geek#8559) in `#minigame-dev`.
88
+
If you need a hand implementing or don't understand something, feel free to [join the Discord](https://nucleoid.xyz/discord/) and ask in `#minigame-dev`.
89
89
90
90
## Extra: debugging
91
-
If you want to doublecheck that your statistics are being counted correctly, you can add `-Dplasmid.debug_statistics=true` to your JVM arguments and plasmid will print out a JSON formatted version of all `GameStatisticBundle`s at the end of any game.
91
+
If you want to double-check that your statistics are being counted correctly, you can add `-Dplasmid.debug_statistics=true` to your JVM arguments and plasmid will print out a JSON formatted version of all `GameStatisticBundle`s at the end of any game.
0 commit comments