summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAikar <aikar@aikar.co>2015-07-31 18:50:06 +1000
committermd_5 <git@md-5.net>2015-07-31 18:50:06 +1000
commitf718da3e4a09bbff8b9b301ba0da037d13fcf8ff (patch)
treec588668baabce0a3fa6138ed3f3dfa1dd30f1d6d /src
parent643b7d56fb3f6040df9b3f4eb559beb44153f165 (diff)
downloadbukkit-f718da3e4a09bbff8b9b301ba0da037d13fcf8ff.tar
bukkit-f718da3e4a09bbff8b9b301ba0da037d13fcf8ff.tar.gz
bukkit-f718da3e4a09bbff8b9b301ba0da037d13fcf8ff.tar.lz
bukkit-f718da3e4a09bbff8b9b301ba0da037d13fcf8ff.tar.xz
bukkit-f718da3e4a09bbff8b9b301ba0da037d13fcf8ff.zip
Allow setName to change a Command name before registration.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/command/Command.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index e5fb0f8f..a02c28d6 100644
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableList;
* Represents a Command, which executes various tasks upon user input
*/
public abstract class Command {
- private final String name;
+ private String name;
private String nextLabel;
private String label;
private List<String> aliases;
@@ -117,6 +117,25 @@ public abstract class Command {
}
/**
+ * Sets the name of this command.
+ * <p>
+ * May only be used before registering the command.
+ * Will return true if the new name is set, and false
+ * if the command has already been registered.
+ *
+ * @param name New command name
+ * @return returns true if the name change happened instantly or false if
+ * the command was already registered
+ */
+ public boolean setName(String name) {
+ if (!isRegistered()) {
+ this.name = name;
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Gets the permission required by users to be able to perform this
* command
*
@@ -186,9 +205,9 @@ public abstract class Command {
}
/**
- * Returns the current label for this command
+ * Returns the label for this command
*
- * @return Label of this command or null if not registered
+ * @return Label of this command
*/
public String getLabel() {
return label;
@@ -197,12 +216,13 @@ public abstract class Command {
/**
* Sets the label of this command.
* <p>
- * If the command is currently registered the label change will only take
- * effect after its been re-registered e.g. after a /reload
+ * May only be used before registering the command.
+ * Will return true if the new name is set, and false
+ * if the command has already been registered.
*
* @param name The command's name
* @return returns true if the name change happened instantly or false if
- * it was scheduled for re-registration
+ * the command was already registered
*/
public boolean setLabel(String name) {
this.nextLabel = name;