From a6a16764dc8a00fa62d5550feb6f6dae36986c23 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 8 Sep 2019 20:36:10 +0300 Subject: [PATCH] Fixed old API (deprecated) not being initialized --- .../java/com/djrapitops/plan/PlanSystem.java | 4 +++- .../java/com/djrapitops/plan/api/PlanAPI.java | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java index 7e8511f1a..08623447c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java @@ -16,6 +16,7 @@ */ package com.djrapitops.plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.capability.CapabilityServiceImplementation; import com.djrapitops.plan.delivery.DeliveryUtilities; import com.djrapitops.plan.delivery.export.ExportSystem; @@ -96,7 +97,8 @@ public class PlanSystem implements SubSystem { ExtensionServiceImplementation extensionService, QueryServiceImplementation queryService, SettingsServiceImplementation settingsService, - ErrorHandler errorHandler + ErrorHandler errorHandler, + PlanAPI.PlanAPIHolder apiHolder ) { this.files = files; this.configSystem = configSystem; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/common/src/main/java/com/djrapitops/plan/api/PlanAPI.java index f68e5afd6..3bce22993 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -19,7 +19,13 @@ package com.djrapitops.plan.api; import com.djrapitops.plan.api.data.PlayerContainer; import com.djrapitops.plan.api.data.ServerContainer; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.identification.UUIDUtility; +import com.djrapitops.plan.storage.database.DBSystem; +import com.djrapitops.plugin.logging.console.PluginLogger; +import com.djrapitops.plugin.logging.error.ErrorHandler; +import javax.inject.Inject; +import javax.inject.Singleton; import java.util.Collection; import java.util.Map; import java.util.Optional; @@ -39,6 +45,7 @@ public interface PlanAPI { .orElseThrow(() -> new IllegalStateException("PlanAPI has not been initialised yet.")); } + @Singleton class PlanAPIHolder { static PlanAPI API; @@ -46,8 +53,14 @@ public interface PlanAPI { PlanAPIHolder.API = api; } - private PlanAPIHolder() { - /* Static variable holder */ + @Inject + public PlanAPIHolder( + DBSystem dbSystem, + UUIDUtility uuidUtility, + PluginLogger logger, + ErrorHandler errorHandler + ) { + set(new CommonAPI(dbSystem, uuidUtility, logger, errorHandler)); } }