Add ability to pass 'max' as 'level' for EnchantCommand.
This commit is contained in:
parent
321aea4156
commit
d9f9ca5127
@ -25,7 +25,7 @@ public class EnchantCommand extends VanillaCommand {
|
|||||||
public EnchantCommand() {
|
public EnchantCommand() {
|
||||||
super("enchant");
|
super("enchant");
|
||||||
this.description = "Adds enchantments to the item the player is currently holding. Specify 0 for the level to remove an enchantment. Specify force to ignore normal enchantment restrictions";
|
this.description = "Adds enchantments to the item the player is currently holding. Specify 0 for the level to remove an enchantment. Specify force to ignore normal enchantment restrictions";
|
||||||
this.usageMessage = "/enchant <player> <enchantment> [level|0] [force]";
|
this.usageMessage = "/enchant <player> <enchantment> [level|max|0] [force]";
|
||||||
this.setPermission("bukkit.command.enchant");
|
this.setPermission("bukkit.command.enchant");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,11 +66,10 @@ public class EnchantCommand extends VanillaCommand {
|
|||||||
int level = 1;
|
int level = 1;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
Integer integer = getInteger(args[2]);
|
Integer integer = getInteger(args[2]);
|
||||||
|
|
||||||
if (integer != null) {
|
|
||||||
int minLevel = enchantment.getStartLevel();
|
int minLevel = enchantment.getStartLevel();
|
||||||
int maxLevel = force ? Short.MAX_VALUE : enchantment.getMaxLevel();
|
int maxLevel = force ? Short.MAX_VALUE : enchantment.getMaxLevel();
|
||||||
|
|
||||||
|
if (integer != null) {
|
||||||
if (integer == 0) {
|
if (integer == 0) {
|
||||||
item.removeEnchantment(enchantment);
|
item.removeEnchantment(enchantment);
|
||||||
Command.broadcastCommandMessage(sender, String.format("Removed %s on %s's %s", enchantmentName, player.getName(), itemName));
|
Command.broadcastCommandMessage(sender, String.format("Removed %s on %s's %s", enchantmentName, player.getName(), itemName));
|
||||||
@ -85,6 +84,10 @@ public class EnchantCommand extends VanillaCommand {
|
|||||||
|
|
||||||
level = integer;
|
level = integer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("max".equals(args[2])) {
|
||||||
|
level = maxLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchantments = item.getEnchantments();
|
Map<Enchantment, Integer> enchantments = item.getEnchantments();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user