mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-10 04:50:12 +01:00
Allow unsafe enchants to be placed by [enchant] signs if enabled in the config file.
This commit is contained in:
parent
87cb6190eb
commit
6497db837d
@ -40,7 +40,8 @@ public class SignEnchant extends EssentialsSign
|
|||||||
sign.setLine(2, "§c<enchant>");
|
sign.setLine(2, "§c<enchant>");
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
if (level < 1 || level > enchantment.getMaxLevel())
|
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && player.isAuthorized("essentials.enchant.allowunsafe");
|
||||||
|
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
|
||||||
{
|
{
|
||||||
level = enchantment.getMaxLevel();
|
level = enchantment.getMaxLevel();
|
||||||
sign.setLine(2, enchantLevel[0] + ":" + level);
|
sign.setLine(2, enchantLevel[0] + ":" + level);
|
||||||
@ -48,10 +49,17 @@ public class SignEnchant extends EssentialsSign
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
|
{
|
||||||
|
if (allowUnsafe)
|
||||||
|
{
|
||||||
|
stack.addUnsafeEnchantment(enchantment, level);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
stack.addEnchantment(enchantment, level);
|
stack.addEnchantment(enchantment, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
@ -102,9 +110,23 @@ public class SignEnchant extends EssentialsSign
|
|||||||
|
|
||||||
final ItemStack toEnchant = playerHand;
|
final ItemStack toEnchant = playerHand;
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if (level == 0)
|
||||||
|
{
|
||||||
|
toEnchant.removeEnchantment(enchantment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ess.getSettings().allowUnsafeEnchantments())
|
||||||
|
{
|
||||||
|
toEnchant.addUnsafeEnchantment(enchantment, level);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
toEnchant.addEnchantment(enchantment, level);
|
toEnchant.addEnchantment(enchantment, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user