From b97e843849c6fbee0bc2d71100b77a2d81c2f8f8 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Tue, 2 Nov 2021 14:38:48 +0100 Subject: [PATCH] perf: Get rid of Guice overhead when accessing the plot area manager (#3315) Fixes #3311 Co-authored-by: Jordan --- .../main/java/com/plotsquared/bukkit/BukkitPlatform.java | 5 +++++ Core/src/main/java/com/plotsquared/core/PlotPlatform.java | 8 ++++++++ Core/src/main/java/com/plotsquared/core/PlotSquared.java | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 44f2b8893..765593c24 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -1180,6 +1180,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return this.injector; } + @Override + public @NonNull PlotAreaManager plotAreaManager() { + return this.plotAreaManager; + } + @NonNull @Override public Locale getLocale() { diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java index 1681d7bf4..6f1580a1b 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java +++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java @@ -38,6 +38,7 @@ import com.plotsquared.core.inject.annotations.DefaultGenerator; import com.plotsquared.core.location.World; import com.plotsquared.core.permissions.PermissionHandler; import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.EconHandler; @@ -268,6 +269,13 @@ public interface PlotPlatform

extends LocaleHolder { return injector().getInstance(ChunkManager.class); } + /** + * Get the {@link PlotAreaManager} implementation. + * + * @return the PlotAreaManager + */ + @NonNull PlotAreaManager plotAreaManager(); + /** * Get the platform specific console {@link Audience} * diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 98f3448ce..2c84dbab7 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -283,7 +283,7 @@ public class PlotSquared { * @return Plot area manager */ public @NonNull PlotAreaManager getPlotAreaManager() { - return this.platform.injector().getInstance(PlotAreaManager.class); + return this.platform.plotAreaManager(); } public void startExpiryTasks() {