command.set/getDescription replaces a now deprecated set/getTooltip + javadocs
This commit is contained in:
parent
2ca3d148cc
commit
0f95f3063a
@ -3,46 +3,112 @@ package org.bukkit.command;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a Command, which executes various tasks upon user input
|
||||||
|
*/
|
||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
private final String name;
|
private final String name;
|
||||||
private List<String> aliases;
|
private List<String> aliases;
|
||||||
protected String tooltip = "";
|
protected String description = "";
|
||||||
protected String usageMessage;
|
protected String usageMessage;
|
||||||
|
|
||||||
public Command(String name) {
|
protected Command(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = new ArrayList<String>();
|
this.aliases = new ArrayList<String>();
|
||||||
this.usageMessage = "/" + name;
|
this.usageMessage = "/" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean execute(CommandSender sender, String currentAlias, String[] args);
|
/**
|
||||||
|
* Executes the command, returning its success
|
||||||
|
*
|
||||||
|
* @param sender Source object which is executing this command
|
||||||
|
* @param commandLabel The alias of the command used
|
||||||
|
* @param args All arguments passed to the command, split via ' '
|
||||||
|
* @return true if the command was successful, otherwise false
|
||||||
|
*/
|
||||||
|
public abstract boolean execute(CommandSender sender, String commandLabel, String[] args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of this command
|
||||||
|
*
|
||||||
|
* @return Name of this command
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of aliases registered to this command
|
||||||
|
*
|
||||||
|
* @return List of aliases
|
||||||
|
*/
|
||||||
public List<String> getAliases() {
|
public List<String> getAliases() {
|
||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTooltip() {
|
/**
|
||||||
return tooltip;
|
* Gets a brief description of this command
|
||||||
|
*
|
||||||
|
* @return Description of this command
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getDescription()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getTooltip() {
|
||||||
|
return getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an example usage of this command
|
||||||
|
*
|
||||||
|
* @return One or more example usages
|
||||||
|
*/
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return usageMessage;
|
return usageMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the list of aliases registered to this command
|
||||||
|
*
|
||||||
|
* @param aliases Aliases to register to this command
|
||||||
|
* @return This command object, for linking
|
||||||
|
*/
|
||||||
public Command setAliases(List<String> aliases) {
|
public Command setAliases(List<String> aliases) {
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command setTooltip(String tooltip) {
|
/**
|
||||||
this.tooltip = tooltip;
|
* Sets a brief description of this command
|
||||||
|
*
|
||||||
|
* @param description New command description
|
||||||
|
* @return This command object, for linking
|
||||||
|
*/
|
||||||
|
public Command setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setDescription(description)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Command setTooltip(String tooltip) {
|
||||||
|
this.description = tooltip;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the example usage of this command
|
||||||
|
*
|
||||||
|
* @param usage New example usage
|
||||||
|
* @return This command object, for linking
|
||||||
|
*/
|
||||||
public Command setUsage(String usage) {
|
public Command setUsage(String usage) {
|
||||||
this.usageMessage = usage;
|
this.usageMessage = usage;
|
||||||
return this;
|
return this;
|
||||||
|
@ -103,7 +103,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||||||
public VersionCommand(String name, Server server) {
|
public VersionCommand(String name, Server server) {
|
||||||
super(name);
|
super(name);
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.tooltip = "Gets the version of this server including any plugins in use";
|
this.description = "Gets the version of this server including any plugins in use";
|
||||||
this.usageMessage = "/version [plugin name]";
|
this.usageMessage = "/version [plugin name]";
|
||||||
this.setAliases(Arrays.asList("ver", "about"));
|
this.setAliases(Arrays.asList("ver", "about"));
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||||||
public ReloadCommand(String name, Server server) {
|
public ReloadCommand(String name, Server server) {
|
||||||
super(name);
|
super(name);
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.tooltip = "Reloads the server configuration and plugins";
|
this.description = "Reloads the server configuration and plugins";
|
||||||
this.usageMessage = "/reload";
|
this.usageMessage = "/reload";
|
||||||
this.setAliases(Arrays.asList("rl"));
|
this.setAliases(Arrays.asList("rl"));
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ public final class SimpleCommandMap implements CommandMap {
|
|||||||
public PluginsCommand(String name, Server server) {
|
public PluginsCommand(String name, Server server) {
|
||||||
super(name);
|
super(name);
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.tooltip = "Gets a list of plugins running on the server";
|
this.description = "Gets a list of plugins running on the server";
|
||||||
this.usageMessage = "/plugins";
|
this.usageMessage = "/plugins";
|
||||||
this.setAliases(Arrays.asList("pl"));
|
this.setAliases(Arrays.asList("pl"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user