Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,45 @@ Then add PUUIDs dependency from Github:
```


# MySQL
PUUIDs can mirror everything in its `Data` folder into MySQL (or MariaDB). It's off by default - turn it on under `MySQL` in your `config.yml`:

```yaml
MySQL:
Enabled: true
Host: localhost
Port: 3306
Database: minecraft
Username: root
Password: ''
```

The `.yml` files stay in charge. Every API read still comes off disk, so switching this on can't slow a plugin down or fail because the database is busy - each write is simply copied up in the background as well. That gives you one place to back up or query, and a way to share player data between the servers on a network.

### How it's laid out
Every plugin that stores data gets its own table, so you can look at one plugin's rows on their own (and drop the table when you stop using it):

| Table | What's in it |
| --- | --- |
| `puuids_players` | One row per player: username, IP, last seen, total play time. |
| `puuids_plugins` | Which table belongs to which plugin. |
| `puuids_data_<plugin>` | One row per value that plugin has stored: `uuid`, `path`, `value`. |

Values keep their type on the round trip - an int comes back an int, a list comes back a list, and ItemStacks come back as themselves.

### Commands
| Command | What it does |
| --- | --- |
| `/puuids mysql` | Connection state, queue depth, and anything that has gone wrong. |
| `/puuids mysql export` | Pushes the whole `Data` folder up. Run this the first time you switch MySQL on. |
| `/puuids mysql import confirm` | Pulls everything down, overwriting local values with the database's. |
| `/puuids mysql reconnect` | Retries a connection that was down at start-up. |

### For a network
Set `Sync-On-Join: true` and a player's file is refreshed from the shared database as they join, so their data follows them between servers. A file that has seen them more recently than the database wins, so nothing is lost when they hop back. On a brand new server, `Import-On-Startup: true` builds the folder from the database before anything reads it.

If the database goes away, puuids keeps saving to file and queues the changes; they're sent as soon as it comes back. Your server needs a MySQL or MariaDB JDBC driver on its classpath - most Spigot and Paper builds ship one, and puuids says so in the console if yours doesn't.

# Spigot
PUUIDs is a Spigot plugin for MC versions 1.13-1.21. Please check out the [Spigot Page](https://www.spigotmc.org/resources/puuids-•-an-async-file-api.71496/). for full documentation.

Expand Down
9 changes: 9 additions & 0 deletions src/com/zachduda/puuids/Cooldowns.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ static boolean onTimeCooling(UUID p) {
return active(ontime, p);
}

/**
* Drops a leaving player's /ontime cooldown. Without this the map keeps an entry for every
* player who ever ran the command and never came back.
*/
@SuppressWarnings("SpellCheckingInspection")
static void forgetOnTime(UUID p) {
ontime.remove(p);
}

@SuppressWarnings("SpellCheckingInspection")
static void onTime(UUID p) {
if (!plugin.getConfig().getBoolean("Settings.Cooldowns.On-Time.Enabled", true)) {
Expand Down
Loading
Loading