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


Java PluginCommand.setAliases方法代碼示例

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


在下文中一共展示了PluginCommand.setAliases方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例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() + "\"");
    }
  }
}
 
開發者ID:CardinalDevelopment,項目名稱:EllyCommand,代碼行數:23,代碼來源:CommandFactory.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

示例5: registerCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
/**
 * Registers a command in the server's CommandMap.
 *
 * @param ce CommandExecutor to be registered
 * @param rc ReflectCommand the command was annotated with
 */
public void registerCommand(@NotNull final BaseCommand<? extends Plugin> ce, @NotNull final ReflectCommand rc) {
    Preconditions.checkNotNull(ce, "ce was null");
    Preconditions.checkNotNull(rc, "rc was null");
    try {
        final Constructor c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
        c.setAccessible(true);
        final PluginCommand pc = (PluginCommand) c.newInstance(rc.name(), this.plugin);
        pc.setExecutor(ce);
        pc.setAliases(Arrays.asList(rc.aliases()));
        pc.setDescription(rc.description());
        pc.setUsage(rc.usage());
        final CommandMap cm = this.getCommandMap();
        if (cm == null) {
            this.plugin.getLogger().warning("CommandMap was null. Command " + rc.name() + " not registered.");
            return;
        }
        cm.register(this.plugin.getDescription().getName(), pc);
        this.commandHandler.addCommand(new CommandCoupling(ce, pc));
    } catch (Exception e) {
        this.plugin.getLogger().warning("Could not register command \"" + rc.name() + "\" - an error occurred: " + e.getMessage() + ".");
    }
}
 
開發者ID:Chatterbox,項目名稱:Chatterbox,代碼行數:29,代碼來源:ReflectiveCommandRegistrar.java

示例6: createPluginCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
/**
 * forces to create a PluginCommand
 * 
 * @author xize
 * @param cmd - the command to be created as instance
 * @return PluginCommand
 */
@SuppressWarnings("unchecked")
public PluginCommand createPluginCommand(String cmd) {
	try {
		//forcibly make a new PluginCommand object
		Class<?> clazz = Class.forName("org.bukkit.command.PluginCommand");
		Constructor<?> constructor = clazz.getDeclaredConstructor(String.class, Plugin.class);
		constructor.setAccessible(true);
		Field mf = Constructor.class.getDeclaredField("modifiers");
		mf.setAccessible(true);
		mf.setInt(constructor, constructor.getModifiers() &~Modifier.PROTECTED);

		PluginCommand command = (PluginCommand) constructor.newInstance(cmd, pl);
		command.setExecutor(new SimpleCommand(pl));
		List<String> aliases = (List<String>) pl.getDescription().getCommands().get(command.getName()).get("aliases");
		command.setAliases(aliases);

		constructor.setAccessible(false);
		mf.setAccessible(false);

		return command;  
	} catch(Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:xEssentials,項目名稱:xEssentials-deprecated-bukkit,代碼行數:33,代碼來源:CommandManager.java

示例7: 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);
  }
}
 
開發者ID:Rires-Magica,項目名稱:Bukkit-Utilities,代碼行數:31,代碼來源:CommandManager.java

示例8: registerCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
private boolean registerCommand(String[] aliases) {
    PluginCommand command = getCommand(aliases[0], javaPlugin);
    command.setAliases(Arrays.asList(aliases));
    command.setExecutor(this);
    getCommandMap().register(javaPlugin.getName(), command);
    return true;
}
 
開發者ID:BurnGames,項目名稱:BGDCore,代碼行數:8,代碼來源:Command.java

示例9: 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);
}
 
開發者ID:IntellectualSites,項目名稱:PlotSquared,代碼行數:9,代碼來源:BukkitMain.java

示例10: registerXprateCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
private static void registerXprateCommand() {
    List<String> aliasList = new ArrayList<String>();
    aliasList.add("mcxprate");

    PluginCommand command = mcMMO.p.getCommand("xprate");
    command.setDescription(LocaleLoader.getString("Commands.Description.xprate"));
    command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set");
    command.setPermissionMessage(permissionsMessage);
    command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "<true|false>"));
    command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset"));
    command.setAliases(aliasList);
    command.setExecutor(new XprateCommand());
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:14,代碼來源:CommandRegistrationManager.java

示例11: addCommandsFrom

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
/**
 * Add commands from a certain plugin to the internal list of commands.
 * 
 * @param plugin The plugin from which to read commands.
 */
@SuppressWarnings("unchecked")
protected void addCommandsFrom(JavaPlugin plugin)
{
	Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
	if (commands != null)
	{
		for (Entry<String, Map<String, Object>> entry : commands.entrySet())
		{
			PluginCommand command = PluginCommandUtils.createPluginCommand(entry.getKey(), plugin);
			for (Entry<String, Object> section : entry.getValue().entrySet())
			{
				switch (section.getKey())
				{
					case "description":
						command.setDescription((String) section.getValue());
						break;
					case "aliases":
						List<String> aliases = new ArrayList<>();
						if (section.getValue() instanceof String)
						{
							aliases.add((String) section.getValue());
						}
						else
						{
							aliases.addAll((List<String>) section.getValue());
						}
						command.setAliases(aliases);
						break;
					case "permission":
						command.setPermission((String) section.getValue());
						break;
					case "permission-message":
						command.setPermissionMessage((String) section.getValue());
						break;
					case "usage":
						command.setUsage((String) section.getValue());
						break;
					default:
						throw new UnsupportedOperationException("Unknown section " + section.getKey());
				}
			}
			this.commands.add(command);
		}
	}
}
 
開發者ID:seeseemelk,項目名稱:MockBukkit,代碼行數:51,代碼來源:PluginManagerMock.java

示例12: registerCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
public void registerCommand(String... aliases) {
	PluginCommand pluginCommand = getCommand(aliases[0], DiscordBot.getInstance());
	pluginCommand.setAliases(Arrays.asList(aliases));
	getCommandMap().register(DiscordBot.getInstance().getDescription().getName(), pluginCommand);
}
 
開發者ID:LXGaming,項目名稱:DiscordBot,代碼行數:6,代碼來源:CommandManager.java

示例13: registerCommands

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
@Override
public void registerCommands() {
    new MainCommand();
    MainCommand.subCommands.add(new Template());
    MainCommand.subCommands.add(new Setup());
    MainCommand.subCommands.add(new DebugUUID());
    MainCommand.subCommands.add(new DebugFill());
    MainCommand.subCommands.add(new DebugSaveTest());
    MainCommand.subCommands.add(new DebugLoadTest());
    MainCommand.subCommands.add(new CreateRoadSchematic());
    MainCommand.subCommands.add(new RegenAllRoads());
    MainCommand.subCommands.add(new DebugClear());
    MainCommand.subCommands.add(new Claim());
    MainCommand.subCommands.add(new Auto());
    MainCommand.subCommands.add(new Home());
    MainCommand.subCommands.add(new Visit());
    MainCommand.subCommands.add(new TP());
    MainCommand.subCommands.add(new Set());
    MainCommand.subCommands.add(new Toggle());
    MainCommand.subCommands.add(new Clear());
    MainCommand.subCommands.add(new Delete());
    MainCommand.subCommands.add(new SetOwner());
    if (Settings.ENABLE_CLUSTERS) {
        MainCommand.subCommands.add(new Cluster());
    }
    
    MainCommand.subCommands.add(new Trust());
    MainCommand.subCommands.add(new Add());
    MainCommand.subCommands.add(new Deny());
    MainCommand.subCommands.add(new Untrust());
    MainCommand.subCommands.add(new Remove());
    MainCommand.subCommands.add(new Undeny());
    
    MainCommand.subCommands.add(new Info());
    MainCommand.subCommands.add(new list());
    MainCommand.subCommands.add(new Help());
    MainCommand.subCommands.add(new Debug());
    MainCommand.subCommands.add(new SchematicCmd());
    MainCommand.subCommands.add(new plugin());
    MainCommand.subCommands.add(new Inventory());
    MainCommand.subCommands.add(new Purge());
    MainCommand.subCommands.add(new Reload());
    MainCommand.subCommands.add(new Merge());
    MainCommand.subCommands.add(new Unlink());
    MainCommand.subCommands.add(new Kick());
    MainCommand.subCommands.add(new Rate());
    MainCommand.subCommands.add(new DebugClaimTest());
    MainCommand.subCommands.add(new Inbox());
    MainCommand.subCommands.add(new Comment());
    MainCommand.subCommands.add(new Database());
    MainCommand.subCommands.add(new Unclaim());
    MainCommand.subCommands.add(new Swap());
    MainCommand.subCommands.add(new MusicSubcommand());
    MainCommand.subCommands.add(new DebugRoadRegen());
    MainCommand.subCommands.add(new Trim());
    MainCommand.subCommands.add(new DebugExec());
    MainCommand.subCommands.add(new FlagCmd());
    MainCommand.subCommands.add(new Target());
    MainCommand.subCommands.add(new DebugFixFlags());
    MainCommand.subCommands.add(new Move());
    MainCommand.subCommands.add(new Condense());
    MainCommand.subCommands.add(new Confirm());
    MainCommand.subCommands.add(new Copy());
    MainCommand.subCommands.add(new Chat());
    final BukkitCommand bcmd = new BukkitCommand();
    final PluginCommand plotCommand = getCommand("plots");
    plotCommand.setExecutor(bcmd);
    plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot", "p2"));
    plotCommand.setTabCompleter(bcmd);
}
 
開發者ID:Mayomi,項目名稱:PlotSquared-Chinese,代碼行數:71,代碼來源:BukkitMain.java

示例14: registerCommand

import org.bukkit.command.PluginCommand; //導入方法依賴的package包/類
public static void registerCommand(String... aliases) {
   PluginCommand command = getCommand(aliases[0], plugin);

   command.setAliases(Arrays.asList(aliases));
   getCommandMap().register(plugin.getDescription().getName(), command);
}
 
開發者ID:PaulBGD,項目名稱:MiniMiniGames,代碼行數:7,代碼來源:Utils.java


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