From ebbbb6c6705a2b8bc20a8cef5882cbfbfedf4d41 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Mon, 17 Oct 2022 18:58:39 +0200 Subject: [PATCH] fix: annotate ExpireManager with @Inject --- .../main/java/com/plotsquared/core/command/DebugExec.java | 5 ++--- .../com/plotsquared/core/plot/expiration/ExpireManager.java | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 9566bbc3c..51e8ad8fe 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -140,8 +140,7 @@ public class DebugExec extends SubCommand { return true; } case "start-expire" -> { - ExpireManager expireManager = PlotSquared.platform().expireManager() == null ? new ExpireManager(this.eventDispatcher) : PlotSquared.platform().expireManager(); - if (expireManager.runAutomatedTask()) { + if (PlotSquared.platform().expireManager().runAutomatedTask()) { player.sendMessage(TranslatableCaption.of("debugexec.expiry_started")); } else { player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started")); @@ -149,7 +148,7 @@ public class DebugExec extends SubCommand { return true; } case "stop-expire" -> { - if (PlotSquared.platform().expireManager() == null || !PlotSquared.platform().expireManager().cancelTask()) { + if (!PlotSquared.platform().expireManager().cancelTask()) { player.sendMessage(TranslatableCaption.of("debugexec.task_halted")); } else { player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index f5a23039a..24897af82 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -18,6 +18,7 @@ */ package com.plotsquared.core.plot.expiration; +import com.google.inject.Inject; import com.plotsquared.core.PlotPlatform; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.caption.Caption; @@ -76,6 +77,7 @@ public class ExpireManager { */ private int running; + @Inject public ExpireManager(final @NonNull EventDispatcher eventDispatcher) { this.tasks = new ArrayDeque<>(); this.dates_cache = new ConcurrentHashMap<>();