Add H2 database support, use indexes to optimize queries, add maria-specific schema, bump adventure-fabric (#465)

* Add support for H2, bundle Maria driver, bump fabric adventure

* Bundle and download H2 drivers

* Fixup H2 schema, add indexes to DBs, add maria-specific schema

* docs: Add database type documentation

* Check plugin isn't disabled before task schedule, close #463

* Bump Annotaml to 2.0.4

* docs: Mention Maria in README and Setup
This commit is contained in:
William authored and GitHub committed 2023-07-18 15:03:31 +01:00
1 parent 8d2424a7ef
commit beed438c16
28 files changed
+1443 -50

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@
HuskHomes can be used on your Spigot, Sponge or Fabric server, and with a MySQL Database even works cross-server, letting players teleport across your proxy (Bungee or Velocity) network!
## Features
**⭐ Works cross-server** — Let players seamlessly teleport and set homes across your proxies network of servers using MySQL.
**⭐ Works cross-server** — Let players seamlessly teleport and set homes across your proxies network of servers using MySQL/MariaDB.
**⭐ Zero learning curve** — Your players already know how to use it! /sethome, /home, /tpa, /rtp—among others—are all built-in and easy-to-use.
+2
View File
@@ -21,6 +21,7 @@ ext {
set 'jedis_version', jedis_version.toString()
set 'sqlite_driver_version', sqlite_driver_version.toString()
set 'mysql_driver_version', mysql_driver_version.toString()
set 'mariadb_driver_version', mariadb_driver_version.toString()
}
allprojects {
@@ -41,6 +42,7 @@ allprojects {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
mavenContent { snapshotsOnly() }
}
maven { url 'https://repo.william278.net/releases/' }
maven { url 'https://maven.fabricmc.net/' }
maven { url 'https://libraries.minecraft.net/' }
maven { url 'https://api.modrinth.com/maven' }
+1 -1
View File
@@ -10,7 +10,7 @@ dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'org.jetbrains:annotations:24.0.1'
compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
compileOnly 'net.william278:Annotaml:2.0.1'
compileOnly 'net.william278:annotaml:2.0.4'
compileOnly 'net.william278:DesertWell:2.0.4'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
compileOnly 'me.clip:placeholderapi:2.11.3'
@@ -30,6 +30,7 @@ import net.william278.huskhomes.config.Server;
import net.william278.huskhomes.config.Settings;
import net.william278.huskhomes.config.Spawn;
import net.william278.huskhomes.database.Database;
import net.william278.huskhomes.database.H2Database;
import net.william278.huskhomes.database.MySqlDatabase;
import net.william278.huskhomes.database.SqLiteDatabase;
import net.william278.huskhomes.event.BukkitEventDispatcher;
@@ -135,6 +136,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
this.database = switch (getSettings().getDatabaseType()) {
case MYSQL, MARIADB -> new MySqlDatabase(this);
case SQLITE -> new SqLiteDatabase(this);
case H2 -> new H2Database(this);
};
database.initialize();
@@ -48,6 +48,11 @@ public interface BukkitTask extends Task {
@Override
public void run() {
if (isPluginDisabled()) {
runnable.run();
return;
}
if (delayTicks > 0) {
this.task = getScheduler().globalRegionalScheduler().runDelayed(runnable, delayTicks);
} else {
@@ -74,6 +79,11 @@ public interface BukkitTask extends Task {
@Override
public void run() {
if (isPluginDisabled()) {
runnable.run();
return;
}
if (!cancelled) {
this.task = getScheduler().asyncScheduler().run(runnable);
}
@@ -98,6 +108,10 @@ public interface BukkitTask extends Task {
@Override
public void run() {
if (isPluginDisabled()) {
return;
}
if (!cancelled) {
this.task = getScheduler().asyncScheduler().runAtFixedRate(runnable, Duration.ZERO, Duration
.of(repeatingTicks * 50L, ChronoUnit.MILLIS)
@@ -106,6 +120,11 @@ public interface BukkitTask extends Task {
}
}
// Returns if the Bukkit HuskHomes plugin is disabled
default boolean isPluginDisabled() {
return !((BukkitHuskHomes) getPlugin()).isEnabled();
}
interface Supplier extends Task.Supplier {
@NotNull
+2
View File
@@ -15,7 +15,9 @@ softdepend:
libraries:
- 'redis.clients:jedis:${jedis_version}'
- 'com.mysql:mysql-connector-j:${mysql_driver_version}'
- 'org.mariadb.jdbc:mariadb-java-client:${mariadb_driver_version}'
- 'org.xerial:sqlite-jdbc:${sqlite_driver_version}'
- 'com.h2database:h2:${h2_driver_version}'
commands:
home:
+6 -4
View File
@@ -11,7 +11,7 @@ dependencies {
api 'org.apache.commons:commons-text:1.10.0'
api 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
api 'com.google.code.gson:gson:2.10.1'
api 'net.william278:Annotaml:2.0.1'
api 'net.william278:annotaml:2.0.4'
api 'net.william278:PagineDown:1.1'
api 'net.william278:DesertWell:2.0.4'
api 'dev.dejvokep:boosted-yaml:1.3.1'
@@ -20,9 +20,11 @@ dependencies {
exclude module: 'slf4j-api'
}
compileOnly 'redis.clients:jedis:' + jedis_version
compileOnly 'org.xerial:sqlite-jdbc:' + sqlite_driver_version
compileOnly 'com.mysql:mysql-connector-j:' + mysql_driver_version
compileOnly "redis.clients:jedis:$jedis_version"
compileOnly "org.xerial:sqlite-jdbc:$sqlite_driver_version"
compileOnly "com.mysql:mysql-connector-j:$mysql_driver_version"
compileOnly "org.mariadb.jdbc:mariadb-java-client:$mariadb_driver_version"
compileOnly "com.h2database:h2:$h2_driver_version"
compileOnly 'org.jetbrains:annotations:24.0.1'
compileOnly 'com.google.guava:guava:32.1.1-jre'
@@ -55,11 +55,11 @@ public class Settings {
private boolean checkForUpdates = true;
// Database settings
@YamlComment("Type of database to use (SQLITE, MYSQL or MARIADB)")
@YamlComment("Type of database to use (SQLITE, H2, MYSQL or MARIADB)")
@YamlKey("database.type")
private Database.Type databaseType = Database.Type.SQLITE;
@YamlComment("Specify credentials here if you are using MYSQL as your database type")
@YamlComment("Specify credentials here if you are using MYSQL or MARIADB as your database type")
@YamlKey("database.mysql.credentials.host")
private String mySqlHost = "localhost";
@@ -81,7 +81,7 @@ public class Settings {
+ "&useUnicode=true"
+ "&characterEncoding=UTF-8";
@YamlComment("MYSQL database Hikari connection pool properties. "
@YamlComment("MYSQL / MARIADB database Hikari connection pool properties. "
+ "Don't modify this unless you know what you're doing!")
@YamlKey("database.mysql.connection_pool.size")
private int mySqlConnectionPoolSize = 12;
@@ -440,7 +440,8 @@ public abstract class Database {
public enum Type {
MYSQL("MySQL"),
MARIADB("MariaDB"),
SQLITE("SQLite");
SQLITE("SQLite"),
H2("H2");
private final String displayName;
File diff suppressed because it is too large. Load diff
@@ -38,16 +38,18 @@ import java.util.*;
import java.util.logging.Level;
/**
* A MySQL implementation of the plugin {@link Database}.
* A MySQL / MariaDB implementation of the plugin {@link Database}.
*/
@SuppressWarnings("DuplicatedCode")
public class MySqlDatabase extends Database {
private static final String DATA_POOL_NAME = "HuskHomesHikariPool";
private final String flavor;
private HikariDataSource dataSource;
public MySqlDatabase(@NotNull HuskHomes plugin) {
super(plugin);
this.flavor = plugin.getSettings().getDatabaseType() == Type.MARIADB ? "mariadb" : "mysql";
}
/**
@@ -64,15 +66,13 @@ public class MySqlDatabase extends Database {
public void initialize() throws IllegalStateException {
// Initialize the Hikari pooled connection
dataSource = new HikariDataSource();
dataSource.setJdbcUrl("jdbc:" + (plugin.getSettings().getDatabaseType() == Type.MARIADB ? "mariadb" : "mysql")
+ "://"
+ plugin.getSettings().getMySqlHost()
+ ":"
+ plugin.getSettings().getMySqlPort()
+ "/"
+ plugin.getSettings().getMySqlDatabase()
+ plugin.getSettings().getMySqlConnectionParameters()
);
dataSource.setJdbcUrl(String.format("jdbc:%s://%s:%s/%s%s",
flavor,
plugin.getSettings().getMySqlHost(),
plugin.getSettings().getMySqlPort(),
plugin.getSettings().getMySqlDatabase(),
plugin.getSettings().getMySqlConnectionParameters()
));
// Authenticate with the database
dataSource.setUsername(plugin.getSettings().getMySqlUsername());
@@ -108,7 +108,7 @@ public class MySqlDatabase extends Database {
// Prepare database schema; make tables if they don't exist
try (Connection connection = dataSource.getConnection()) {
final String[] databaseSchema = getSchemaStatements("database/mysql_schema.sql");
final String[] databaseSchema = getSchemaStatements(String.format("database/%s_schema.sql", flavor));
try (Statement statement = connection.createStatement()) {
for (String tableCreationStatement : databaseSchema) {
statement.execute(tableCreationStatement);
@@ -81,7 +81,7 @@ public class SqLiteDatabase extends Database {
plugin.log(Level.INFO, "Created the SQLite database file");
}
// Specify use of the JDBC SQLite driver
// Specify use of the JDBC SQLite driver for legacy compatibility
Class.forName("org.sqlite.JDBC");
// Set SQLite database properties
@@ -92,10 +92,11 @@ public class SqLiteDatabase extends Database {
// Establish the connection
connection = DriverManager.getConnection(
"jdbc:sqlite:" + databaseFile.getAbsolutePath(), config.toProperties()
String.format("jdbc:sqlite:%s", databaseFile.getAbsolutePath()),
config.toProperties()
);
} catch (IOException e) {
plugin.log(Level.SEVERE, "An exception occurred creating the database file", e);
plugin.log(Level.SEVERE, "An exception occurred creating the SQLite database file", e);
} catch (SQLException e) {
plugin.log(Level.SEVERE, "An SQL exception occurred initializing the SQLite database", e);
} catch (ClassNotFoundException e) {
@@ -0,0 +1,94 @@
/* Create the positions table if it does not exist */
CREATE TABLE IF NOT EXISTS `%positions_table%`
(
`id` INT NOT NULL AUTO_INCREMENT,
`x` DOUBLE NOT NULL,
`y` DOUBLE NOT NULL,
`z` DOUBLE NOT NULL,
`yaw` REAL NOT NULL,
`pitch` REAL NOT NULL,
`world_name` VARCHAR(255) NOT NULL,
`world_uuid` UUID NOT NULL,
`server_name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
);
/* Create the players table if it does not exist */
CREATE TABLE IF NOT EXISTS `%players_table%`
(
`uuid` UUID NOT NULL PRIMARY KEY,
`username` VARCHAR(16) NOT NULL,
`last_position` INT NULL,
`offline_position` INT NULL,
`respawn_position` INT NULL,
`home_slots` INT NOT NULL DEFAULT 0,
`ignoring_requests` BOOLEAN NOT NULL DEFAULT FALSE,
FOREIGN KEY (`last_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
/* Create the cooldowns table if it does not exist */
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
(
`id` INT NOT NULL AUTO_INCREMENT,
`player_uuid` UUID NOT NULL,
`type` VARCHAR(255) NOT NULL,
`start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_timestamp` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
/* Create the current cross-server teleports table if it does not exist */
CREATE TABLE IF NOT EXISTS `%teleports_table%`
(
`player_uuid` UUID NOT NULL PRIMARY KEY,
`destination_id` INT NOT NULL,
`type` INT NOT NULL DEFAULT 0,
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`destination_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
/* Create the saved positions table if it does not exist */
CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
(
`id` INT NOT NULL AUTO_INCREMENT,
`position_id` INT NOT NULL,
`name` VARCHAR(64) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`tags` CLOB NULL,
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
/* Create the homes table if it does not exist */
CREATE TABLE IF NOT EXISTS `%homes_table%`
(
`uuid` UUID NOT NULL PRIMARY KEY,
`saved_position_id` INT NOT NULL,
`owner_uuid` UUID NOT NULL,
`public` BOOLEAN NOT NULL DEFAULT FALSE,
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
/* Create the warps table if it does not exist */
CREATE TABLE IF NOT EXISTS `%warps_table%`
(
`uuid` UUID NOT NULL PRIMARY KEY,
`saved_position_id` INT NOT NULL,
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
@@ -0,0 +1,118 @@
-- Set the storage engine
SET DEFAULT_STORAGE_ENGINE = InnoDB;
-- Enable foreign key constraints
SET FOREIGN_KEY_CHECKS = 1;
-- Create the positions table if it does not exist
CREATE TABLE IF NOT EXISTS `%positions_table%`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`x` DOUBLE NOT NULL,
`y` DOUBLE NOT NULL,
`z` DOUBLE NOT NULL,
`yaw` FLOAT NOT NULL,
`pitch` FLOAT NOT NULL,
`world_name` VARCHAR(255) NOT NULL,
`world_uuid` CHAR(36) NOT NULL,
`server_name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
-- Create the players table if it does not exist
CREATE TABLE IF NOT EXISTS `%players_table%`
(
`uuid` CHAR(36) NOT NULL,
`username` VARCHAR(16) NOT NULL,
`last_position` INTEGER DEFAULT NULL,
`offline_position` INTEGER DEFAULT NULL,
`respawn_position` INTEGER DEFAULT NULL,
`home_slots` INTEGER NOT NULL DEFAULT 0,
`ignoring_requests` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`uuid`),
FOREIGN KEY (`last_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
-- Create the cooldowns table if it does not exist
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`player_uuid` CHAR(36) NOT NULL,
`type` VARCHAR(255) NOT NULL,
`start_timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_timestamp` DATETIME NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
-- Create the current cross-server teleports table if it does not exist
CREATE TABLE IF NOT EXISTS `%teleports_table%`
(
`player_uuid` CHAR(36) NOT NULL,
`destination_id` INTEGER NOT NULL,
`type` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (`player_uuid`),
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`destination_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
-- Create the saved positions table if it does not exist
CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`position_id` INTEGER NOT NULL,
`name` VARCHAR(64) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`tags` MEDIUMTEXT DEFAULT NULL,
`timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
-- Create the homes table if it does not exist
CREATE TABLE IF NOT EXISTS `%homes_table%`
(
`uuid` CHAR(36) NOT NULL,
`saved_position_id` INTEGER NOT NULL,
`owner_uuid` CHAR(36) NOT NULL,
`public` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`uuid`),
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
-- Create the warps table if it does not exist
CREATE TABLE IF NOT EXISTS `%warps_table%`
(
`uuid` CHAR(36) NOT NULL,
`saved_position_id` INTEGER NOT NULL,
PRIMARY KEY (`uuid`),
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
@@ -30,6 +30,7 @@ CREATE TABLE IF NOT EXISTS `%players_table%`
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
/* Create the cooldowns table if it does not exist */
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
@@ -43,6 +44,7 @@ CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
PRIMARY KEY (`id`),
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
/* Create the current cross-server teleports table if it does not exist */
CREATE TABLE IF NOT EXISTS `%teleports_table%`
@@ -69,6 +71,7 @@ CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
PRIMARY KEY (`id`),
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
/* Create the homes table if it does not exist */
CREATE TABLE IF NOT EXISTS `%homes_table%`
@@ -82,6 +85,7 @@ CREATE TABLE IF NOT EXISTS `%homes_table%`
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
/* Create the warps table if it does not exist */
CREATE TABLE IF NOT EXISTS `%warps_table%`
+3 -3
View File
@@ -24,11 +24,11 @@ language: en-gb
# Whether to automatically check for plugin updates on startup
check_for_updates: true
database:
# Type of database to use (MYSQL, SQLITE)
# Type of database to use (SQLITE, H2, MYSQL or MARIADB)
type: SQLITE
mysql:
credentials:
# Specify credentials here if you are using MYSQL as your database type
# Specify credentials here if you are using MYSQL or MARIADB as your database type
host: localhost
port: 3306
database: HuskHomes
@@ -36,7 +36,7 @@ database:
password: pa55w0rd
parameters: ?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
connection_pool:
# MYSQL database Hikari connection pool properties. Don't modify this unless you know what you're doing!
# MYSQL / MARIADB database Hikari connection pool properties. Don't modify this unless you know what you're doing!
size: 12
idle: 12
lifetime: 1800000
+48
View File
@@ -0,0 +1,48 @@
HuskHomes stores player data, homes, warps, and teleports in a database of your choosing. For cross-server setups, you'll need to configure a MySQL or MariaDB database to allow homes to be accessed globally.
## Database types
> **Warning:** There is currently no automatic way of migrating between _database_ types. Changing the database type will cause data to be lost.
| Type | File or Server | Description | Supports cross-server |
|:----------|----------------|:----------------------------------------------------------------------------|:---------------------:|
| `SQLITE` | File | A file-based database. This is the default (recommended) option. | ❌ |
| `H2` | File | A file-based database, similar to SQLITE, with slightly faster query times. | ❌ |
| `MYSQL` | Server | A database hosted on a MySQL server. | ✅ |
| `MARIADB` | Server | A database hosted on a MariaDB server. | ✅ |
### Cross-server
If you are using HuskHomes on a cross-server network, you will need to use a database type that supports cross-server setups. This is because cross-server setups require a single database to be shared between all servers so that HuskHomes can access the same data on each server.
## Configuring
To change the database type, navigate to your [`config.yml`](Config-Files) file and modify the properties under `database`.
<details>
<summary>Database options (config.yml)</summary>
```yaml
database:
# Type of database to use (SQLITE, H2, MYSQL or MARIADB)
type: SQLITE
mysql:
credentials:
# Specify credentials here if you are using MYSQL or MARIADB as your database type
host: localhost
port: 3306
database: HuskHomes
username: root
password: pa55w0rd
parameters: ?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
connection_pool:
# MYSQL / MARIADB database Hikari connection pool properties. Don't modify this unless you know what you're doing!
size: 12
idle: 12
lifetime: 1800000
keepalive: 30000
timeout: 20000
```
</details>
### Credentials (MariaDB & MySQL)
You will need to specify the credentials (hostname, port, username, password and the database) if you are using MariaDB or MySQL. These credentials are used to connect to your database server.
Additionally, you can modify the HikariCP connection pool properties if you know what you're doing. The default values should be fine for most users.
+1
View File
@@ -10,6 +10,7 @@ Welcome to the plugin documentation for HuskHomes v4.x+, the powerful and intuit
* 📜 [[Command Conflicts]]
## Documentation
* 📁 [[Database]]
* ⛅ [[Redis Support]]
* 📝 [[Translations]]
* 🟩 [[Plan Hook]]
+6 -5
View File
@@ -2,7 +2,7 @@ This will walk you through installing HuskHomes on your Spigot, Fabric or Sponge
## Requirements
* A Spigot (1.16.5+), Fabric (latest Minecraft version), or Sponge (Implementing API v8) _Minecraft: Java Edition_ server running on Java 16+
* (For proxy network support) A proxy server (Velocity, BungeeCord) and MySQL (v8.0+) database
* (For proxy network support) A proxy server (Velocity, BungeeCord) and MySQL (v8.0+)/MariaDB database
* (For optional [[Redis support]]) A Redis database (v5.0+)
## Download HuskHomes for your server
@@ -18,7 +18,7 @@ These instructions are for simply installing HuskHomes on one Spigot, Fabric or
- Place the plugin jar file in the `/plugins/` directory of your Spigot server, or the `/mods` directory of your Fabric/Sponge server.
### 2. Restart the server and configure
- Start, then stop your server to let HuskHomes generate the config file.
- You can now edit the config and locales to your liking.
- You can now edit the [config](Config-Files) and locales to your liking.
### 3. Turn on your server
- Start your server again and enjoy HuskHomes!
@@ -34,9 +34,9 @@ These instructions are for installing HuskHomes on multiple Spigot, Fabric or Sp
- Start, then stop every server to let HuskHomes generate the config file.
- Advanced users: If you'd prefer, you can just create one config.yml file and create symbolic links in each `/plugins/HuskHomes/` (`/config/huskhomes/` on Fabric/Sponge) folder to it to make updating it easier.
### 3. Configure servers to use cross-server mode
- Navigate to the HuskHomes config file on each server (`~/plugins/HuskHomes/config.yml` on Spigot, `~/config/huskhomes/config.yml` on Fabric/Sponge)
- Under `database`, set `type` to `MYSQL`
- Under `mysql`/`credentials`, enter the credentials of your MySQL database server.
- Navigate to the HuskHomes [config](Config-Files) file on each server (`~/plugins/HuskHomes/config.yml` on Spigot, `~/config/huskhomes/config.yml` on Fabric/Sponge)
- Under `database`, set `type` to `MYSQL` or `MARIADB` (depending on which type of database you wish to use)
- Under `mysql`/`credentials`, enter the credentials of your MySQL or MariaDB database server.
- Scroll down and look for the `cross_server` section. Set `enabled` to `true`.
- You can additionally configure a Redis server to use for network messaging, if you prefer (set the `messenger_type` to `REDIS` if you do this).
- Save the config file. Make sure you have updated the file on every server.
@@ -50,5 +50,6 @@ These instructions are for installing HuskHomes on multiple Spigot, Fabric or Sp
## Next steps
* [Commands & Permissions](Commands)
* [[Config Files]]
* [[Database]]
* [[Redis Support]]
* [[Translations]]
+1
View File
@@ -7,6 +7,7 @@
* 📜 [[Command Conflicts]]
## Documentation
* 📁 [[Database]]
* ⛅ [[Redis Support]]
* 📝 [[Translations]]
* 🟩 [[Plan Hook]]
+2
View File
@@ -28,7 +28,9 @@ dependencies {
implementation include("redis.clients:jedis:$jedis_version")
implementation include("org.apache.commons:commons-pool2:$commons_pool_version")
implementation include("com.mysql:mysql-connector-j:$mysql_driver_version")
implementation include("org.mariadb.jdbc:mariadb-java-client:$mariadb_driver_version")
implementation include("org.xerial:sqlite-jdbc:$sqlite_driver_version")
implementation include("com.h2database:h2:$h2_driver_version")
compileOnly 'org.jetbrains:annotations:24.0.1'
@@ -43,6 +43,7 @@ import net.william278.huskhomes.config.Server;
import net.william278.huskhomes.config.Settings;
import net.william278.huskhomes.config.Spawn;
import net.william278.huskhomes.database.Database;
import net.william278.huskhomes.database.H2Database;
import net.william278.huskhomes.database.MySqlDatabase;
import net.william278.huskhomes.database.SqLiteDatabase;
import net.william278.huskhomes.event.FabricEventDispatcher;
@@ -139,17 +140,12 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
// Create adventure audience
this.audiences = FabricServerAudiences.of(minecraftServer);
// Temporarily log about sounds being disabled - todo: Remove when adventure-platform-fabric is updated
if (getSettings().doPlaySoundEffects()) {
log(Level.WARNING, "Sound effects are currently disabled for HuskHomes v" + getVersion()
+ " on Fabric servers running Minecraft " + getMinecraftServer().getVersion());
}
// Initialize the database
initialize(getSettings().getDatabaseType().getDisplayName() + " database connection", (plugin) -> {
this.database = switch (getSettings().getDatabaseType()) {
case MYSQL, MARIADB -> new MySqlDatabase(this);
case SQLITE -> new SqLiteDatabase(this);
case H2 -> new H2Database(this);
};
database.initialize();
@@ -124,11 +124,6 @@ public class FabricUser extends OnlineUser {
return player;
}
@Override
public void playSound(@NotNull String soundEffect) throws IllegalArgumentException {
// Do nothing - todo: Fix sounds when adventure-platform-fabric is updated.
}
@Override
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
final MinecraftServer server = player.getServer();
+4 -2
View File
@@ -3,7 +3,7 @@ javaVersion=16
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true
plugin_version=4.4.3
plugin_version=4.4.4
plugin_archive=huskhomes
plugin_description=The powerful and intuitive homes, warps, and teleports plugin/mod
@@ -11,7 +11,9 @@ plugin_description=The powerful and intuitive homes, warps, and teleports plugin
jedis_version=4.4.2
commons_pool_version=2.11.1
sqlite_driver_version=3.42.0.0
h2_driver_version=2.2.220
mysql_driver_version=8.0.33
mariadb_driver_version=3.1.4
# Fabric settings
fabric_loom_version=1.3-SNAPSHOT
@@ -22,4 +24,4 @@ fabric_yarn_mappings=1.20.1+build.2
fabric_api_version=0.83.1+1.20.1
fabric_permissions_api_version=0.2-SNAPSHOT
adventure_platform_fabric_version=5.9.0-SNAPSHOT
adventure_platform_fabric_version=5.9.0
+1 -1
View File
@@ -11,7 +11,7 @@ dependencies {
compileOnly 'org.bstats:bstats-bukkit:3.0.2'
compileOnly 'org.jetbrains:annotations:24.0.1'
compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
compileOnly 'net.william278:Annotaml:2.0.1'
compileOnly 'net.william278:annotaml:2.0.4'
compileOnly 'net.william278:DesertWell:2.0.4'
compileOnly 'me.lucko:commodore:2.2'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
+3 -1
View File
@@ -2,4 +2,6 @@
libraries:
- 'redis.clients:jedis:${jedis_version}'
- 'com.mysql:mysql-connector-j:${mysql_driver_version}'
- 'org.xerial:sqlite-jdbc:${sqlite_driver_version}'
- 'org.mariadb.jdbc:mariadb-java-client:${mariadb_driver_version}'
- 'org.xerial:sqlite-jdbc:${sqlite_driver_version}'
- 'com.h2database:h2:${h2_driver_version}'
+5 -3
View File
@@ -9,9 +9,11 @@ dependencies {
implementation project(path: ':common')
implementation 'org.bstats:bstats-sponge:3.0.2'
implementation 'redis.clients:jedis:' + jedis_version
implementation 'com.mysql:mysql-connector-j:' + mysql_driver_version
implementation 'org.xerial:sqlite-jdbc:' + sqlite_driver_version
implementation "redis.clients:jedis:$jedis_version"
implementation "com.mysql:mysql-connector-j:$mysql_driver_version"
implementation "org.mariadb.jdbc:mariadb-java-client:$mariadb_driver_version"
implementation "org.xerial:sqlite-jdbc:$sqlite_driver_version"
implementation "com.h2database:h2:$h2_driver_version"
}
sponge {
@@ -29,6 +29,7 @@ import net.william278.huskhomes.config.Server;
import net.william278.huskhomes.config.Settings;
import net.william278.huskhomes.config.Spawn;
import net.william278.huskhomes.database.Database;
import net.william278.huskhomes.database.H2Database;
import net.william278.huskhomes.database.MySqlDatabase;
import net.william278.huskhomes.database.SqLiteDatabase;
import net.william278.huskhomes.event.SpongeEventDispatcher;
@@ -141,6 +142,7 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTask.Supplier, SpongeSa
this.database = switch (getSettings().getDatabaseType()) {
case MYSQL, MARIADB -> new MySqlDatabase(this);
case SQLITE -> new SqLiteDatabase(this);
case H2 -> new H2Database(this);
};
database.initialize();