Added bypass permission for hard cap
This commit is contained in:
@@ -27,7 +27,7 @@ public class AnvilListeners implements Listener {
|
||||
|
||||
Player player = (Player) event.getViewers().get(0);
|
||||
|
||||
Pair<ItemStack, Integer> newOut = AnvilMerge.doMerge(left, right, out, name);
|
||||
Pair<ItemStack, Integer> newOut = AnvilMerge.doMerge(left, right, out, name, player);
|
||||
|
||||
if(newOut.getKey() == null) {
|
||||
newOut.setKey(new ItemStack(Material.AIR, 0));
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.util.Pair;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
@@ -26,9 +27,10 @@ public class AnvilMerge {
|
||||
* @param right The {@link ItemStack} in the middle of the anvil
|
||||
* @param old The previous {@link ItemStack} result
|
||||
* @param name The anvil display name
|
||||
* @param player The player merging (for permissions)
|
||||
* @return The result, stored as a {@link Pair} of {@link ItemStack} and {@link Integer}.
|
||||
*/
|
||||
public static Pair<ItemStack, Integer> doMerge(ItemStack left, ItemStack right, ItemStack old, String name) {
|
||||
public static Pair<ItemStack, Integer> doMerge(ItemStack left, ItemStack right, ItemStack old, String name, Player player) {
|
||||
// Here so it can be accessed later (scope)
|
||||
|
||||
int outDamage = -1;
|
||||
@@ -130,7 +132,7 @@ public class AnvilMerge {
|
||||
if(left.getItemMeta() instanceof EnchantmentStorageMeta) canEnchantItem = true;
|
||||
|
||||
if(canEnchantItem && !doesConflict.get()) {
|
||||
if(ConfigManager.getConfig().getBool("anvil.hard-cap.enabled")) {
|
||||
if(ConfigManager.getConfig().getBool("anvil.hard-cap.enabled") && !player.hasPermission("ecoenchants.anvil.bypasshardcap")) {
|
||||
if(outEnchants.size() >= ConfigManager.getConfig().getInt("anvil.hard-cap.cap")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ permissions:
|
||||
ecoenchants.updateannounce: true
|
||||
ecoenchants.enchantinfo: true
|
||||
ecoenchants.ecodebug: true
|
||||
ecoenchants.anvil.*: true
|
||||
ecoenchants.anvil.*:
|
||||
description: Allows all anvil permissions
|
||||
default: op
|
||||
children:
|
||||
ecoenchants.anvil.bypasshardcap: true
|
||||
ecoenchants.fromtable.*:
|
||||
description: Allows getting all enchantments from an enchanting table
|
||||
default: true
|
||||
@@ -263,6 +269,9 @@ permissions:
|
||||
ecoenchants.enchantinfo:
|
||||
description: Allows the use of /enchantinfo to show enchant info
|
||||
default: true
|
||||
ecoenchants.anvil.bypasshardcap:
|
||||
description: Allows bypassing the anvil hard cap
|
||||
default: op
|
||||
|
||||
ecoenchants.fromtable.beheading:
|
||||
description: Allows getting beheading from an enchanting table
|
||||
|
||||
Reference in New Issue
Block a user