Skip to content

Adding old world support - #4

Closed
Markle98 wants to merge 2 commits into
HLVM04:masterfrom
Markle98:old_world
Closed

Markle98 wants to merge 2 commits into
HLVM04:masterfrom
Markle98:old_world

Conversation

@Markle98

@Markle98 Markle98 commented Nov 8, 2026

Copy link
Copy Markdown

Old world stats

Adds optional support for showing the stats of a previous world next to the current ones, in both leaderboards and single-player lookups.

If no old world data is configured, the output is identical to the original mod.

What it looks like

--- Most Chest Crafted (Old world) (Page 1) ---
#1 marcel_mrm: 1,824 (3,243)

The value outside the parentheses is the current world, the one inside is the old world.

New optional mode argument

Every /stats <player> ... and /stats top ... command accepts an optional trailing mode, usable before or after the existing [share] flag:

Mode Behaviour
both (default) Current value, old world value in parentheses
current Current world only (original behaviour)
old Old world only, ranked by the old values
total Current + old world added together

Examples:

/stats top custom minecraft:play_time total
/stats top crafted minecraft:chest 2 old
/stats Steve mined minecraft:diamond_ore current

Notes:

  • The leaderboard header shows the active mode: (Old world), (Old world only) or (Total).
  • The [Share] button keeps the selected mode.
  • both falls back to current when there is no old data. old and total return a clear error instead.
  • The help text is updated.

How old data is loaded

  • Put the old world's stats/*.json in config/stats-command/old-world/stats/ (an optional usercache.json can go in old-world/).
  • Files are read once at startup in a background daemon thread and kept in memory, read-only. Commands never read old files from disk, and the existing StatsIndex is untouched.
  • Old stats key minecraft:custom/minecraft:play_one_minute is mapped to the current play_time.

UUID handling (Bedrock / Floodgate and premium players)

The old world used offline UUIDs, while the current world uses the offline UUID derived from the player name (e.g. EasyAuth with forced-offline-uuid). To match players across worlds:

  • Floodgate (00000000-0000-0000-0009-...) and premium (version 4) UUIDs are translated to the offline UUID of the player's name. Names are resolved from the old world's usercache.json, the server's usercache.json, or the server's own profile lookup.
  • Offline UUIDs are kept as they are.
  • Floodgate UUIDs whose name cannot be found are skipped and listed in the log, so nothing is silently misattributed.
  • uuid-map.json ("old uuid": "new uuid or player name") can override any of these by hand.
  • If several old files end up as one player: regular files are summed, files from Floodgate UUIDs only raise the value (they may be copies of the same data).

Duplicate rows fix

The same person can have stats stored under several UUIDs, for example a Floodgate UUID file and its migrated offline copy. Previously this could show a player twice in a leaderboard. All UUIDs are now reduced to the canonical one before building rows, keeping the highest value, so one person is always one row.

Code changes

  • StatsMode (new): the four modes, header labels, and the helper that builds the share command.
  • OldWorldStats (new): loading, UUID translation and in-memory lookup of the old stats.
  • StatsRows (new): pure logic that builds and sorts leaderboard rows per mode. It has no Minecraft dependencies, so it can be tested on its own.
  • StatsCommand: Brigadier tree now registers [share]/[mode] through a common helper, handlers take a StatsMode, and old data is loaded on server start and cleared on stop.
  • README.md: new "Old world stats" section with setup, UUID matching, uuid-map.json, modes and examples.

@Markle98 Markle98 closed this Nov 8, 2026
@Markle98

Markle98 commented Nov 8, 2026

Copy link
Copy Markdown
Author

opened by error, wanted to push to my fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant