From 5c2d6b959f51d922409a2ff1d913341e6b116d02 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 2 Mar 2021 12:54:57 +0000 Subject: [PATCH] Fixed LootPopulator --- .../com/willfp/ecoenchants/EcoEnchantsPlugin.java | 14 +++++++++++--- .../support/obtaining/LootPopulator.java | 4 ---- 2 files changed, 11 insertions(+), 7 deletions(-) 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 59e60973..6a42871e 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 @@ -127,9 +127,17 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin { */ @Override public void postLoad() { - Bukkit.getServer().getWorlds().forEach(world -> { - world.getPopulators().add(new LootPopulator(this)); - }); + 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); + } + })); + world.getPopulators().add(new LootPopulator(this)); + }); + } EssentialsManager.registerEnchantments(); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java index 96206f93..c7c0e88b 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/LootPopulator.java @@ -51,10 +51,6 @@ public class LootPopulator extends BlockPopulator { public void populate(@NotNull final World world, @NotNull final Random random, @NotNull final Chunk chunk) { - if (!plugin.getConfigYml().getBool("loot.enabled")) { - return; - } - for (BlockState state : chunk.getTileEntities()) { Block block = state.getBlock(); if (!(block.getState() instanceof Chest)) {