Add AnvilView#bypassEnchantmentLevelRestriction

Anvils, by default, limit applied enchantment levels to their respective
maximum level. The added API enables plugins to disable this behaviour,
allowing enchantments that are overleveled to be applied via the anvil.
This commit is contained in:
Doc
2024-10-06 16:46:36 -03:00
parent f207099765
commit e95dccb515
2 changed files with 33 additions and 11 deletions

View File

@@ -50,6 +50,18 @@ public class CraftAnvilView extends CraftInventoryView<AnvilMenu, AnvilInventory
this.container.maximumRepairCost = cost;
}
// Paper start
@Override
public boolean bypassesEnchantmentLevelRestriction() {
return this.container.bypassEnchantmentLevelRestriction;
}
@Override
public void bypassEnchantmentLevelRestriction(final boolean bypassEnchantmentLevelRestriction) {
this.container.bypassEnchantmentLevelRestriction = bypassEnchantmentLevelRestriction;
}
// Paper end
public void updateFromLegacy(CraftInventoryAnvil legacy) {
if (legacy.isRepairCostSet()) {
this.setRepairCost(legacy.getRepairCost());