diff --git a/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java b/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java index 13818a26c..35ba91c1b 100644 --- a/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java +++ b/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java @@ -129,11 +129,11 @@ public class SIsland implements Island { private static final SuperiorSkyblockPlugin plugin = SuperiorSkyblockPlugin.getPlugin(); private static int blocksUpdateCounter = 0; - private final DatabaseBridge databaseBridge = plugin.getFactory().createDatabaseBridge(this); - private final IslandBank islandBank = plugin.getFactory().createIslandBank(this, this::hasGiveInterestFailed); - private final IslandCalculationAlgorithm calculationAlgorithm = plugin.getFactory().createIslandCalculationAlgorithm(this); - private final IslandBlocksTrackerAlgorithm blocksTracker = plugin.getFactory().createIslandBlocksTrackerAlgorithm(this); - private final IslandEntitiesTrackerAlgorithm entitiesTracker = plugin.getFactory().createIslandEntitiesTrackerAlgorithm(this); + private final DatabaseBridge databaseBridge; + private final IslandBank islandBank; + private final IslandCalculationAlgorithm calculationAlgorithm; + private final IslandBlocksTrackerAlgorithm blocksTracker; + private final IslandEntitiesTrackerAlgorithm entitiesTracker; private final Synchronized bankInterestTask = Synchronized.of(null); @Nullable private PersistentDataContainer persistentDataContainer; @@ -252,6 +252,12 @@ private SIsland(@Nullable SuperiorPlayer owner, UUID uuid, Location location, St this.islandName = islandName; this.islandRawName = Formatters.STRIP_COLOR_FORMATTER.format(islandName); this.schemName = schemName; + + this.databaseBridge = plugin.getFactory().createDatabaseBridge(this); + this.islandBank = plugin.getFactory().createIslandBank(this, this::hasGiveInterestFailed); + this.calculationAlgorithm = plugin.getFactory().createIslandCalculationAlgorithm(this); + this.blocksTracker = plugin.getFactory().createIslandBlocksTrackerAlgorithm(this); + this.entitiesTracker = plugin.getFactory().createIslandEntitiesTrackerAlgorithm(this); } public static Optional fromDatabase(DatabaseCache cache, DatabaseResult resultSet) { diff --git a/src/main/java/com/bgsoftware/superiorskyblock/player/SSuperiorPlayer.java b/src/main/java/com/bgsoftware/superiorskyblock/player/SSuperiorPlayer.java index c55e97a96..88b05f06e 100644 --- a/src/main/java/com/bgsoftware/superiorskyblock/player/SSuperiorPlayer.java +++ b/src/main/java/com/bgsoftware/superiorskyblock/player/SSuperiorPlayer.java @@ -51,8 +51,8 @@ public class SSuperiorPlayer implements SuperiorPlayer { private static final SuperiorSkyblockPlugin plugin = SuperiorSkyblockPlugin.getPlugin(); - private final DatabaseBridge databaseBridge = plugin.getFactory().createDatabaseBridge(this); - private final PlayerTeleportAlgorithm playerTeleportAlgorithm = plugin.getFactory().createPlayerTeleportAlgorithm(this); + private final DatabaseBridge databaseBridge; + private final PlayerTeleportAlgorithm playerTeleportAlgorithm; @Nullable private PersistentDataContainer persistentDataContainer; // Lazy loading @@ -104,6 +104,10 @@ public SSuperiorPlayer(UUID uuid, @Nullable String name, PlayerRole playerRole, this.playerRole = playerRole; this.disbands = disbands; this.userLocale = userLocale; + + this.databaseBridge = plugin.getFactory().createDatabaseBridge(this); + this.playerTeleportAlgorithm = plugin.getFactory().createPlayerTeleportAlgorithm(this); + databaseBridge.setDatabaseBridgeMode(DatabaseBridgeMode.SAVE_DATA); }