Package org.bukkit.command

Examples of org.bukkit.command.PluginCommand


   * @param executor to register
   * @param commands to register it for
   */
  public final void register(CommandExecutor executor, String... commands) {
    for (String command : commands) {
      PluginCommand cmd = this.getCommand(command);
      if (cmd != null) {
        cmd.setExecutor(executor);
      }
    }
  }
View Full Code Here


    for (Method method : commands.getClass().getDeclaredMethods())
    {
      AutoRefCommand command = method.getAnnotation(AutoRefCommand.class);
      if (command == null || command.name().length == 0) continue;

      PluginCommand pcommand = plugin.getCommand(command.name()[0]);
      if (pcommand == null) throw new CommandRegistrationException(method, "Command not provided in plugin.yml");

      if (method.getReturnType() != boolean.class)
        throw new CommandRegistrationException(method, "Command method must return type boolean");

      if (pcommand.getExecutor() != this) pcommand.setExecutor(this);
      if (pcommand.getTabCompleter() != this) pcommand.setTabCompleter(this);

      CommandDelegator delegator = new CommandDelegator(commands, method, pcommand);
      this.setHandler(delegator, command.name());
    }
  }
View Full Code Here

  public void generateHelp(JavaPlugin plugin)
  {
    List<HelpTopic> topics = Lists.newArrayList();
    for (Map.Entry<String, HandlerNode> e : cmap.entrySet())
    {
      PluginCommand pcommand = Bukkit.getPluginCommand(e.getKey());
      if (pcommand != null && plugin.equals(pcommand.getPlugin()))
      {
        HandlerNode handler = e.getValue();
        if (handler != null) topics.addAll(handler.getHelpTopics(pcommand));
      }
    }
View Full Code Here

 
  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 EmptyStackException();
    }
View Full Code Here

TOP

Related Classes of org.bukkit.command.PluginCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.