Game dev #8: Stats tracking

My work on updating the Creeper's Lab to Minecraft 1.14 is underway right now. One of the big (bad) surprises I encountered quickly is that our stats-tracking plugin is breaking in the new game version, and there's no clear upgrade path available. The stats tracking is critical to our setup: it's part of the player profiles on the forums, the achievements targets, griefing tracking, and more. There is no easy way out of this one, and this unfortunately isn't the first time this happens either. Here's a recap of all the gameplay stats solutions I've used in the past.

Stats/TNO-Stats Our first stats plugin, selected because it had a wide range of values being tracked, in a simple format, and was easy enough to use. Initially, nothing relied on this, but I integrated it early on so we could record as many gameplay events as possible.

BeardStats Quickly after that initial setup, the first Stats plugin went abandoned. Someone else made a follow-up that was compatible with the same structure, so I migrated to this. The initial version of key features like the achievements were made using this one.

Vanilla When Minecraft 1.8 rolled around, a lot of functionality was rewritten, breaking a lot of compatibility. Unfortunately, BeardStats stopped getting updated around that time, so I had to look for another option. The Mojang team had implemented their own vanilla statistics, tracked server-side and viewable through your game menu. I rewrote everything to support this. However, at the next game update, I realized that Mojang's implementation caused any stat with an ID change (for example, roses becoming poppies) to completely ERASE the old values and start counting anew, which wasn't acceptable for our uses. Another change was needed.

Stats2 At the time, Stats2 was the leading plugin to track player events, so I once again rewrote all my logic to be based on this. A negative effect was that all stats had to be counted from 0, but it seemed like a necessary evil to get a stable base to work with.

Stats3 The author of Stats2 created a new version, Stats3, with a different data structure and better performance. Thankfully, this one properly converted the values already stored to the new format. While I had to do some updates to the processing of achievements to account for the new format, this was a rather smooth change.

IOBattleStats Stats3 didn't count everything I wanted for the sake of some achievements, like the famous “Sailor Scout – Defeat an enemy with the power of Love”. To complement it, I wrote my own plugin, focused on a more detailed tracking of any damage taken or dealt (to both mobs and other players), along with death causes on all sides. This took care of PvP and PvE events, while everything else still relied on Stats3.

And that's where we stood, up until 1.14 showed up. My initial tests revealed that Stats3 was completely incompatible with the new game version, as it was still trying to use numerical item IDs instead of names. Its author stopped updating it, and instead chose to start building Stats5, once again incompatible with the previous versions, and this time with no data converter available. That'd have meant restarting counting the values from 0 all over again, and that's where I decided to draw the line. No more!

I figured that, if everyone on this front is going to let me down every few years, I might as well do it myself, so that's what I'm doing now. IOBattleStats is being expanded on to track all relevant gameplay values, from block breaking to minecart distance passing by portal uses. I'll also write a converter from Stats3 to IOBattleStats' own data format, so that everyone working toward specific achievements don't need to restart from zero. Then, everything based on these stats (see above: player profiles, achievements, griefing tracking) will be updated to the new data format, and this time should finally be the one.

This takes more time to do upfront, but will save me from having to rewrite significant parts of the existing systems every year or two, so I see it as very much worthwhile!

#gamedev #projects #plugins

– Doctacosa