Aller au contenu principal

Database

zEssentials uses a relational database to persist all player data, economies, sanctions, vaults, and more. This page covers the available storage backends, the full database schema, performance optimizations, and the migration system.

Storage Backends

zEssentials supports three storage backends. Configure the storage-type option in config.yml to select your backend.

SQLITE

SQLite is the default backend, storing data in a local file at plugins/zEssentials/storage.db. It requires no external database server.

storage-type: SQLITE
attention

SQLite is intended for testing and development only. It has significant limitations compared to MySQL-based backends:

  • No support for LEFT JOIN queries, which disables certain features that rely on cross-table lookups
  • Single-writer concurrency model, which can cause lock contention under load
  • Not suitable for multi-server setups (cannot be shared across servers)

Do not use SQLite in production. Switch to MYSQL or HIKARICP before going live.

MYSQL

Direct MySQL/MariaDB connection. Suitable for small to medium servers that do not require connection pooling.

storage-type: MYSQL

database-configuration:
host: 192.168.10.10
port: 3306
user: homestead
password: secret
database: zessentials
table-prefix: zessentials_
useSSL: false

This backend opens a new database connection for each operation. It works well for servers with moderate player counts but may become a bottleneck under heavy concurrent load.

HIKARICP

HikariCP provides high-performance JDBC connection pooling on top of MySQL/MariaDB. This is the recommended backend for production environments.

storage-type: HIKARICP

database-configuration:
host: 192.168.10.10
port: 3306
user: homestead
password: secret
database: zessentials
table-prefix: zessentials_
useSSL: false

HikariCP maintains a pool of reusable database connections, dramatically reducing connection overhead on high-traffic servers. Benefits include:

  • Connection reuse eliminates the cost of establishing new connections per query
  • Automatic connection health checks and eviction of stale connections
  • Configurable pool sizing to match your server's workload
  • Significantly lower latency for database operations under concurrent access
Recommended

For any server expecting real players, use HIKARICP. It handles concurrent database access far more efficiently than a direct MYSQL connection and is required for optimal performance on networks with multiple servers.

Configuration Reference

PropertyDefault ValueDescription
host192.168.10.10Database server hostname or IP address
port3306Database server port
userhomesteadDatabase username
passwordsecretDatabase password
databasezessentialsDatabase name (must already exist)
table-prefixzessentials_Prefix applied to all table names
useSSLfalseWhether to use SSL for the database connection
attention

Always change the default credentials before deploying to production. The values shown above are placeholders only.

Database Tables

zEssentials creates 22 tables (using the default zessentials_ prefix). Each table is described below with its columns, data types, and purpose.

zessentials_users

Stores core player data. One row per player.

ColumnTypeKeyDescription
unique_idUUIDPKPlayer UUID
nameVARCHARCurrent player name
last_locationVARCHARSerialized last known location
play_timeBIGINTTotal play time in milliseconds
fly_secondsBIGINTRemaining temporary fly time in seconds
frozenBOOLEANWhether the player is currently frozen
ban_sanction_idBIGINTFK to active ban in zessentials_sanctions
mute_sanction_idBIGINTFK to active mute in zessentials_sanctions
voteBIGINTTotal online vote count
vote_offlineBIGINTVotes received while offline
created_atTIMESTAMPAccount first seen
updated_atTIMESTAMPLast data update

zessentials_economies

Stores per-player balances for each economy. Supports multiple currencies.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
economy_nameVARCHARPK (composite)Name of the economy/currency
amountDECIMAL(65,2)Current balance

zessentials_economy_transactions

Logs all economy transactions between players or from the server.

ColumnTypeKeyDescription
from_unique_idUUIDSender player UUID
to_unique_idUUIDReceiver player UUID
economy_nameVARCHAREconomy/currency name
amountDECIMAL(65,2)Transaction amount
from_amountDECIMAL(65,2)Sender balance after transaction
to_amountDECIMAL(65,2)Receiver balance after transaction
reasonVARCHARTransaction reason or description

zessentials_user_homes

Stores player home locations.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
nameVARCHARPK (composite)Home name
locationVARCHARSerialized location (world, x, y, z, yaw, pitch)
materialVARCHARDisplay icon material for GUI

zessentials_sanctions

Stores all sanction records (bans, mutes, kicks) with full history.

ColumnTypeKeyDescription
idBIGINTPK (auto increment)Sanction ID
player_unique_idUUIDSanctioned player UUID
sender_unique_idUUIDStaff member UUID who issued the sanction
sanction_typeVARCHARType of sanction (BAN, MUTE, KICK, etc.)
reasonVARCHARReason for the sanction
durationBIGINTDuration in milliseconds (0 for permanent)
expired_atTIMESTAMPWhen the sanction expires (null for permanent)

zessentials_chat_message

Logs chat messages sent by players.

ColumnTypeKeyDescription
unique_idUUIDPlayer UUID
contentTEXTMessage content
created_atTIMESTAMPWhen the message was sent

zessentials_private_messages

Logs private messages between players.

ColumnTypeKeyDescription
sender_unique_idUUIDSender player UUID
receiver_unique_idUUIDReceiver player UUID
contentTEXTMessage content

zessentials_commands

Logs commands executed by players.

ColumnTypeKeyDescription
unique_idUUIDPlayer UUID
commandTEXTFull command string
created_atTIMESTAMPWhen the command was executed

zessentials_user_mail_boxes

Stores items waiting in a player's mailbox for offline delivery.

ColumnTypeKeyDescription
idBIGINTPK (auto increment)Mailbox entry ID
unique_idUUIDRecipient player UUID
itemstackTEXTSerialized ItemStack data
expired_atTIMESTAMPWhen the mailbox item expires

zessentials_vaults

Stores vault metadata for player storage vaults.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
vault_idINTPK (composite)Vault slot number
nameVARCHARCustom vault name
iconVARCHARDisplay icon material for GUI

zessentials_vault_items

Stores individual items within player vaults.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
vault_idINTPK (composite)Vault slot number
slotINTPK (composite)Item slot within the vault
itemTEXTSerialized ItemStack data
quantityINTItem stack quantity

zessentials_player_slots

Stores unlocked vault slot data per player.

ColumnTypeKeyDescription
unique_idUUIDPKPlayer UUID
slotsINTNumber of unlocked vault slots

zessentials_user_options

Stores per-player boolean option toggles (e.g., toggle chat, toggle PM).

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
option_nameVARCHARPK (composite)Option identifier
option_valueBOOLEANCurrent option state

zessentials_user_cooldowns

Stores per-player cooldown timers for commands and features.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
cooldown_nameVARCHARPK (composite)Cooldown identifier
cooldown_valueBIGINTCooldown expiration timestamp in milliseconds

zessentials_user_play_times

Tracks individual play sessions with connection metadata.

ColumnTypeKeyDescription
unique_idUUIDPlayer UUID
play_timeBIGINTSession duration in milliseconds
addressVARCHARPlayer IP address for the session

zessentials_user_power_tools

Stores power tool bindings that map materials to commands.

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
materialVARCHARPK (composite)Minecraft material name
commandVARCHARCommand to execute on item use

zessentials_steps

Tracks player progression through step-based systems (e.g., quests, tutorials).

ColumnTypeKeyDescription
unique_idUUIDPK (composite)Player UUID
step_nameVARCHARPK (composite)Step identifier
dataJSONArbitrary step data
play_time_startBIGINTPlay time when the step started
play_time_endBIGINTPlay time when the step must end
play_time_betweenBIGINTRequired play time between start and end
finished_atTIMESTAMPWhen the step was completed (null if in progress)

zessentials_vote_sites

Tracks per-player vote timestamps for each voting site.

ColumnTypeKeyDescription
player_idUUIDPK (composite)Player UUID
siteVARCHARPK (composite)Vote site identifier
last_vote_atTIMESTAMPTimestamp of the last vote on this site

Stores verified Discord-to-Minecraft account links.

ColumnTypeKeyDescription
user_idVARCHARPK (composite)Discord user ID
unique_idUUIDPK (composite)Minecraft player UUID
minecraft_nameVARCHARMinecraft player name
discord_nameVARCHARDiscord username

Stores temporary linking codes used during the account linking process.

ColumnTypeKeyDescription
codeVARCHARPK (composite)Temporary linking code
user_idVARCHARPK (composite)Discord user ID
discord_nameVARCHARDiscord username

Audit log of all account link and unlink actions.

ColumnTypeKeyDescription
idBIGINTPK (auto increment)History entry ID
actionVARCHARAction type (LINK, UNLINK, etc.)
discord_idVARCHARDiscord user ID
minecraft_idUUIDMinecraft player UUID
discord_nameVARCHARDiscord username at time of action
minecraft_nameVARCHARMinecraft name at time of action
dataTEXTAdditional action metadata

zessentials_storages

Generic key-value storage for plugin-internal data (e.g., serialized warps, spawn locations).

ColumnTypeKeyDescription
nameVARCHARPKStorage key
contentLONGTEXTSerialized storage value

Performance Optimizations

zEssentials implements several layers of write optimization to minimize database load and ensure responsive gameplay.

Batch Processing (TypeSafeCache)

Player data is not written to the database on every change. Instead, modifications are accumulated in a TypeSafeCache and flushed to the database in batches at a configurable interval.

batch-auto-save: 10 # Flush interval in seconds

The default flush interval is 10 seconds. During each flush cycle, all pending changes across all players are written in a single batch operation. This dramatically reduces the number of database round-trips compared to writing each change individually.

If the server shuts down gracefully, all pending changes are flushed immediately before the connection is closed.

Vault Item Debouncing

When players move items within vaults, rapid slot changes can generate dozens of database writes per second. zEssentials uses a 200ms debounce window backed by a ConcurrentHashMap cache to coalesce rapid vault item updates.

When a vault slot changes, the update is placed into the cache. If the same slot changes again within 200ms, the previous pending write is replaced. Only the final state of each slot is written to the database, eliminating redundant intermediate writes.

Economy Update Debouncing

Economy balance updates use an AtomicReference queue to debounce rapid successive changes to the same player's balance. When multiple economy operations target the same player in quick succession (e.g., rapid shop transactions), only the final balance state is persisted. This prevents write amplification while guaranteeing that the database always reflects the correct final balance.

ExpiringCache for Redis

When running in multi-server mode with Redis, zEssentials uses an ExpiringCache with a 30-second TTL to avoid redundant Redis lookups. Frequently accessed data (such as player balances or online status) is cached locally and only refreshed from Redis when the cache entry expires. This reduces Redis network traffic and query latency while still keeping data reasonably fresh across servers.

Migration System

zEssentials uses a sequential migration system to manage database schema changes across versions. Each migration is numbered and executed in order. The plugin tracks which migrations have already been applied, so only new migrations run on startup.

There are currently 32 sequential migrations that build up the full schema:

  1. Migrations 1-4 -- Create the core tables: users, economies, user_homes, and sanctions
  2. Migrations 5-8 -- Add logging tables: chat_message, private_messages, commands, and economy_transactions
  3. Migrations 9-12 -- Add vault system tables: vaults, vault_items, player_slots, and user_mail_boxes
  4. Migrations 13-16 -- Add player option and cooldown tables: user_options, user_cooldowns, user_play_times, and user_power_tools
  5. Migrations 17-20 -- Add progression and voting tables: steps, vote_sites, and introduce new columns to existing tables
  6. Migrations 21-24 -- Add Discord linking tables: link_accounts, link_codes, link_histories
  7. Migrations 25-28 -- Add storages table and schema refinements (index additions, column type changes)
  8. Migrations 29-32 -- Latest schema adjustments including new columns for votes, fly time, and additional sanction fields

Migrations run automatically on server startup. No manual intervention is required. If you are upgrading from an older version, the plugin will detect the current schema state and apply only the migrations that have not yet been executed.

info

Never manually modify the migration tracking state or skip migrations. Doing so can leave your database in an inconsistent state. If you encounter migration errors, check the server console for details and report the issue on GitHub or Discord.

Copyright © 2026 GroupeZ|Build #loading...|-