geforkt von Mirrors/Paper
Allow setName to change a Command name before registration.
By: Aikar <aikar@aikar.co>
Dieser Commit ist enthalten in:
Ursprung
2db2a26aec
Commit
a7e868a7a4
@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
* Represents a Command, which executes various tasks upon user input
|
* Represents a Command, which executes various tasks upon user input
|
||||||
*/
|
*/
|
||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
private final String name;
|
private String name;
|
||||||
private String nextLabel;
|
private String nextLabel;
|
||||||
private String label;
|
private String label;
|
||||||
private List<String> aliases;
|
private List<String> aliases;
|
||||||
@ -116,6 +116,25 @@ public abstract class Command {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Gets the permission required by users to be able to perform this
|
||||||
* command
|
* 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() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
@ -197,12 +216,13 @@ public abstract class Command {
|
|||||||
/**
|
/**
|
||||||
* Sets the label of this command.
|
* Sets the label of this command.
|
||||||
* <p>
|
* <p>
|
||||||
* If the command is currently registered the label change will only take
|
* May only be used before registering the command.
|
||||||
* effect after its been re-registered e.g. after a /reload
|
* Will return true if the new name is set, and false
|
||||||
|
* if the command has already been registered.
|
||||||
*
|
*
|
||||||
* @param name The command's name
|
* @param name The command's name
|
||||||
* @return returns true if the name change happened instantly or false if
|
* @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) {
|
public boolean setLabel(String name) {
|
||||||
this.nextLabel = name;
|
this.nextLabel = name;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren