mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
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:
1 parent
8d2424a7ef
commit
beed438c16
28 files changed
+1443
-50
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user