mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-30 01:39:51 +02:00
Allow unsafe enchantments in /item /give /enchant with permissions.
This commit is contained in:
@@ -50,8 +50,9 @@ public class Commandenchant extends EssentialsCommand
|
||||
level = -1;
|
||||
}
|
||||
}
|
||||
final boolean allowUnsafe = Permissions.ENCHANT_UNSAFE.isAuthorized(user);
|
||||
final Enchantment enchantment = getEnchantment(args[0], user);
|
||||
if (level < 0 || level > enchantment.getMaxLevel())
|
||||
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
@@ -60,9 +61,16 @@ public class Commandenchant extends EssentialsCommand
|
||||
stack.removeEnchantment(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allowUnsafe)
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
user.getPlayer().getInventory().setItemInHand(stack);
|
||||
user.getPlayer().updateInventory();
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
|
@@ -60,9 +60,16 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
if (Permissions.GIVE_ENCHANTED_UNSAFE.isAuthorized(sender))
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getTypeId() == 0)
|
||||
{
|
||||
|
@@ -56,9 +56,16 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
if (Permissions.ITEM_ENCHANTED_UNSAFE.isAuthorized(sender))
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getTypeId() == 0)
|
||||
{
|
||||
|
@@ -27,6 +27,7 @@ public enum Permissions implements IPermission
|
||||
CLEARINVENTORY_OTHERS,
|
||||
DELHOME_OTHERS,
|
||||
ECO_LOAN(PermissionDefault.FALSE),
|
||||
ENCHANT_UNSAFE(PermissionDefault.FALSE),
|
||||
ENDERCHEST_OTHERS,
|
||||
ESSENTIALS,
|
||||
EXP_GIVE,
|
||||
@@ -42,6 +43,7 @@ public enum Permissions implements IPermission
|
||||
GETPOS_OTHERS,
|
||||
GOD_OTHERS,
|
||||
GIVE_ENCHANTED,
|
||||
GIVE_ENCHANTED_UNSAFE(PermissionDefault.FALSE),
|
||||
HEAL_COOLDOWN_BYPASS,
|
||||
HEAL_OTHERS,
|
||||
HELPOP_RECEIVE,
|
||||
@@ -51,6 +53,7 @@ public enum Permissions implements IPermission
|
||||
INVSEE_MODIFY,
|
||||
INVSEE_PREVENT_MODIFY,
|
||||
ITEM_ENCHANTED,
|
||||
ITEM_ENCHANTED_UNSAFE(PermissionDefault.FALSE),
|
||||
KEEPXP,
|
||||
KICK_EXEMPT,
|
||||
KICK_NOTIFY,
|
||||
|
Reference in New Issue
Block a user