geforkt von Mirrors/Paper
Added JavaPlugin.getCommand
By: Dinnerbone <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
3eb015141a
Commit
9c2782bea7
@ -32,4 +32,13 @@ public final class PluginCommand extends Command {
|
||||
public void setExecutor(CommandExecutor executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner of this PluginCommand
|
||||
*
|
||||
* @return Plugin that owns this command
|
||||
*/
|
||||
public Plugin getPlugin() {
|
||||
return owningPlugin;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
@ -158,7 +159,31 @@ public abstract class JavaPlugin implements Plugin {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command with the given name, specific to this plugin
|
||||
*
|
||||
* @param name Name or alias of the command
|
||||
* @return PluginCommand if found, otherwise null
|
||||
*/
|
||||
public PluginCommand getCommand(String name) {
|
||||
String alias = name.toLowerCase();
|
||||
PluginCommand command = getServer().getPluginCommand(alias);
|
||||
|
||||
if ((command != null) && (command.getPlugin() != this)) {
|
||||
command = getServer().getPluginCommand(getDescription().getName().toLowerCase() + ":" + alias);
|
||||
}
|
||||
|
||||
if ((command != null) && (command.getPlugin() == this)) {
|
||||
return command;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren