From 2d47962ea1e6e2842eb518f2a2b9a365848ed6d5 Mon Sep 17 00:00:00 2001 From: Michael Burgess Date: Sun, 9 Aug 2026 12:44:33 -0400 Subject: [PATCH] Allow arbitrary MySQL JDBC connection properties in config.yml storage.mysql.properties is now a free-form map merged into the JDBC URL as ?key=value&key=value..., letting hosts that require TLS set things like sslMode: REQUIRED, or override the useSSL/autoReconnect defaults, without needing a code change for every possible parameter. --- README.md | 6 +++++- .../stargate/paper/StargatePlugin.java | 19 ++++++++++++++++++- stargate-paper/src/main/resources/config.yml | 9 +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e581dbc..f2e8b63 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,11 @@ cross-world travel in the original Stargate mod. ## Cross-server (Velocity / Bungee) 1. Set `storage.type: mysql` in every backend server's `config.yml` and point them at - the **same** database — this is how servers see each other's gates. + the **same** database — this is how servers see each other's gates. Add any + connection parameters your host requires (TLS, timezone, etc.) under + `storage.mysql.properties` - each key becomes `?key=value` on the JDBC URL. It + defaults to `useSSL: false` / `autoReconnect: true`; list a key here to override + that default (e.g. `useSSL: true` plus `sslMode: REQUIRED`). 2. Give each backend a unique `server-id` in `config.yml` that matches its name in the proxy config (`velocity.toml` / `config.yml` servers list). 3. Set `cross-server.enabled: true` on every backend. diff --git a/stargate-paper/src/main/java/dev/skywalker3200/stargate/paper/StargatePlugin.java b/stargate-paper/src/main/java/dev/skywalker3200/stargate/paper/StargatePlugin.java index 36057ce..b4ec921 100644 --- a/stargate-paper/src/main/java/dev/skywalker3200/stargate/paper/StargatePlugin.java +++ b/stargate-paper/src/main/java/dev/skywalker3200/stargate/paper/StargatePlugin.java @@ -76,7 +76,24 @@ public class StargatePlugin extends JavaPlugin { String user = getConfig().getString("storage.mysql.username", "stargate"); String pass = getConfig().getString("storage.mysql.password", ""); String prefix = getConfig().getString("storage.mysql.table-prefix", "stargate_"); - String url = "jdbc:mysql://" + host + ":" + port + "/" + db + "?useSSL=false&autoReconnect=true"; + + // Sane defaults, overridable (or removable) via storage.mysql.properties in config.yml - + // e.g. sslMode: REQUIRED, serverTimezone: UTC, useSSL: false, allowPublicKeyRetrieval: true. + java.util.LinkedHashMap params = new java.util.LinkedHashMap<>(); + params.put("useSSL", "false"); + params.put("autoReconnect", "true"); + var propsSection = getConfig().getConfigurationSection("storage.mysql.properties"); + if (propsSection != null) { + for (String key : propsSection.getKeys(false)) { + params.put(key, String.valueOf(propsSection.get(key))); + } + } + StringBuilder query = new StringBuilder(); + for (var entry : params.entrySet()) { + query.append(query.isEmpty() ? '?' : '&'); + query.append(entry.getKey()).append('=').append(entry.getValue()); + } + String url = "jdbc:mysql://" + host + ":" + port + "/" + db + query; return new SqlGateStorage(SqlGateStorage.Driver.MYSQL, url, user, pass, prefix, getLogger()); } File dataFile = new File(getDataFolder(), "gates.db"); diff --git a/stargate-paper/src/main/resources/config.yml b/stargate-paper/src/main/resources/config.yml index 2650ba5..63b2c15 100644 --- a/stargate-paper/src/main/resources/config.yml +++ b/stargate-paper/src/main/resources/config.yml @@ -17,6 +17,15 @@ storage: username: stargate password: "" table-prefix: "stargate_" + # Extra JDBC connection parameters, appended to the URL as ?key=value&key=value. + # Defaults to useSSL: false and autoReconnect: true if you don't set them here - + # any key you list overrides that default (e.g. set useSSL: true and add sslMode + # to actually require TLS). Values are written into the URL as-is. + properties: + # useSSL: true + # sslMode: REQUIRED + # serverTimezone: UTC + # allowPublicKeyRetrieval: true # Enables sending players to another backend server when they dial a gate whose # server-id differs from this one. Requires the stargate-velocity or stargate-bungee