diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java index 32cdc541..4638af74 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -11,6 +11,7 @@ import com.willfp.ecoenchants.config.RarityYml; import com.willfp.ecoenchants.config.TargetYml; import com.willfp.ecoenchants.config.VanillaEnchantsYml; import com.willfp.ecoenchants.display.EnchantDisplay; +import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.support.merging.anvil.AnvilListeners; import com.willfp.ecoenchants.enchantments.support.merging.grindstone.GrindstoneListeners; @@ -25,12 +26,11 @@ import com.willfp.ecoenchants.integrations.essentials.plugins.IntegrationEssenti import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; import lombok.Getter; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.generator.BlockPopulator; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -81,46 +81,35 @@ public class EcoEnchantsPlugin extends EcoPlugin { @Override protected void handleDisable() { - Bukkit.getServer().getWorlds().forEach(world -> { - List populators = new ArrayList<>(world.getPopulators()); - populators.forEach((blockPopulator -> { - if (blockPopulator instanceof LootPopulator) { - world.getPopulators().remove(blockPopulator); - } - })); - }); + for (World world : Bukkit.getServer().getWorlds()) { + world.getPopulators().removeIf(blockPopulator -> blockPopulator instanceof LootPopulator); + } } @Override protected void handleReload() { this.getDisplayModule().update(); - EcoEnchants.values().forEach((ecoEnchant -> { - HandlerList.unregisterAll(ecoEnchant); - + for (EcoEnchant enchant : EcoEnchants.values()) { + HandlerList.unregisterAll(enchant); this.getScheduler().runLater(() -> { - if (ecoEnchant.isEnabled()) { - this.getEventManager().registerListener(ecoEnchant); + if (enchant.isEnabled()) { + this.getEventManager().registerListener(enchant); - if (ecoEnchant instanceof TimedRunnable) { - this.getScheduler().syncRepeating((TimedRunnable) ecoEnchant, 5, ((TimedRunnable) ecoEnchant).getTime()); + if (enchant instanceof TimedRunnable) { + this.getScheduler().syncRepeating((TimedRunnable) enchant, 5, ((TimedRunnable) enchant).getTime()); } } }, 1); - })); + } } @Override protected void handleAfterLoad() { if (this.getConfigYml().getBool("loot.enabled")) { - Bukkit.getServer().getWorlds().forEach(world -> { - List populators = new ArrayList<>(world.getPopulators()); - populators.forEach((blockPopulator -> { - if (blockPopulator instanceof LootPopulator) { - world.getPopulators().remove(blockPopulator); - } - })); + for (World world : Bukkit.getServer().getWorlds()) { + world.getPopulators().removeIf(blockPopulator -> blockPopulator instanceof LootPopulator); world.getPopulators().add(new LootPopulator(this)); - }); + } } EssentialsManager.registerEnchantments(); } @@ -148,7 +137,7 @@ public class EcoEnchantsPlugin extends EcoPlugin { new AnvilListeners(this), new WatcherTriggers(this), new VillagerListeners(this), - new ItemConversions(this) + new ItemConversions() ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java index 6343783c..3ff7c357 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -63,7 +63,9 @@ public class EnchantmentConfig extends YamlExtendableConfig { public Set getEnchantments(@NotNull final String path) { Set enchantments = new HashSet<>(); List enchantmentKeys = this.getStrings(path); - enchantmentKeys.forEach((key -> enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key))))); + for (String key : enchantmentKeys) { + enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key))); + } return enchantments; } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java index f3dbad90..b8c4b2dc 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java @@ -47,12 +47,14 @@ public class CallingCurse extends EcoEnchant implements TimedRunnable { private void refresh() { players.clear(); - this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { - int level = EnchantChecks.getArmorPoints(player, this, 0); - if (level > 0) { - players.put(player, level); + this.getPlugin().getScheduler().runLater(() -> { + for (Player player : this.getPlugin().getServer().getOnlinePlayers()) { + int level = EnchantChecks.getArmorPoints(player, this, 0); + if (level > 0) { + players.put(player, level); + } } - }), 1); + }, 1); distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance"); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java index 05b2fd92..2e6888d9 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Forcefield.java @@ -47,12 +47,14 @@ public class Forcefield extends EcoEnchant implements TimedRunnable { private void refresh() { players.clear(); - this.getPlugin().getScheduler().runLater(() -> this.getPlugin().getServer().getOnlinePlayers().forEach(player -> { - int level = EnchantChecks.getArmorPoints(player, this, 0); - if (level > 0) { - players.put(player, level); + this.getPlugin().getScheduler().runLater(() -> { + for (Player player : this.getPlugin().getServer().getOnlinePlayers()) { + int level = EnchantChecks.getArmorPoints(player, this, 0); + if (level > 0) { + players.put(player, level); + } } - }), 1); + }, 1); initialDistance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance"); bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level"); damagePerPoint = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");