Skip to content

Commit

Permalink
perf: get rid of guice overhead when accessing the player & world man…
Browse files Browse the repository at this point in the history
…ager (#4409)

Return already injected fields to skip slow Injector access
  • Loading branch information
Vrganj authored May 1, 2024
1 parent c57d784 commit 6ef1163
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
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;
Expand All @@ -45,7 +44,6 @@
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;
Expand Down Expand Up @@ -1271,15 +1269,13 @@ public void setLocale(final @NonNull Locale locale) {

@Override
public @NonNull PlatformWorldManager<?> worldManager() {
return injector().getInstance(Key.get(new TypeLiteral<PlatformWorldManager<World>>() {
}));
return this.worldManager;
}

@Override
@NonNull
@SuppressWarnings("unchecked")
public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> playerManager() {
return (PlayerManager<BukkitPlayer, Player>) injector().getInstance(PlayerManager.class);
return this.playerManager;
}

@Override
Expand Down

0 comments on commit 6ef1163

Please sign in to comment.