From 6ef1163325939bb99e08f7cfe2d17b8957b691fa Mon Sep 17 00:00:00 2001 From: Vrganj <43708436+Vrganj@users.noreply.github.com> Date: Wed, 1 May 2024 18:45:15 +0200 Subject: [PATCH] perf: get rid of guice overhead when accessing the player & world manager (#4409) Return already injected fields to skip slow Injector access --- .../main/java/com/plotsquared/bukkit/BukkitPlatform.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 8aa3fb7c0..b169ddb4f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -24,7 +24,6 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; import com.google.inject.Stage; -import com.google.inject.TypeLiteral; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.inject.BackupModule; import com.plotsquared.bukkit.inject.BukkitModule; @@ -45,7 +44,6 @@ import com.plotsquared.bukkit.listener.SpigotListener; import com.plotsquared.bukkit.listener.WorldEvents; import com.plotsquared.bukkit.placeholder.PAPIPlaceholders; import com.plotsquared.bukkit.placeholder.PlaceholderFormatter; -import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayerManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitWorld; @@ -1271,15 +1269,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl @Override public @NonNull PlatformWorldManager worldManager() { - return injector().getInstance(Key.get(new TypeLiteral>() { - })); + return this.worldManager; } @Override @NonNull - @SuppressWarnings("unchecked") public PlayerManager, ? extends Player> playerManager() { - return (PlayerManager) injector().getInstance(PlayerManager.class); + return this.playerManager; } @Override