mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Added rmeove-illegal to config
This commit is contained in:
parent
78599ae9de
commit
294ae7e268
@ -304,4 +304,71 @@ public class ItemConversions extends PluginDependent<EcoPlugin> implements Liste
|
||||
this.getPlugin().getLogger().warning(player.getName() + " has/had an illegal item!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On player hold item.
|
||||
* <p>
|
||||
* Listener for hide fixer.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler
|
||||
public void removeDisallowed(@NotNull final PlayerItemHeldEvent event) {
|
||||
if (!this.getPlugin().getConfigYml().getBool("advanced.remove-illegal.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().hasPermission("ecoenchants.allowillegal")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack itemStack = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
||||
|
||||
clampItemLevels(itemStack, event.getPlayer());
|
||||
}
|
||||
|
||||
private void removeDisallowed(@Nullable final ItemStack itemStack,
|
||||
@NotNull final Player player) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (meta instanceof EnchantmentStorageMeta) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean illegal = false;
|
||||
|
||||
EcoEnchant illegalEnchant = null;
|
||||
|
||||
for (Enchantment enchantment : meta.getEnchants().keySet()) {
|
||||
if (EcoEnchants.getFromEnchantment(enchantment) != null) {
|
||||
EcoEnchant enchant = EcoEnchants.getFromEnchantment(enchantment);
|
||||
|
||||
if (!enchant.getTargetMaterials().contains(itemStack.getType())) {
|
||||
illegal = true;
|
||||
illegalEnchant = enchant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!illegal) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getPlugin().getConfigYml().getBool("advanced.remove-illegal.delete-item")) {
|
||||
itemStack.setType(Material.AIR);
|
||||
itemStack.setItemMeta(new ItemStack(Material.AIR).getItemMeta());
|
||||
itemStack.setItemMeta(meta);
|
||||
} else {
|
||||
meta.removeEnchant(illegalEnchant);
|
||||
}
|
||||
|
||||
this.getPlugin().getLogger().warning(player.getName() + " has/had an illegal item!");
|
||||
}
|
||||
}
|
||||
|
@ -144,3 +144,11 @@ advanced:
|
||||
enabled: false
|
||||
# If the item should be deleted rather than have the enchantment level capped.
|
||||
delete-item: false
|
||||
remove-illegal:
|
||||
# Helps reverse players who have enchantments on illegal items.
|
||||
# When holding an item, any enchantments present on the item that shouldn't be will be removed.
|
||||
# Players with ecoenchants.allowillegal permission will be ignored.
|
||||
# This may impact performance.
|
||||
enabled: false
|
||||
# If the item should be deleted rather than have the enchantment removed.
|
||||
delete-item: false
|
||||
|
@ -41,6 +41,7 @@ permissions:
|
||||
ecoenchants.bypasslevelclamp: true
|
||||
ecoenchants.anvil.*: true
|
||||
ecoenchants.command.*: true
|
||||
ecoenchants.allowillegal: true
|
||||
ecoenchants.anvil.*:
|
||||
description: Allows all anvil permissions
|
||||
default: op
|
||||
@ -98,6 +99,9 @@ permissions:
|
||||
ecoenchants.bypasslevelclamp:
|
||||
description: Allows bypassing the advanced level clamp option
|
||||
default: op
|
||||
ecoenchants.allowillegal:
|
||||
description: Don't remove illegal items when remove-illegal is enabled.
|
||||
default: op
|
||||
|
||||
# Perks
|
||||
ecoenchants.cooldowntime.half:
|
||||
|
Loading…
Reference in New Issue
Block a user