mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-25 18:48:24 +01:00
Allow unsafe enchantments in /item /give /kit and /enchant
Needs enabled in config file manually.
This commit is contained in:
parent
d551e8c6d2
commit
ed88f8aa06
@ -151,6 +151,8 @@ public interface ISettings extends IConf
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean allowUnsafeEnchantments();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
|
@ -34,12 +34,13 @@ public class Kit
|
||||
{
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay")) {
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ public class Kit
|
||||
|
||||
// When was the last kit used?
|
||||
final long lastTime = user.getKitTimestamp(kitName);
|
||||
|
||||
|
||||
if (lastTime < earliestLong || lastTime == 0L)
|
||||
{
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
@ -80,15 +81,15 @@ public class Kit
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
return (List<String>)kit.get("items");
|
||||
@ -99,7 +100,7 @@ public class Kit
|
||||
throw new Exception(_("kitErrorHelp"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
@ -107,7 +108,7 @@ public class Kit
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
if (d.startsWith(ess.getSettings().getCurrencySymbol()))
|
||||
if (d.startsWith(ess.getSettings().getCurrencySymbol()))
|
||||
{
|
||||
Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim());
|
||||
Trade t = new Trade(value, ess);
|
||||
@ -119,7 +120,7 @@ public class Kit
|
||||
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
|
||||
|
||||
|
||||
final ItemStack stack = new ItemStack(id, amount, data);
|
||||
if (parts.length > 2)
|
||||
{
|
||||
@ -146,7 +147,14 @@ public class Kit
|
||||
}
|
||||
try
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
if (ess.getSettings().allowUnsafeEnchantments())
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -154,7 +162,7 @@ public class Kit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
|
@ -856,6 +856,12 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("repair-enchanted", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowUnsafeEnchantments()
|
||||
{
|
||||
return config.getBoolean("unsafe-enchantments", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldTeleportPermissions()
|
||||
|
@ -56,7 +56,8 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
final Enchantment enchantment = getEnchantment(args[0], user);
|
||||
if (level < 0 || level > enchantment.getMaxLevel())
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
|
||||
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
@ -66,7 +67,14 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
if (allowUnsafe)
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
user.getInventory().setItemInHand(stack);
|
||||
user.updateInventory();
|
||||
|
@ -81,7 +81,19 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchant.allowunsafe"))
|
||||
{
|
||||
allowUnsafe = false;
|
||||
}
|
||||
if (allowUnsafe)
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
super("item");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@ -25,7 +25,7 @@ public class Commanditem extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
? (!user.isAuthorized("essentials.itemspawn.item-all")
|
||||
@ -69,7 +69,14 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
if (ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe"))
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,12 +84,12 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
|
||||
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
|
@ -334,6 +334,10 @@ oversized-stacksize: 64
|
||||
# essentials.repair.enchanted
|
||||
repair-enchanted: true
|
||||
|
||||
# Allow 'unsafe' enchantments in kits and item spawning.
|
||||
# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins.
|
||||
unsafe-enchantments: false
|
||||
|
||||
#Do you want essentials to keep track of previous location for /back in the teleport listener?
|
||||
#If you set this to true any plugin that uses teleport will have the previous location registered.
|
||||
register-back-in-listener: false
|
||||
|
Loading…
Reference in New Issue
Block a user