Fixed old API (deprecated) not being initialized

This commit is contained in:
Rsl1122 2019-09-08 20:36:10 +03:00
parent 1185aa05f2
commit a6a16764dc
2 changed files with 18 additions and 3 deletions

View File

@ -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;

View File

@ -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));
}
}