Skip to content

Commit 58ffa29

Browse files
authored
Merge pull request #9 from Hugman76/stats-fixes
Update statistics documentation
2 parents c0e674e + 8dc7db2 commit 58ffa29

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/plasmid/statistics.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
# Implementing statistics
22

33
!!! 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
55

66
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™).
77

88
## 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/).
1010

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.
1212

1313
## Bundles of fun
1414
(Well it might not seem fun, but its the first step for implementing statistics into your game.)
1515

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:
1717
```java
1818
public class MyGameActive {
1919
/* other fields */
20-
public final GameStatisticsBundle statistics;
20+
public final GameStatisticBundle statistics;
2121

2222
private MyGameActive(GameSpace gameSpace, /* other parameters */) {
2323
/* other initialization logic */
2424

2525
// The value passed to getStatistics should usually be the ID of your minigame/mod
26-
this.statistics = gameSpace.getStatistics(MyGame.ID);
26+
this.statistics = gameSpace.getStatistics().bundle(MyGame.ID);
2727
}
2828

2929
/* other game logic */
3030
}
3131
```
3232

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()`, 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.
3434

3535
## Getting some keys
3636
Time to get implementi- Oh, we still need to do something else first :/
3737

3838
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.
3939

4040
!!! 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`.
4242

4343
### Standard keys
4444
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`
5454
public class MyGameStatistics {
5555
public static final StatisticKey<Integer> SOME_COOL_STAT =
5656
// or StatisticKey.doubleKey or StatisticKey.floatKey
57-
StatisticKey.intKey(new Identifier(MyGame.ID, "some_cool_stat"), StatisticKey.StorageType.TOTAL);
57+
StatisticKey.intKey(new Identifier(MyGame.ID, "some_cool_stat"));
5858
}
5959
```
6060

@@ -85,7 +85,7 @@ The final step is to scatter these increments around your minigame and collect s
8585
## Finished!
8686
And then that's it, your minigame now has statistics support 🎉!
8787

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`.
8989

9090
## Extra: debugging
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.
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

Comments
 (0)