本文整理汇总了Java中org.bukkit.command.PluginCommand.setTabCompleter方法的典型用法代码示例。如果您正苦于以下问题:Java PluginCommand.setTabCompleter方法的具体用法?Java PluginCommand.setTabCompleter怎么用?Java PluginCommand.setTabCompleter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.command.PluginCommand
的用法示例。
在下文中一共展示了PluginCommand.setTabCompleter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerCommand
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
* Registers a CommandExecutor with the server
*
* @param plugin the plugin instance
* @param command the command instance
* @param aliases the command aliases
* @param <T> the command executor class type
* @return the command executor
*/
@Nonnull
public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, @Nonnull String... aliases) {
Preconditions.checkArgument(aliases.length != 0, "No aliases");
for (String alias : aliases) {
try {
PluginCommand cmd = COMMAND_CONSTRUCTOR.newInstance(alias, plugin);
getCommandMap().register(plugin.getDescription().getName(), cmd);
getKnownCommandMap().put(plugin.getDescription().getName().toLowerCase() + ":" + alias.toLowerCase(), cmd);
getKnownCommandMap().put(alias.toLowerCase(), cmd);
cmd.setLabel(alias.toLowerCase());
cmd.setExecutor(command);
if (command instanceof TabCompleter) {
cmd.setTabCompleter((TabCompleter) command);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return command;
}
示例2: register
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
private void register() {
for (EllyCommand command : commands) {
try {
Constructor constructor = Class.forName(PluginCommand.class.getName()).getDeclaredConstructor(String.class, Plugin.class);
constructor.setAccessible(true);
Plugin plugin = registry.getPlugin();
PluginCommand pluginCommand = (PluginCommand) constructor.newInstance(command.getName(), plugin);
pluginCommand.setAliases(command.getAliases());
pluginCommand.setDescription(command.getDescription());
pluginCommand.setExecutor(plugin);
pluginCommand.setTabCompleter(command.getTabCompleter());
pluginCommand.setUsage(command.getUsage(false));
Commands.getCommandMap().register(plugin.getName(), pluginCommand);
} catch (InstantiationException | InvocationTargetException | IllegalAccessException
| NoSuchMethodException | ClassNotFoundException e) {
Logger.getLogger("EllyCommand").severe("Could not register command \"" + command.getName() + "\"");
}
}
}
示例3: onEnable
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void onEnable() {
Config.setup(this);
PluginCommand mainCommand = getCommand(MainCommandExecutor.NAME);
mainCommand.setExecutor(new MainCommandExecutor(this));
mainCommand.setTabCompleter(new MainCommandTabCompleter());
PluginCommand confCommand = getCommand(ConfCommandExecutor.NAME);
confCommand.setExecutor(new ConfCommandExecutor(this));
confCommand.setTabCompleter(new ConfCommandTabCompleter());
getServer().getPluginManager().registerEvents(new CustomListener(this), this);
eventBus.register(new MainListener(this));
}
示例4: createPluginCommand
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
private PluginCommand createPluginCommand() {
plugin.debug("Creating plugin command");
try {
Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
c.setAccessible(true);
PluginCommand cmd = c.newInstance(name, plugin);
cmd.setDescription("Manage players' shops or this plugin.");
cmd.setUsage("/" + name);
cmd.setExecutor(new ShopBaseCommandExecutor());
cmd.setTabCompleter(new ShopBaseTabCompleter());
return cmd;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
plugin.getLogger().severe("Failed to create command");
plugin.debug("Failed to create plugin command");
plugin.debug(e);
}
return null;
}
示例5: subscribe
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
* Subscribes the commands to Bukkit commands list.
* The commands must be registered in plugin.yml by its name.
*/
public void subscribe() {
PluginCommand cmd = Bukkit.getPluginCommand(getName());
if (cmd == null) {
Uppercore.logger().severe("Command not found in plugin.yml: \"" + getName() + "\"");
return;
}
setDescription(cmd.getDescription());
cmd.setExecutor(this);
cmd.setTabCompleter(this);
registerPermissions(Bukkit.getPluginManager());
}
示例6: register
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
public static void register(String prefix, Plugin plugin, InjectableCommand... commands) {
for (InjectableCommand command : commands) {
if (command.getName() == null || command.getExecutor() == null) {
Bukkit.getServer().getLogger().severe("Could not register command " + command.getName() + " for plugin " + plugin.getName() + ": CommandName or CommandExecutor cannot be null");
continue;
}
if (command.getName().contains(":")) {
Bukkit.getServer().getLogger().severe("Could not register command " + command.getName() + " for plugin " + plugin.getName() + ": CommandName cannot contain \":\"");
continue;
}
PluginCommand _command = getPluginCommand(command.getName(), plugin);
_command.setExecutor(command.getExecutor());
if (command.getDescription() != null) {
_command.setDescription(command.getDescription());
}
if (!(command.getAliases() == null || command.getAliases().isEmpty())) {
_command.setAliases(command.getAliases());
}
if (command.getPermission() != null) {
_command.setPermission(command.getPermission());
}
if (command.getPermissionMessage() != null) {
_command.setPermissionMessage(command.getPermissionMessage());
}
if (command.getTabCompleter() != null) {
_command.setTabCompleter(command.getTabCompleter());
}
getCommandMap().register(prefix, _command);
}
}
示例7: registerCommand
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
private void registerCommand(String command, CommandExecutor executor, TabCompleter tabCompleter) {
if (tabCompleter == null && !(executor instanceof TabCompleter))
throw new UnsupportedOperationException();
PluginCommand commandObject = this.getCommand(command);
if (commandObject == null) return;
commandObject.setExecutor(executor);
commandObject.setTabCompleter(tabCompleter != null ? tabCompleter : (TabCompleter) executor);
}
示例8: Create
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
public Create(Main main) {
this.main = main;
PluginCommand command = main.getCommand("bpcreate");
command.setExecutor(this);
if (!syncConfig) {
command.setTabCompleter(new CreateCompleter());
}
}
示例9: onEnable
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public final void onEnable() {
if (API_MAJOR_VERSION < getRequiredMajorVersion()) {
logSevere("API version is too old! ( " + API_MAJOR_VERSION + "." + API_MINOR_VERSION + " < "
+ getRequiredMajorVersion() + "." + getRequiredMinorVersion() + " )");
loadFailed = true;
} else {
if(API_MAJOR_VERSION > getRequiredMajorVersion()){
logWarn("Major API version is newer than the minimum. Things may not work as expected");
}
for (JavaPluginCommandList cmd : getCommands()) { // Register Commands
logInfo("Registering Command: " + cmd.name());
PluginCommand pCmd = getCommand(cmd.name());
pCmd.setExecutor(cmd.getExecutor());
pCmd.setTabCompleter(cmd.getTabCompleter());
}
for (Listener evt : getEventHandlers()) {
logInfo("Registering Event Listener: " + evt);
getServer().getPluginManager().registerEvents(evt, this);
}
saveDefaultConfig();
if((loadFailed = !startup())){
logWarn("Failed to startup!!");
}
}
if(loadFailed){
Bukkit.getPluginManager().disablePlugin(this);
}
}
示例10: onEnable
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void onEnable() {
ReflectionHelper.init();
config = new Config(this);
config.loadConfig(getConfig());
config.saveConfig(getConfig());
saveConfig();
functions = new Register<Function>("Function", getLogger());
dataTypes = new Register<DataType>("Datatype", getLogger());
expressionHandler = new ExpressionHandler(this);
nbtHandler = new NBTHandler(this);
varTable = new VarTable(this);
registerDataTypes();
registerFunctions();
registerConstants();
PluginCommand commandExp = getCommand("exp");
commandExp.setExecutor(new CommandExp(this));
commandExp.setTabCompleter(new TabCompleterExp(this));
PluginCommand commandVarTable = getCommand("varTable");
commandVarTable.setExecutor(new CommandVarTable(this));
commandVarTable.setTabCompleter(new TabCompleterVarTable());
varTableFile = new File(getDataFolder(), "ac-vars.dat");
try {
loadVarTable(false);
} catch (Exception e) {
;
}
getLogger().info("Enabled");
}
示例11: registerCommands
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void registerCommands(Object object, boolean inject, List<AbstractModule> modules) throws CommandParseException
{
logger.log(Level.INFO, "Loading commands from class: " + object.getClass().getName());
//inject if we need to
if(inject) {
Injector childInjector = injector.createChildInjector(modules);
childInjector.injectMembers(object);
}
//the class of our object
Class klass = object.getClass();
//get all of the classes methods
Method[] methods = klass.getDeclaredMethods();
for(Method method : methods) {
//if it's a command method
if(parser.hasCommandMethodAnnotation(method)) {
//attempt to parse the route
CommandRoute route = parser.parseCommandMethodAnnotation(method, object);
PluginCommand command = Bukkit.getPluginCommand(route.getCommandName());
//if the command required is 'ungettable' throw an error
if(null == command)
throw new CommandParseException("Cannot register the command with name " + route.getCommandName());
//set ourselves as the executor for the command
command.setExecutor(this);
command.setTabCompleter(this);
//add to command map
commands.put(route.getCommandName(), route);
logger.log(Level.INFO, "Loading command '" + route.getCommandName() + "' from: " + method.getName());
}
}
logger.log(Level.INFO, "Loaded all commands from class: " + object.getClass().getName());
}
示例12: onEnable
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void onEnable(){
if (!getConfig().getBoolean("enabled")){
getLogger().severe("The plugin enabled status has not been set to true in the config, disabling...");
setEnabled(false);
return;
}
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new UUIDCompatibilityListener(this), this);
pluginManager.registerEvents(this, this);
PluginCommand command = getCommand("uuidcompatibility");
MainCommand mainCommand = new MainCommand(this);
command.setExecutor(mainCommand);
command.setTabCompleter(mainCommand);
importData();
try {
metrics = new Metrics(this);
Metrics.Graph storedGraph = metrics.createGraph("Player UUIDs <-> Names Stored");
storedGraph.addPlotter(new Metrics.Plotter() {
@Override
public int getValue() {
return getNameMappingsWrapper().getConfig().getKeys(false).size();
}
});
metrics.start();
} catch (IOException e){}
}
示例13: register
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
* Register a base command as a command executor
* @param cmd The command which this instance represents.
*/
public void register(PluginCommand cmd){
Validate.notNull(cmd, "The plugin command is null.");
cmd.setExecutor(this);
cmd.setTabCompleter(this);
}
示例14: register
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
* Register this parent command to handle execution of the specified plugin command.
* @param cmd A command which this instance represents.
*/
public final void register(PluginCommand cmd){
Validate.notNull(cmd, "The plugin command is null.");
cmd.setExecutor(this);
cmd.setTabCompleter(this);
}
示例15: registerCommands
import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void registerCommands() {
BukkitCommand bukkitCommand = new BukkitCommand();
PluginCommand plotCommand = getCommand("plots");
plotCommand.setExecutor(bukkitCommand);
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
plotCommand.setTabCompleter(bukkitCommand);
}