summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2012-11-18 17:45:00 -0500
committerEvilSeph <evilseph@gmail.com>2012-11-18 17:45:00 -0500
commitd9f9ca51272f23677f31130540647caa38dcfa28 (patch)
tree0aca36e5873510234b28a8ad3d873c80ade43922 /src/main/java
parent321aea41564edf3bdcc312ab9d93b74a114a46a3 (diff)
downloadbukkit-d9f9ca51272f23677f31130540647caa38dcfa28.tar
bukkit-d9f9ca51272f23677f31130540647caa38dcfa28.tar.gz
bukkit-d9f9ca51272f23677f31130540647caa38dcfa28.tar.lz
bukkit-d9f9ca51272f23677f31130540647caa38dcfa28.tar.xz
bukkit-d9f9ca51272f23677f31130540647caa38dcfa28.zip
Add ability to pass 'max' as 'level' for EnchantCommand.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/command/defaults/EnchantCommand.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/EnchantCommand.java b/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
index 45d4a468..29766493 100644
--- a/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
@@ -25,7 +25,7 @@ public class EnchantCommand extends VanillaCommand {
public EnchantCommand() {
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.usageMessage = "/enchant <player> <enchantment> [level|0] [force]";
+ this.usageMessage = "/enchant <player> <enchantment> [level|max|0] [force]";
this.setPermission("bukkit.command.enchant");
}
@@ -66,11 +66,10 @@ public class EnchantCommand extends VanillaCommand {
int level = 1;
if (args.length > 2) {
Integer integer = getInteger(args[2]);
+ int minLevel = enchantment.getStartLevel();
+ int maxLevel = force ? Short.MAX_VALUE : enchantment.getMaxLevel();
if (integer != null) {
- int minLevel = enchantment.getStartLevel();
- int maxLevel = force ? Short.MAX_VALUE : enchantment.getMaxLevel();
-
if (integer == 0) {
item.removeEnchantment(enchantment);
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;
}
+
+ if ("max".equals(args[2])) {
+ level = maxLevel;
+ }
}
Map<Enchantment, Integer> enchantments = item.getEnchantments();