1
0
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:
snowleo
2012-10-16 21:24:00 +02:00
parent d056b9e436
commit c644eb1ee2
4 changed files with 29 additions and 4 deletions

View File

@@ -50,8 +50,9 @@ public class Commandenchant extends EssentialsCommand
level = -1; level = -1;
} }
} }
final boolean allowUnsafe = Permissions.ENCHANT_UNSAFE.isAuthorized(user);
final Enchantment enchantment = getEnchantment(args[0], user); final Enchantment enchantment = getEnchantment(args[0], user);
if (level < 0 || level > enchantment.getMaxLevel()) if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
@@ -61,7 +62,14 @@ public class Commandenchant extends EssentialsCommand
} }
else else
{ {
stack.addEnchantment(enchantment, level); if (allowUnsafe)
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
user.getPlayer().getInventory().setItemInHand(stack); user.getPlayer().getInventory().setItemInHand(stack);
user.getPlayer().updateInventory(); user.getPlayer().updateInventory();

View File

@@ -60,7 +60,14 @@ public class Commandgive extends EssentialsCommand
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
stack.addEnchantment(enchantment, level); if (Permissions.GIVE_ENCHANTED_UNSAFE.isAuthorized(sender))
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
} }

View File

@@ -56,7 +56,14 @@ public class Commanditem extends EssentialsCommand
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
stack.addEnchantment(enchantment, level); if (Permissions.ITEM_ENCHANTED_UNSAFE.isAuthorized(sender))
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
} }

View File

@@ -27,6 +27,7 @@ public enum Permissions implements IPermission
CLEARINVENTORY_OTHERS, CLEARINVENTORY_OTHERS,
DELHOME_OTHERS, DELHOME_OTHERS,
ECO_LOAN(PermissionDefault.FALSE), ECO_LOAN(PermissionDefault.FALSE),
ENCHANT_UNSAFE(PermissionDefault.FALSE),
ENDERCHEST_OTHERS, ENDERCHEST_OTHERS,
ESSENTIALS, ESSENTIALS,
EXP_GIVE, EXP_GIVE,
@@ -42,6 +43,7 @@ public enum Permissions implements IPermission
GETPOS_OTHERS, GETPOS_OTHERS,
GOD_OTHERS, GOD_OTHERS,
GIVE_ENCHANTED, GIVE_ENCHANTED,
GIVE_ENCHANTED_UNSAFE(PermissionDefault.FALSE),
HEAL_COOLDOWN_BYPASS, HEAL_COOLDOWN_BYPASS,
HEAL_OTHERS, HEAL_OTHERS,
HELPOP_RECEIVE, HELPOP_RECEIVE,
@@ -51,6 +53,7 @@ public enum Permissions implements IPermission
INVSEE_MODIFY, INVSEE_MODIFY,
INVSEE_PREVENT_MODIFY, INVSEE_PREVENT_MODIFY,
ITEM_ENCHANTED, ITEM_ENCHANTED,
ITEM_ENCHANTED_UNSAFE(PermissionDefault.FALSE),
KEEPXP, KEEPXP,
KICK_EXEMPT, KICK_EXEMPT,
KICK_NOTIFY, KICK_NOTIFY,