Stats & Leaderboards

6commands
3files
2figures
3min read
Sheet 15 of 31 · Playing

Filesplugins/IgniteZombies/leaderboards.yml · holograms.yml · leaderboards.yml

Fileplugins/IgniteZombies/leaderboards.ymlFileholograms.ymlCommand/zombies statsCommand/zombies topSince 1.4.0 every player has a profile that outlives the match. It records five numbers, is saved to SQLite or MySQL, and feeds a cached leaderboard that you can show in chat, in holograms and through PlaceholderAPI.

The five stats

Stat idWhat countsUpdated when
best_roundThe highest wave reached. Also kept per arena in the database.The game ends, or the player leaves a running game.
total_killsEnemies killed by the player.Each kill.
games_playedGames the player was in when they started.The game ends, or the player leaves a running game.
total_revivesDowned teammates brought back, by sneaking or through the Team Machine.Each revive.
playtimeSeconds spent in running games.The game ends, or the player leaves a running game.

Only games that actually started count. Leaving from the lobby or during the countdown records nothing. Stats began counting with 1.4.0; older games were never backfilled.

Commands

CommandWhat it does
/zombies stats [player]Show all five stats for you, or for an online player
/zombies top <stat>Show the top list for one stat
/zadmin leaderboard add <stat>Place a live top list hologram just above your head
/zadmin leaderboard removeRemove the nearest leaderboard hologram within 5 blocks

Command/zombies stats/zombies stats looks players up among those online, so an offline name reports no profile. In chat, playtime is shown as hours and minutes. Holograms and placeholders show it as raw seconds.

/zombies stats in chat.
The /zombies stats output in chat, one line per stat

Leaderboard holograms

Fileplugins/IgniteZombies/leaderboards.ymlLeaderboard holograms are TextDisplays that redraw every time the leaderboard cache refreshes. Their positions are saved in plugins/IgniteZombies/leaderboards.yml, so they come back after a restart. You can place as many as you like, for any stat.

Fileholograms.ymlThe layout is the leaderboard template in holograms.yml. {stat} is the stat's display name and {rows} is the list itself, one line per entry, built from the top-line message. When the list is empty the top-empty message is shown instead.

leaderboard:
  - "<gold><bold>TOP - {stat}</bold></gold>"
  - "{rows}"
A best_round leaderboard hologram.
A best_round leaderboard hologram with the top players listed

Command/zadmin reloadFileleaderboards.yml/zadmin reload removes and respawns every leaderboard hologram from leaderboards.yml, so a reload no longer leaves them missing.

The cache

Leaderboards are never read from the database on demand. A timer reloads the top list for every stat off the main thread, then redraws the holograms.

# config.yml
leaderboards:
  size: 10             # entries per list
  refresh-seconds: 60  # at least 5 seconds

Players with a value of zero are left off the list. A new record can take up to one refresh before it shows.

When profiles are saved

A profile is loaded when the player joins the server and kept in memory while they are online. Changed profiles are written in the background on the auto-save-interval timer (300 seconds by default), when the player quits, and all at once on shutdown. A failed write is retried on the next pass.

Storage

Profiles go to SQLite by default: plugins/IgniteZombies/profiles.db, nothing to set up. For a network that wants shared stats, point every server at the same MySQL database.

# config.yml
database:
  type: SQLITE     # or MYSQL
  host: localhost
  port: 3306
  name: ignite
  user: root
  password: ""

Command/zadmin reloadThe plugin creates two tables, iz_profiles and iz_arena_stats. The connection is picked up at startup, so changing database needs a restart, not /zadmin reload.

Placeholders

PlaceholderReturns
%ignitezombies_stats_<stat>%The viewer's value for a stat, for example %ignitezombies_stats_total_kills%.
%ignitezombies_top_<stat>_<pos>_name%The name at a position, for example %ignitezombies_top_best_round_1_name%.
%ignitezombies_top_<stat>_<pos>_value%The value at that position.

The top_ placeholders need no viewer, so they work in hub scoreboards and hologram plugins. The full list is on PlaceholderAPI.

Loading the index

Enter openUp Down moveEsc close