summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-10-16 21:24:00 +0200
committersnowleo <schneeleo@gmail.com>2012-10-16 21:24:00 +0200
commitc644eb1ee2fe9b6bc1b787e95086fb76a3797445 (patch)
tree2bef4f662f0d331ca63f1b1a652f659449482758
parentd056b9e43688a7dc03e2491760499fa2897fa141 (diff)
downloadEssentials-c644eb1ee2fe9b6bc1b787e95086fb76a3797445.tar
Essentials-c644eb1ee2fe9b6bc1b787e95086fb76a3797445.tar.gz
Essentials-c644eb1ee2fe9b6bc1b787e95086fb76a3797445.tar.lz
Essentials-c644eb1ee2fe9b6bc1b787e95086fb76a3797445.tar.xz
Essentials-c644eb1ee2fe9b6bc1b787e95086fb76a3797445.zip
Allow unsafe enchantments in /item /give /enchant with permissions.
-rw-r--r--Essentials/src/net/ess3/commands/Commandenchant.java12
-rw-r--r--Essentials/src/net/ess3/commands/Commandgive.java9
-rw-r--r--Essentials/src/net/ess3/commands/Commanditem.java9
-rw-r--r--Essentials/src/net/ess3/permissions/Permissions.java3
4 files changed, 29 insertions, 4 deletions
diff --git a/Essentials/src/net/ess3/commands/Commandenchant.java b/Essentials/src/net/ess3/commands/Commandenchant.java
index af7c9cf5b..916d7d183 100644
--- a/Essentials/src/net/ess3/commands/Commandenchant.java
+++ b/Essentials/src/net/ess3/commands/Commandenchant.java
@@ -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();
}
@@ -61,7 +62,14 @@ public class Commandenchant extends EssentialsCommand
}
else
{
- stack.addEnchantment(enchantment, level);
+ if (allowUnsafe)
+ {
+ stack.addUnsafeEnchantment(enchantment, level);
+ }
+ else
+ {
+ stack.addEnchantment(enchantment, level);
+ }
}
user.getPlayer().getInventory().setItemInHand(stack);
user.getPlayer().updateInventory();
diff --git a/Essentials/src/net/ess3/commands/Commandgive.java b/Essentials/src/net/ess3/commands/Commandgive.java
index 0e18aba99..6bc23fc3e 100644
--- a/Essentials/src/net/ess3/commands/Commandgive.java
+++ b/Essentials/src/net/ess3/commands/Commandgive.java
@@ -60,7 +60,14 @@ public class Commandgive extends EssentialsCommand
{
level = enchantment.getMaxLevel();
}
- stack.addEnchantment(enchantment, level);
+ if (Permissions.GIVE_ENCHANTED_UNSAFE.isAuthorized(sender))
+ {
+ stack.addUnsafeEnchantment(enchantment, level);
+ }
+ else
+ {
+ stack.addEnchantment(enchantment, level);
+ }
}
}
diff --git a/Essentials/src/net/ess3/commands/Commanditem.java b/Essentials/src/net/ess3/commands/Commanditem.java
index a082a5101..4ae60a7c4 100644
--- a/Essentials/src/net/ess3/commands/Commanditem.java
+++ b/Essentials/src/net/ess3/commands/Commanditem.java
@@ -56,7 +56,14 @@ public class Commanditem extends EssentialsCommand
{
level = enchantment.getMaxLevel();
}
- stack.addEnchantment(enchantment, level);
+ if (Permissions.ITEM_ENCHANTED_UNSAFE.isAuthorized(sender))
+ {
+ stack.addUnsafeEnchantment(enchantment, level);
+ }
+ else
+ {
+ stack.addEnchantment(enchantment, level);
+ }
}
}
diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java
index afaf5e2b4..256154238 100644
--- a/Essentials/src/net/ess3/permissions/Permissions.java
+++ b/Essentials/src/net/ess3/permissions/Permissions.java
@@ -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,