當前位置: 首頁>>代碼示例>>Java>>正文


Java PluginCommand.setLabel方法代碼示例

本文整理匯總了Java中org.bukkit.command.PluginCommand.setLabel方法的典型用法代碼示例。如果您正苦於以下問題:Java PluginCommand.setLabel方法的具體用法?Java PluginCommand.setLabel怎麽用?Java PluginCommand.setLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.command.PluginCommand的用法示例。


在下文中一共展示了PluginCommand.setLabel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:32,代碼來源:CommandMapUtil.java

示例2: setupBukkitCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
private PluginCommand setupBukkitCommand() {
	try {
		final Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
		c.setAccessible(true);
		final PluginCommand bukkitCommand = c.newInstance(name, Skript.getInstance());
		bukkitCommand.setAliases(aliases);
		bukkitCommand.setDescription(description);
		bukkitCommand.setLabel(label);
		bukkitCommand.setPermission(permission);
		bukkitCommand.setPermissionMessage(permissionMessage);
		bukkitCommand.setUsage(usage);
		bukkitCommand.setExecutor(this);
		return bukkitCommand;
	} catch (final Exception e) {
		Skript.outdatedError(e);
		throw new EmptyStacktraceException();
	}
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:19,代碼來源:ScriptCommand.java

示例3: createNewBukkitCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
/**
 * Creates a new Bukkit command.
 *
 * @param nukkitCommand
 *            The Nukkit command.
 * @return The plugin command.
 * @throws ClassCastException
 *             If the nukkitCommand is not provided by a Bukkit plugin.
 */
private PluginCommand createNewBukkitCommand(cn.nukkit.command.PluginCommand<?> nukkitCommand) {
	Plugin bukkitPlugin = PokkitPlugin.toBukkit(nukkitCommand.getPlugin());
	try {
		Constructor<PluginCommand> constructor = PluginCommand.class.getDeclaredConstructor(String.class,
				Plugin.class);
		constructor.setAccessible(true);
		PluginCommand bukkitCommand = constructor.newInstance(nukkitCommand.getName(), bukkitPlugin);

		bukkitCommand.setAliases(Arrays.asList(nukkitCommand.getAliases()));
		bukkitCommand.setDescription(nukkitCommand.getDescription());
		bukkitCommand.setLabel(nukkitCommand.getLabel());
		bukkitCommand.setPermission(nukkitCommand.getPermission());
		bukkitCommand.setPermissionMessage(nukkitCommand.getPermissionMessage());
		bukkitCommand.setUsage(nukkitCommand.getUsage());

		return bukkitCommand;
	} catch (ReflectiveOperationException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:30,代碼來源:PokkitCommandFetcher.java

示例4: addExecutor

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
@SneakyThrows
public static void addExecutor(Plugin plugin, Command command) {
    Field f = SimplePluginManager.class.getDeclaredField("commandMap");
    f.setAccessible(true);
    CommandMap map = (CommandMap) f.get(plugin.getServer().getPluginManager());
    Constructor<PluginCommand> init = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
    init.setAccessible(true);
    PluginCommand inject = init.newInstance(command.getName(), plugin);
    inject.setExecutor((who, __, label, input) -> command.execute(who, label, input));
    inject.setAliases(command.getAliases());
    inject.setDescription(command.getDescription());
    inject.setLabel(command.getLabel());
    inject.setName(command.getName());
    inject.setPermission(command.getPermission());
    inject.setPermissionMessage(command.getPermissionMessage());
    inject.setUsage(command.getUsage());
    map.register(plugin.getName().toLowerCase(), inject);
}
 
開發者ID:caoli5288,項目名稱:EnderChest,代碼行數:19,代碼來源:PluginHelper.java


注:本文中的org.bukkit.command.PluginCommand.setLabel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。