Skip to content

mySQL Integration - #39

Merged
zachduda merged 2 commits into
masterfrom
claude/minecraft-plugin-mysql-integration-j8bwpb
Sep 5, 2026
Merged

mySQL Integration#39
zachduda merged 2 commits into
masterfrom
claude/minecraft-plugin-mysql-integration-j8bwpb

Conversation

@zachduda

@zachduda zachduda commented Sep 5, 2026

Copy link
Copy Markdown
Owner

No description provided.

Player data can now be mirrored into MySQL (or MariaDB) as well as saved to
file, switched on under MySQL in the config.yml. The .yml files stay the
source of truth: every API read still comes off disk, so turning this on
can't slow a get down or fail because the database is busy. Each write is
copied up afterwards from a single background thread instead.

One table per plugin, which is what makes the layout legible from outside:

  puuids_players       one row per player - name, IP, last on, play time
  puuids_plugins       which table belongs to which plugin
  puuids_data_<plugin> one row per stored value: uuid, path, value

Values are stored as a one-key YAML document, so types survive the round
trip - an int stays an int, a list stays a list, and ItemStacks come back as
themselves.

Writes are queued and coalesced before they are sent, so a player earning
points ten times in a flush window is one row rather than ten statements,
and what is left goes out in JDBC batches. If the database disappears the
changes wait in memory and drain when it returns; only a queue past
Max-Queued-Writes drops anything, and the files are still intact to export
from. Clearing a value removes its nested children too, with LIKE patterns
escaped so a path containing an underscore can't take a sibling's rows with
it.

Also adds /puuids mysql for status, export (push the folder up), import
(pull it down, behind a confirm) and reconnect, plus Import-On-Startup,
Export-On-Startup and Sync-On-Join for network setups - a join refresh keeps
whichever record is newer, so a player hopping back doesn't lose time.

Fixes found while reading through the rest:

- The server id was written to a top-level UUID key but read back from
  Advanced.UUID, so getServerId() always answered "0" and a new id was
  generated on every start-up.
- Settings.File-Cleanup.Max-Days was read without a default, so a missing or
  mistyped key meant 0 days - deleting every data file on the next start.
- Allow-Unsafe-Reloads was only ever set to true, so turning it back off and
  reloading left unsafe reloads permitted until the next restart.
- A file created by plugin data alone had no UUID key, which the start-up
  scan then treated as corrupt and deleted.
- Leftover .tmp files from an interrupted save were reported as unknown
  files and left in place; they are cleaned up now.
- The connected-plugins list named the last plugin twice and left a trailing
  separator.
- /ontime cooldowns were never dropped for players who left.
- plugin.yml carried a hardcoded 4.0.0 against a 4.0.1 pom, which the update
  checker then read as being out of date; it uses ${project.version} now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LCicgjWrvrV7ffqrZi7VLS
/puuids reset writes files directly rather than going through the save
queue, so the mirror never saw it: the database kept the play time and
plugin data that had just been erased, and Import-On-Startup or Sync-On-Join
would have handed all of it straight back.

"reset ontime" now mirrors the zeroed play time as it goes, and "reset all"
clears the same players out of every plugin table - after flushing whatever
was still queued for them, so nothing lands behind the delete. Both also
save through the same atomic write the rest of the plugin uses, instead of
config.save() with an empty catch block that hid the failure.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LCicgjWrvrV7ffqrZi7VLS
@zachduda
zachduda merged commit bd84e8d into master Sep 5, 2026
5 of 6 checks passed
@zachduda
zachduda deleted the claude/minecraft-plugin-mysql-integration-j8bwpb branch September 5, 2026 16:57
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.

2 participants