Fixed natural loot generated items going above hard cap

This commit is contained in:
Auxilor 2021-07-04 19:13:36 +02:00
parent 32dd134372
commit 3542c1a62b

View File

@ -88,6 +88,8 @@ public class LootPopulator extends BlockPopulator {
multiplier /= plugin.getConfigYml().getDouble("loot.reduce-probability.factor");
}
int cap = 0;
for (EcoEnchant enchantment : enchantments) {
if (enchantment == null || enchantment.getRarity() == null) {
continue;
@ -145,6 +147,16 @@ public class LootPopulator extends BlockPopulator {
if (plugin.getConfigYml().getBool("loot.reduce-probability.enabled")) {
multiplier /= plugin.getConfigYml().getDouble("loot.reduce-probability.factor");
}
if (!enchantment.hasFlag("hard-cap-ignore")) {
cap++;
}
if (plugin.getConfigYml().getBool("anvil.hard-cap.enabled")) {
if (cap >= plugin.getConfigYml().getInt("anvil.hard-cap.cap")) {
break;
}
}
}
if (item.getItemMeta() instanceof EnchantmentStorageMeta meta) {