From 0360db3a0f972a0dee6f47d4f979e94a8877fb5a Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:59:46 -0500 Subject: [PATCH] inline some usages --- .../AlternativeCommandsHandler.java | 2 +- .../com/earth2me/essentials/Essentials.java | 10 +++++----- .../essentials/EssentialsBlockListener.java | 4 ++-- .../essentials/EssentialsPlayerListener.java | 4 ++-- .../com/earth2me/essentials/IEssentials.java | 5 +++++ .../java/com/earth2me/essentials/Kit.java | 5 +++-- .../earth2me/essentials/MetaItemStack.java | 2 +- .../earth2me/essentials/RandomTeleport.java | 9 +++++---- .../com/earth2me/essentials/Settings.java | 20 ++++++++++++------- .../essentials/commands/Commandanvil.java | 6 ++++-- .../essentials/commands/Commandbottom.java | 2 +- .../commands/Commandcartographytable.java | 6 ++++-- .../essentials/commands/Commandcreatekit.java | 5 +++-- .../commands/Commandessentials.java | 4 ++-- .../commands/Commandgrindstone.java | 6 ++++-- .../essentials/commands/Commandhelp.java | 2 +- .../essentials/commands/Commandloom.java | 6 ++++-- .../commands/Commandsmithingtable.java | 6 ++++-- .../essentials/commands/Commandspawner.java | 2 +- .../commands/Commandstonecutter.java | 6 ++++-- .../essentials/commands/Commandtop.java | 2 +- .../commands/EssentialsCommand.java | 2 +- .../earth2me/essentials/items/FlatItemDb.java | 6 +++--- .../essentials/items/LegacyItemDb.java | 8 ++++---- .../essentials/signs/EssentialsSign.java | 14 +++++++------ .../earth2me/essentials/signs/SignAnvil.java | 4 ++-- .../essentials/signs/SignCartography.java | 4 ++-- .../essentials/signs/SignEnchant.java | 4 ++-- .../essentials/signs/SignGrindstone.java | 4 ++-- .../earth2me/essentials/signs/SignLoom.java | 4 ++-- .../essentials/signs/SignSmithing.java | 4 ++-- .../essentials/textreader/HelpInput.java | 2 +- .../essentials/utils/CommandMapUtil.java | 2 +- .../essentials/utils/LocationUtil.java | 15 ++++++++------ 34 files changed, 109 insertions(+), 78 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/main/java/com/earth2me/essentials/AlternativeCommandsHandler.java index b1594c2c4..107d7934f 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/AlternativeCommandsHandler.java +++ b/Essentials/src/main/java/com/earth2me/essentials/AlternativeCommandsHandler.java @@ -67,7 +67,7 @@ public class AlternativeCommandsHandler { private Map getPluginCommands(Plugin plugin) { final Map commands = new HashMap<>(); - for (final Map.Entry entry : ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().entrySet()) { + for (final Map.Entry entry : ess.provider(KnownCommandsProvider.class).getKnownCommands().entrySet()) { if (entry.getValue() instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) entry.getValue()).getPlugin().equals(plugin)) { commands.put(entry.getKey(), entry.getValue()); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java index 9aa7d2919..2182dac0f 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java @@ -506,7 +506,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { @Override public void onDisable() { - final boolean stopping = getProviders().get(ServerStateProvider.class).isStopping(); + final boolean stopping = provider(ServerStateProvider.class).isStopping(); if (!stopping) { LOGGER.log(Level.SEVERE, tl("serverReloading")); } @@ -619,8 +619,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { // Check for disabled commands if (getSettings().isCommandDisabled(commandLabel)) { - if (getProviders().get(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) { - final Command newCmd = getProviders().get(KnownCommandsProvider.class).getKnownCommands().get(commandLabel); + if (provider(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) { + final Command newCmd = provider(KnownCommandsProvider.class).getKnownCommands().get(commandLabel); if (!(newCmd instanceof PluginIdentifiableCommand) || ((PluginIdentifiableCommand) newCmd).getPlugin() != this) { return newCmd.tabComplete(cSender, commandLabel, args); } @@ -725,8 +725,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { // Check for disabled commands if (getSettings().isCommandDisabled(commandLabel)) { - if (getProviders().get(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) { - final Command newCmd = getProviders().get(KnownCommandsProvider.class).getKnownCommands().get(commandLabel); + if (provider(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) { + final Command newCmd = provider(KnownCommandsProvider.class).getKnownCommands().get(commandLabel); if (!(newCmd instanceof PluginIdentifiableCommand) || !isEssentialsPlugin(((PluginIdentifiableCommand) newCmd).getPlugin())) { return newCmd.execute(cSender, commandLabel, args); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java index 887982033..2890bc2a7 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java @@ -28,11 +28,11 @@ public class EssentialsBlockListener implements Listener { public void onBlockPlace(final BlockPlaceEvent event) { final ItemStack is = event.getItemInHand(); - if (is.getType() == MaterialUtil.SPAWNER && ess.getProviders().get(PersistentDataProvider.class).getString(is, "convert") != null) { + if (is.getType() == MaterialUtil.SPAWNER && ess.provider(PersistentDataProvider.class).getString(is, "convert") != null) { final BlockState blockState = event.getBlockPlaced().getState(); if (blockState instanceof CreatureSpawner) { final CreatureSpawner spawner = (CreatureSpawner) blockState; - final EntityType type = ess.getProviders().get(SpawnerItemProvider.class).getEntityType(event.getItemInHand()); + final EntityType type = ess.provider(SpawnerItemProvider.class).getEntityType(event.getItemInHand()); if (type != null && Mob.fromBukkitType(type) != null) { if (ess.getUser(event.getPlayer()).isAuthorized("essentials.spawnerconvert." + Mob.fromBukkitType(type).name().toLowerCase(Locale.ENGLISH))) { spawner.setSpawnedType(type); diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java index c5a462836..142b2fd1e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java @@ -607,10 +607,10 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { // If the plugin command does not exist, check if it is an alias from commands.yml if (ess.getServer().getPluginCommand(cmd) == null) { - final Command knownCommand = ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().get(cmd); + final Command knownCommand = ess.provider(KnownCommandsProvider.class).getKnownCommands().get(cmd); if (knownCommand instanceof FormattedCommandAlias) { final FormattedCommandAlias command = (FormattedCommandAlias) knownCommand; - for (String fullCommand : ess.getProviders().get(FormattedCommandAliasProvider.class).createCommands(command, event.getPlayer(), args.split(" "))) { + for (String fullCommand : ess.provider(FormattedCommandAliasProvider.class).createCommands(command, event.getPlayer(), args.split(" "))) { handlePlayerCommandPreprocess(event, fullCommand); } return; diff --git a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java index 286b431f0..c9e197bca 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java @@ -8,6 +8,7 @@ import com.earth2me.essentials.commands.PlayerNotFoundException; import com.earth2me.essentials.perm.PermissionsHandler; import com.earth2me.essentials.updatecheck.UpdateChecker; import com.earth2me.essentials.userstorage.IUserMap; +import net.ess3.provider.Provider; import net.essentialsx.api.v2.services.BalanceTop; import net.essentialsx.api.v2.services.mail.MailService; import org.bukkit.Server; @@ -131,4 +132,8 @@ public interface IEssentials extends Plugin { PluginCommand getPluginCommand(String cmd); ProviderFactory getProviders(); + + default

P provider(final Class

providerClass) { + return getProviders().get(providerClass); + } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Kit.java b/Essentials/src/main/java/com/earth2me/essentials/Kit.java index a12b6b157..7cf7572bb 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Kit.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Kit.java @@ -190,13 +190,14 @@ public class Kit { } final ItemStack stack; + final SerializationProvider serializationProvider = ess.provider(SerializationProvider.class); if (kitItem.startsWith("@")) { - if (ess.getProviders().get(SerializationProvider.class) == null) { + if (serializationProvider == null) { ess.getLogger().log(Level.WARNING, tl("kitError3", kitName, user.getName())); continue; } - stack = ess.getProviders().get(SerializationProvider.class).deserializeItem(Base64Coder.decodeLines(kitItem.substring(1))); + stack = serializationProvider.deserializeItem(Base64Coder.decodeLines(kitItem.substring(1))); } else { final String[] parts = kitItem.split(" +"); final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1); diff --git a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java index 2a41a5164..6446c5509 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java @@ -702,7 +702,7 @@ public class MetaItemStack { private void setUnbreakable(final IEssentials ess, final ItemStack is, final boolean unbreakable) { final ItemMeta meta = is.getItemMeta(); - ess.getProviders().get(ItemUnbreakableProvider.class).setUnbreakable(meta, unbreakable); + ess.provider(ItemUnbreakableProvider.class).setUnbreakable(meta, unbreakable); is.setItemMeta(meta); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java b/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java index 6742a9e5f..049fc8c1b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java +++ b/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java @@ -26,16 +26,17 @@ public class RandomTeleport implements IConf { private final IEssentials ess; private final EssentialsConfiguration config; private final ConcurrentLinkedQueue cachedLocations = new ConcurrentLinkedQueue<>(); + private WorldInfoProvider worldInfoProvider; public RandomTeleport(final IEssentials essentials) { this.ess = essentials; config = new EssentialsConfiguration(new File(essentials.getDataFolder(), "tpr.yml"), "/tpr.yml", "Configuration for the random teleport command.\nSome settings may be defaulted, and can be changed via the /settpr command in-game."); - reloadConfig(); } @Override public void reloadConfig() { + worldInfoProvider = ess.provider(WorldInfoProvider.class); config.load(); cachedLocations.clear(); } @@ -178,7 +179,7 @@ public class RandomTeleport implements IConf { final Location location = new Location( center.getWorld(), center.getX() + offsetX, - ess.getProviders().get(WorldInfoProvider.class).getMaxHeight(center.getWorld()), + worldInfoProvider.getMaxHeight(center.getWorld()), center.getZ() + offsetZ, 360 * RANDOM.nextFloat() - 180, 0 @@ -196,7 +197,7 @@ public class RandomTeleport implements IConf { // Returns an appropriate elevation for a given location in the nether, or -1 if none is found private double getNetherYAt(final Location location) { - for (int y = 32; y < ess.getProviders().get(WorldInfoProvider.class).getMaxHeight(location.getWorld()); ++y) { + for (int y = 32; y < worldInfoProvider.getMaxHeight(location.getWorld()); ++y) { if (!LocationUtil.isBlockUnsafe(ess, location.getWorld(), location.getBlockX(), y, location.getBlockZ())) { return y; } @@ -205,7 +206,7 @@ public class RandomTeleport implements IConf { } private boolean isValidRandomLocation(final Location location) { - return location.getBlockY() > ess.getProviders().get(WorldInfoProvider.class).getMinHeight(location.getWorld()) && !this.getExcludedBiomes().contains(location.getBlock().getBiome()); + return location.getBlockY() > worldInfoProvider.getMinHeight(location.getWorld()) && !this.getExcludedBiomes().contains(location.getBlock().getBiome()); } public File getFile() { diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index 975c29cd0..782b4c694 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -315,9 +315,11 @@ public class Settings implements net.ess3.api.ISettings { } private void _addAlternativeCommand(final String label, final Command current) { + final KnownCommandsProvider knownCommandsProvider = ess.provider(KnownCommandsProvider.class); + Command cmd = ess.getAlternativeCommandsHandler().getAlternative(label); if (cmd == null) { - for (final Map.Entry entry : ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().entrySet()) { + for (final Map.Entry entry : knownCommandsProvider.getKnownCommands().entrySet()) { final String[] split = entry.getKey().split(":"); if (entry.getValue() != current && split[split.length - 1].equals(label)) { cmd = entry.getValue(); @@ -327,7 +329,7 @@ public class Settings implements net.ess3.api.ISettings { } if (cmd != null) { - ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().put(label, cmd); + knownCommandsProvider.getKnownCommands().put(label, cmd); } } @@ -681,14 +683,16 @@ public class Settings implements net.ess3.api.ISettings { overriddenCommands = _getOverriddenCommands(); playerCommands = _getPlayerCommands(); + final KnownCommandsProvider knownCommandsProvider = ess.provider(KnownCommandsProvider.class); + // This will be late loaded - if (ess.getProviders().get(KnownCommandsProvider.class) != null) { + if (knownCommandsProvider != null) { boolean mapModified = false; if (!disabledBukkitCommands.isEmpty()) { if (isDebug()) { ess.getLogger().log(Level.INFO, "Re-adding " + disabledBukkitCommands.size() + " disabled commands!"); } - ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().putAll(disabledBukkitCommands); + knownCommandsProvider.getKnownCommands().putAll(disabledBukkitCommands); disabledBukkitCommands.clear(); mapModified = true; } @@ -700,7 +704,7 @@ public class Settings implements net.ess3.api.ISettings { if (isDebug()) { ess.getLogger().log(Level.INFO, "Attempting removal of " + effectiveAlias); } - final Command removed = ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().remove(effectiveAlias); + final Command removed = knownCommandsProvider.getKnownCommands().remove(effectiveAlias); if (removed != null) { if (isDebug()) { ess.getLogger().log(Level.INFO, "Adding command " + effectiveAlias + " to disabled map!"); @@ -718,14 +722,16 @@ public class Settings implements net.ess3.api.ISettings { } } + final SyncCommandsProvider syncCommandsProvider = ess.provider(SyncCommandsProvider.class); + if (mapModified) { if (isDebug()) { ess.getLogger().log(Level.INFO, "Syncing commands"); } if (reloadCount.get() < 2) { - ess.scheduleSyncDelayedTask(() -> ess.getProviders().get(SyncCommandsProvider.class).syncCommands()); + ess.scheduleSyncDelayedTask(syncCommandsProvider::syncCommands); } else { - ess.getProviders().get(SyncCommandsProvider.class).syncCommands(); + syncCommandsProvider.syncCommands(); } } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandanvil.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandanvil.java index 75a0c95a2..1b1f681ea 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandanvil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandanvil.java @@ -14,11 +14,13 @@ public class Commandanvil extends EssentialsCommand { @Override protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openAnvil(user.getBase()); + containerProvider.openAnvil(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbottom.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbottom.java index 849dc026a..a50281f66 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbottom.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbottom.java @@ -24,7 +24,7 @@ public class Commandbottom extends EssentialsCommand { final int bottomZ = user.getLocation().getBlockZ(); final float pitch = user.getLocation().getPitch(); final float yaw = user.getLocation().getYaw(); - final Location unsafe = new Location(user.getWorld(), bottomX, ess.getProviders().get(WorldInfoProvider.class).getMinHeight(user.getWorld()), bottomZ, yaw, pitch); + final Location unsafe = new Location(user.getWorld(), bottomX, ess.provider(WorldInfoProvider.class).getMinHeight(user.getWorld()), bottomZ, yaw, pitch); final Location safe = LocationUtil.getSafeDestination(ess, unsafe); final CompletableFuture future = getNewExceptionFuture(user.getSource(), commandLabel); future.thenAccept(success -> { diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcartographytable.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcartographytable.java index bd1160928..70407d49c 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcartographytable.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcartographytable.java @@ -14,11 +14,13 @@ public class Commandcartographytable extends EssentialsCommand { @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openCartographyTable(user.getBase()); + containerProvider.openCartographyTable(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcreatekit.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcreatekit.java index 29ae3a853..799c27b97 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcreatekit.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcreatekit.java @@ -42,9 +42,10 @@ public class Commandcreatekit extends EssentialsCommand { final ItemStack[] items = Inventories.getInventory(user.getBase(), true); final List list = new ArrayList<>(); + final SerializationProvider serializationProvider = ess.provider(SerializationProvider.class); boolean useSerializationProvider = ess.getSettings().isUseBetterKits(); - if (useSerializationProvider && ess.getProviders().get(SerializationProvider.class) == null) { + if (useSerializationProvider && serializationProvider == null) { ess.showError(user.getSource(), new Exception(tl("createKitUnsupported")), commandLabel); useSerializationProvider = false; } @@ -53,7 +54,7 @@ public class Commandcreatekit extends EssentialsCommand { if (is != null && is.getType() != null && is.getType() != Material.AIR) { final String serialized; if (useSerializationProvider) { - serialized = "@" + Base64Coder.encodeLines(ess.getProviders().get(SerializationProvider.class).serializeItem(is)); + serialized = "@" + Base64Coder.encodeLines(serializationProvider.serializeItem(is)); } else { serialized = ess.getItemDb().serialize(is); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandessentials.java index 9b28bc7a7..1c883307e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandessentials.java @@ -262,7 +262,7 @@ public class Commandessentials extends EssentialsCommand { serverData.addProperty("bukkit-version", Bukkit.getBukkitVersion()); serverData.addProperty("server-version", Bukkit.getVersion()); serverData.addProperty("server-brand", Bukkit.getName()); - serverData.addProperty("online-mode", ess.getProviders().get(OnlineModeProvider.class).getOnlineModeString()); + serverData.addProperty("online-mode", ess.provider(OnlineModeProvider.class).getOnlineModeString()); final JsonObject supportStatus = new JsonObject(); final VersionUtil.SupportStatus status = VersionUtil.getServerSupportStatus(); supportStatus.addProperty("status", status.name()); @@ -333,7 +333,7 @@ public class Commandessentials extends EssentialsCommand { final Plugin essDiscordLink = Bukkit.getPluginManager().getPlugin("EssentialsDiscordLink"); final Plugin essSpawn = Bukkit.getPluginManager().getPlugin("EssentialsSpawn"); - final Map knownCommandsCopy = new HashMap<>(ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands()); + final Map knownCommandsCopy = new HashMap<>(ess.provider(KnownCommandsProvider.class).getKnownCommands()); final Map disabledCommandsCopy = new HashMap<>(ess.getAlternativeCommandsHandler().disabledCommands()); // Further operations will be heavy IO diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgrindstone.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgrindstone.java index 6e3593c22..4ff55e588 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgrindstone.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgrindstone.java @@ -14,11 +14,13 @@ public class Commandgrindstone extends EssentialsCommand { @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openGrindstone(user.getBase()); + containerProvider.openGrindstone(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhelp.java index 121dc0f26..4cfea3d6e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhelp.java @@ -37,7 +37,7 @@ public class Commandhelp extends EssentialsCommand { if (input.getLines().isEmpty()) { if (pageStr != null && pageStr.startsWith("/")) { final String cmd = pageStr.substring(1); - for (final Map.Entry knownCmd : ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().entrySet()) { + for (final Map.Entry knownCmd : ess.provider(KnownCommandsProvider.class).getKnownCommands().entrySet()) { if (knownCmd.getKey().equalsIgnoreCase(cmd)) { user.sendMessage(tl("commandHelpLine1", cmd)); user.sendMessage(tl("commandHelpLine2", knownCmd.getValue().getDescription())); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandloom.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandloom.java index 7d064c2e5..ecc734d44 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandloom.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandloom.java @@ -14,11 +14,13 @@ public class Commandloom extends EssentialsCommand { @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openLoom(user.getBase()); + containerProvider.openLoom(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsmithingtable.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsmithingtable.java index 6765baacf..250de06fe 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsmithingtable.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsmithingtable.java @@ -14,11 +14,13 @@ public class Commandsmithingtable extends EssentialsCommand { @Override protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openSmithingTable(user.getBase()); + containerProvider.openSmithingTable(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandspawner.java index 6d3b50c12..5214b5877 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandspawner.java @@ -61,7 +61,7 @@ public class Commandspawner extends EssentialsCommand { final CreatureSpawner spawner = (CreatureSpawner) target.getBlock().getState(); spawner.setSpawnedType(mob.getType()); if (delay > 0) { - final SpawnerBlockProvider spawnerBlockProvider = ess.getProviders().get(SpawnerBlockProvider.class); + final SpawnerBlockProvider spawnerBlockProvider = ess.provider(SpawnerBlockProvider.class); spawnerBlockProvider.setMinSpawnDelay(spawner, 1); spawnerBlockProvider.setMaxSpawnDelay(spawner, Integer.MAX_VALUE); spawnerBlockProvider.setMinSpawnDelay(spawner, delay); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandstonecutter.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandstonecutter.java index 4b749548b..c37a63d27 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandstonecutter.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandstonecutter.java @@ -14,11 +14,13 @@ public class Commandstonecutter extends EssentialsCommand { @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (ess.getProviders().get(ContainerProvider.class) == null) { + final ContainerProvider containerProvider = ess.provider(ContainerProvider.class); + + if (containerProvider == null) { user.sendMessage(tl("unsupportedBrand")); return; } - ess.getProviders().get(ContainerProvider.class).openStonecutter(user.getBase()); + containerProvider.openStonecutter(user.getBase()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtop.java index 5c1fe370d..54d0bab9d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtop.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtop.java @@ -23,7 +23,7 @@ public class Commandtop extends EssentialsCommand { final int topZ = user.getLocation().getBlockZ(); final float pitch = user.getLocation().getPitch(); final float yaw = user.getLocation().getYaw(); - final Location unsafe = new Location(user.getWorld(), topX, ess.getProviders().get(WorldInfoProvider.class).getMaxHeight(user.getWorld()), topZ, yaw, pitch); + final Location unsafe = new Location(user.getWorld(), topX, ess.provider(WorldInfoProvider.class).getMaxHeight(user.getWorld()), topZ, yaw, pitch); final Location safe = LocationUtil.getSafeDestination(ess, unsafe); final CompletableFuture future = getNewExceptionFuture(user.getSource(), commandLabel); future.thenAccept(success -> { diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java index c4f5e1635..71e6b9088 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java @@ -278,7 +278,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand { * Lists all commands. */ protected final List getCommands(Server server) { - final Map commandMap = Maps.newHashMap(this.ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands()); + final Map commandMap = Maps.newHashMap(this.ess.provider(KnownCommandsProvider.class).getKnownCommands()); final List commands = Lists.newArrayListWithCapacity(commandMap.size()); for (final Command command : commandMap.values()) { if (!(command instanceof PluginIdentifiableCommand)) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java b/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java index 6eb20f04a..a132751dd 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java +++ b/Essentials/src/main/java/com/earth2me/essentials/items/FlatItemDb.java @@ -151,8 +151,8 @@ public class FlatItemDb extends AbstractItemDb { // setItemMeta to prevent a race condition final EntityType entity = data.getEntity(); if (entity != null && material.toString().contains("SPAWNER")) { - ess.getProviders().get(SpawnerItemProvider.class).setEntityType(stack, entity); - ess.getProviders().get(PersistentDataProvider.class).set(stack, "convert", "true"); + ess.provider(SpawnerItemProvider.class).setEntityType(stack, entity); + ess.provider(PersistentDataProvider.class).set(stack, "convert", "true"); } return stack; @@ -210,7 +210,7 @@ public class FlatItemDb extends AbstractItemDb { final PotionData potion = ((PotionMeta) item.getItemMeta()).getBasePotionData(); return new ItemData(type, potion); } else if (type.toString().contains("SPAWNER")) { - final EntityType entity = ess.getProviders().get(SpawnerItemProvider.class).getEntityType(item); + final EntityType entity = ess.provider(SpawnerItemProvider.class).getEntityType(item); return new ItemData(type, entity); } else { return new ItemData(type); diff --git a/Essentials/src/main/java/com/earth2me/essentials/items/LegacyItemDb.java b/Essentials/src/main/java/com/earth2me/essentials/items/LegacyItemDb.java index d7d229150..64e9402a0 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/items/LegacyItemDb.java +++ b/Essentials/src/main/java/com/earth2me/essentials/items/LegacyItemDb.java @@ -192,8 +192,8 @@ public class LegacyItemDb extends AbstractItemDb { if (mat == MOB_SPAWNER) { if (metaData == 0) metaData = EntityType.PIG.getTypeId(); try { - retval = ess.getProviders().get(SpawnerItemProvider.class).setEntityType(retval, EntityType.fromId(metaData)); - ess.getProviders().get(PersistentDataProvider.class).set(retval, "convert", "true"); + retval = ess.provider(SpawnerItemProvider.class).setEntityType(retval, EntityType.fromId(metaData)); + ess.provider(PersistentDataProvider.class).set(retval, "convert", "true"); } catch (final IllegalArgumentException e) { throw new Exception("Can't spawn entity ID " + metaData + " from mob spawners."); } @@ -204,10 +204,10 @@ public class LegacyItemDb extends AbstractItemDb { } catch (final IllegalArgumentException e) { throw new Exception("Can't spawn entity ID " + metaData + " from spawn eggs."); } - retval = ess.getProviders().get(SpawnEggProvider.class).createEggItem(type); + retval = ess.provider(SpawnEggProvider.class).createEggItem(type); } else if (mat.name().endsWith("POTION") && VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_11_R01)) { // Only apply this to pre-1.11 as items.csv might only work in 1.11 - retval = ess.getProviders().get(PotionMetaProvider.class).createPotionItem(mat, metaData); + retval = ess.provider(PotionMetaProvider.class).createPotionItem(mat, metaData); } else { retval.setDurability(metaData); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/main/java/com/earth2me/essentials/signs/EssentialsSign.java index 0358d7ca1..a80adb9c9 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/EssentialsSign.java @@ -166,24 +166,26 @@ public class EssentialsSign { } public void setOwnerData(final IEssentials ess, final User user, final ISign signProvider) { - if (ess.getProviders().get(SignDataProvider.class) == null) { + final SignDataProvider dataProvider = ess.provider(SignDataProvider.class); + if (dataProvider == null) { return; } final Sign sign = (Sign) signProvider.getBlock().getState(); - ess.getProviders().get(SignDataProvider.class).setSignData(sign, SIGN_OWNER_KEY, user.getUUID().toString()); + dataProvider.setSignData(sign, SIGN_OWNER_KEY, user.getUUID().toString()); } public boolean isOwner(final IEssentials ess, final User user, final ISign signProvider, final int nameIndex, final String namePrefix) { + final SignDataProvider dataProvider = ess.provider(SignDataProvider.class); final Sign sign = (Sign) signProvider.getBlock().getState(); - if (ess.getProviders().get(SignDataProvider.class) == null || ess.getProviders().get(SignDataProvider.class).getSignData(sign, SIGN_OWNER_KEY) == null) { + if (dataProvider == null || dataProvider.getSignData(sign, SIGN_OWNER_KEY) == null) { final boolean isLegacyOwner = FormatUtil.stripFormat(signProvider.getLine(nameIndex)).equalsIgnoreCase(getUsername(user)); - if (ess.getProviders().get(SignDataProvider.class) != null && isLegacyOwner) { - ess.getProviders().get(SignDataProvider.class).setSignData(sign, SIGN_OWNER_KEY, user.getUUID().toString()); + if (dataProvider != null && isLegacyOwner) { + dataProvider.setSignData(sign, SIGN_OWNER_KEY, user.getUUID().toString()); } return isLegacyOwner; } - if (user.getUUID().toString().equals(ess.getProviders().get(SignDataProvider.class).getSignData(sign, SIGN_OWNER_KEY))) { + if (user.getUUID().toString().equals(dataProvider.getSignData(sign, SIGN_OWNER_KEY))) { signProvider.setLine(nameIndex, namePrefix + getUsername(user)); return true; } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignAnvil.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignAnvil.java index 080f07ce3..e45c38f29 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignAnvil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignAnvil.java @@ -13,7 +13,7 @@ public class SignAnvil extends EssentialsSign { @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) { - if (ess.getProviders().get(ContainerProvider.class) == null) { + if (ess.provider(ContainerProvider.class) == null) { player.sendMessage(tl("unsupportedBrand")); return false; } @@ -22,7 +22,7 @@ public class SignAnvil extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - ess.getProviders().get(ContainerProvider.class).openAnvil(player.getBase()); + ess.provider(ContainerProvider.class).openAnvil(player.getBase()); return true; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignCartography.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignCartography.java index 5186f559e..50c6ee5d7 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignCartography.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignCartography.java @@ -13,7 +13,7 @@ public class SignCartography extends EssentialsSign { @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) { - if (ess.getProviders().get(ContainerProvider.class) == null) { + if (ess.provider(ContainerProvider.class) == null) { player.sendMessage(tl("unsupportedBrand")); return false; } @@ -22,7 +22,7 @@ public class SignCartography extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - ess.getProviders().get(ContainerProvider.class).openCartographyTable(player.getBase()); + ess.provider(ContainerProvider.class).openCartographyTable(player.getBase()); return true; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignEnchant.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignEnchant.java index 51e839802..22d144fdf 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignEnchant.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignEnchant.java @@ -23,7 +23,7 @@ public class SignEnchant extends EssentialsSign { protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException { final ItemStack stack; final String itemName = sign.getLine(1); - final MaterialTagProvider tagProvider = ess.getProviders().get(MaterialTagProvider.class); + final MaterialTagProvider tagProvider = ess.provider(MaterialTagProvider.class); try { stack = itemName.equals("*") || itemName.equalsIgnoreCase("any") || (tagProvider != null && tagProvider.tagExists(itemName)) ? null : getItemStack(sign.getLine(1), 1, ess); } catch (final SignException e) { @@ -68,7 +68,7 @@ public class SignEnchant extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException { final ItemStack playerHand = Inventories.getItemInHand(player.getBase()); - final MaterialTagProvider tagProvider = ess.getProviders().get(MaterialTagProvider.class); + final MaterialTagProvider tagProvider = ess.provider(MaterialTagProvider.class); final String itemName = sign.getLine(1); final ItemStack search = itemName.equals("*") || itemName.equalsIgnoreCase("any") || (tagProvider != null && tagProvider.tagExists(itemName) && tagProvider.isTagged(itemName, playerHand.getType())) ? null : getItemStack(itemName, 1, ess); final Trade charge = getTrade(sign, 3, ess); diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignGrindstone.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignGrindstone.java index 4c52a2aa2..bc217baf7 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignGrindstone.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignGrindstone.java @@ -13,7 +13,7 @@ public class SignGrindstone extends EssentialsSign { @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) { - if (ess.getProviders().get(ContainerProvider.class) == null) { + if (ess.provider(ContainerProvider.class) == null) { player.sendMessage(tl("unsupportedBrand")); return false; } @@ -22,7 +22,7 @@ public class SignGrindstone extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - ess.getProviders().get(ContainerProvider.class).openGrindstone(player.getBase()); + ess.provider(ContainerProvider.class).openGrindstone(player.getBase()); return true; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignLoom.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignLoom.java index c2de03f0d..b29b3a8b0 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignLoom.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignLoom.java @@ -13,7 +13,7 @@ public class SignLoom extends EssentialsSign { @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) { - if (ess.getProviders().get(ContainerProvider.class) == null) { + if (ess.provider(ContainerProvider.class) == null) { player.sendMessage(tl("unsupportedBrand")); return false; } @@ -22,7 +22,7 @@ public class SignLoom extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - ess.getProviders().get(ContainerProvider.class).openLoom(player.getBase()); + ess.provider(ContainerProvider.class).openLoom(player.getBase()); return true; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignSmithing.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignSmithing.java index d76c85cc4..2e38fc588 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignSmithing.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignSmithing.java @@ -13,7 +13,7 @@ public class SignSmithing extends EssentialsSign { @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) { - if (ess.getProviders().get(ContainerProvider.class) == null) { + if (ess.provider(ContainerProvider.class) == null) { player.sendMessage(tl("unsupportedBrand")); return false; } @@ -22,7 +22,7 @@ public class SignSmithing extends EssentialsSign { @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - ess.getProviders().get(ContainerProvider.class).openSmithingTable(player.getBase()); + ess.provider(ContainerProvider.class).openSmithingTable(player.getBase()); return true; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/textreader/HelpInput.java b/Essentials/src/main/java/com/earth2me/essentials/textreader/HelpInput.java index ab0c1a6e0..303e9b8c3 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/textreader/HelpInput.java +++ b/Essentials/src/main/java/com/earth2me/essentials/textreader/HelpInput.java @@ -34,7 +34,7 @@ public class HelpInput implements IText { } final Multimap pluginCommands = HashMultimap.create(); - for (final Command command : ess.getProviders().get(KnownCommandsProvider.class).getKnownCommands().values()) { + for (final Command command : ess.provider(KnownCommandsProvider.class).getKnownCommands().values()) { if (!(command instanceof PluginIdentifiableCommand)) { continue; } diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/CommandMapUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/CommandMapUtil.java index 2daa0cae1..336de90c4 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/CommandMapUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/CommandMapUtil.java @@ -61,7 +61,7 @@ public final class CommandMapUtil { } else if (value instanceof FormattedCommandAlias) { json.addProperty("source", "commands.yml"); final JsonArray formatStrings = new JsonArray(); - for (final String entry : ess.getProviders().get(FormattedCommandAliasProvider.class).getFormatStrings((FormattedCommandAlias) value)) { + for (final String entry : ess.provider(FormattedCommandAliasProvider.class).getFormatStrings((FormattedCommandAlias) value)) { formatStrings.add(new JsonPrimitive(entry)); } json.add("bukkit_aliases", formatStrings); diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java index ea4557b2a..d98d4e94a 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java @@ -110,7 +110,7 @@ public final class LocationUtil { } public static boolean isBlockAboveAir(IEssentials ess, final World world, final int x, final int y, final int z) { - return y > ess.getProviders().get(WorldInfoProvider.class).getMaxHeight(world) || HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType()); + return y > ess.provider(WorldInfoProvider.class).getMaxHeight(world) || HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType()); } public static boolean isBlockOutsideWorldBorder(final World world, final int x, final int z) { @@ -215,10 +215,12 @@ public final class LocationUtil { if (loc == null || loc.getWorld() == null) { throw new Exception(tl("destinationNotSet")); } + final WorldInfoProvider worldInfoProvider = ess.provider(WorldInfoProvider.class); + final World world = loc.getWorld(); - final int worldMinY = ess.getProviders().get(WorldInfoProvider.class).getMinHeight(world); - final int worldLogicalY = ess.getProviders().get(WorldInfoProvider.class).getLogicalHeight(world); - final int worldMaxY = loc.getBlockY() < worldLogicalY ? worldLogicalY : ess.getProviders().get(WorldInfoProvider.class).getMaxHeight(world); + final int worldMinY = worldInfoProvider.getMinHeight(world); + final int worldLogicalY = worldInfoProvider.getLogicalHeight(world); + final int worldMaxY = loc.getBlockY() < worldLogicalY ? worldLogicalY : worldInfoProvider.getMaxHeight(world); int x = loc.getBlockX(); int y = (int) Math.round(loc.getY()); int z = loc.getBlockZ(); @@ -275,13 +277,14 @@ public final class LocationUtil { } public static boolean shouldFly(IEssentials ess, final Location loc) { + final WorldInfoProvider worldInfoProvider = ess.provider(WorldInfoProvider.class); final World world = loc.getWorld(); final int x = loc.getBlockX(); int y = (int) Math.round(loc.getY()); final int z = loc.getBlockZ(); int count = 0; // Check whether more than 2 unsafe block are below player. - while (LocationUtil.isBlockUnsafe(ess, world, x, y, z) && y >= ess.getProviders().get(WorldInfoProvider.class).getMinHeight(world)) { + while (LocationUtil.isBlockUnsafe(ess, world, x, y, z) && y >= worldInfoProvider.getMinHeight(world)) { y--; count++; if (count > 2) { @@ -290,7 +293,7 @@ public final class LocationUtil { } // If not then check if player is in the void - return y < ess.getProviders().get(WorldInfoProvider.class).getMinHeight(world); + return y < worldInfoProvider.getMinHeight(world); } public static class Vector3D {