Java 类org.bukkit.command.CommandException 实例源码

项目:Chambers    文件:BukkitCommand.java   
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean success = false;

    if (!owningPlugin.isEnabled()) {
        return false;
    }

    if (!testPermission(sender)) {
        return true;
    }

    try {
        success = executor.onCommand(sender, this, commandLabel, args);
    } catch (Throwable ex) {
        throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + owningPlugin.getDescription().getFullName(), ex);
    }

    if (!success && usageMessage.length() > 0) {
        for (String line : usageMessage.replace("<command>", commandLabel).split("\n")) {
            sender.sendMessage(line);
        }
    }

    return success;
}
项目:ConditionalCommands    文件:ConditionalCommands.java   
private void protectedDispatch(CommandSender sender, String command) {
    boolean player = (sender instanceof Player);
    try {
        sender.sendMessage((player ? ChatColor.GOLD : "") + "[ConditionalCommands] > Dispatching command \"" + command + "\"");
        this.getServer().dispatchCommand(sender, command);
    } catch (CommandException ex) {
        if (getConfig().getBoolean("dev")) {
            sender.sendMessage((player ? ChatColor.GOLD : "") + "[ConditionalCommands] > An error occured whilst executing the command. The stack trace has been printed to the console.");
            this.getLogger().warning("ConditionalCommands executed this command on the main thread through the sender " + sender);
            this.getLogger().warning("The command string is: " + command);
            this.getLogger().warning("Stack trace follows: ");
            ex.printStackTrace();
        } else {
            sender.sendMessage((player ? ChatColor.GOLD : "") + "[ConditionalCommands] > There was a problem trying to run the command.");
        }
    }
}
项目:SupaCommons    文件:CommonExceptionHandler.java   
@Override public boolean execute(BaseCommand command, RegisteredCommand registeredCommand, CommandIssuer sender,
                                 List<String> args, Throwable t) {
  if (t instanceof InvocationTargetException) { // ACF doesnt pass actual exception in 0.5.0
    t = t.getCause();
  }
  if (t instanceof NumberFormatException) {
    final Matcher matcher = numberFormat.matcher(t.getMessage());
    if (matcher.matches()) {
      sender.sendMessage(ChatColor.RED + "Number expected; string \"" + matcher.group(1) + "\" given.");
      return true;
    } else {
      sender.sendMessage(ChatColor.RED + "Number expected; string given.");
      return true;
    }
  } else if (t instanceof CommonException) {
    sender.sendMessage(ChatColor.RED + t.getMessage());
    t.printStackTrace();
    return true;
  } else if (t instanceof CommandException) {
    sender.sendMessage(ChatColor.RED + t.getMessage());
    return true;
  }
  return false;
}
项目:Tweakkit-Server    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
      // Spigot Start
if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) )
      {
          return ImmutableList.of();
      }
      // Spigot End

      List<String> completions = null;
      try {
          completions = getCommandMap().tabComplete(player, message.substring(1));
      } catch (CommandException ex) {
          player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
          getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
      }

      return completions == null ? ImmutableList.<String>of() : completions;
  }
项目:SpigotSource    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
      // Spigot Start
if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) )
      {
          return ImmutableList.of();
      }
      // Spigot End

      List<String> completions = null;
      try {
          completions = getCommandMap().tabComplete(player, message.substring(1));
      } catch (CommandException ex) {
          player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
          getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
      }

      return completions == null ? ImmutableList.<String>of() : completions;
  }
项目:Uranium    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:ServerCommons    文件:BukkitCommand.java   
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean success;

    if (!this.owningPlugin.isEnabled()) {
        return false;
    }

    if (!testPermission(sender)) {
        return true;
    }

    try {
        success = this.executor.onCommand(sender, this, commandLabel, args);
    }
    catch (Throwable ex) {
        throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + this.owningPlugin.getDescription().getFullName(), ex);
    }

    if (!success && this.usageMessage.length() > 0) {
        for (String line : this.usageMessage.replace("<command>", commandLabel).split("\n")) {
            sender.sendMessage(line);
        }
    }

    return success;
}
项目:ServerCommons    文件:BukkitCommand.java   
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    List<String> completions = null;

    try {
        if (this.completer != null) {
            completions = this.completer.onTabComplete(sender, this, alias, args);
        }

        if (completions == null && this.executor instanceof TabCompleter) {
            completions = ((TabCompleter) this.executor).onTabComplete(sender, this, alias, args);
        }
    }
    catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');

        for (String arg : args) {
            message.append(arg).append(' ');
        }

        message.deleteCharAt(message.length() - 1).append("' in plugin ").append(this.owningPlugin.getDescription().getFullName());

        throw new CommandException(message.toString(), ex);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }

    return completions;
}
项目:Chambers    文件:BukkitCommand.java   
@Override
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    List<String> completions = null;
    try {
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias, args);
        }
        if (completions == null && executor instanceof TabCompleter) {
            completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
        }
    } catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1).append("' in plugin ")
                .append(owningPlugin.getDescription().getFullName());
        throw new CommandException(message.toString(), ex);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}
项目:ThermosRebased    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:Commons    文件:CommandWrapper.java   
@Override
public boolean execute( CommandSender commandSender, String commandLabel, String[] args ) {
    checkNotNull( commandSender );
    checkNotNull( commandLabel );
    checkNotNull( args );

    boolean success;

    if ( !plugin.isEnabled() ) {
        return false;
    }

    if ( !testPermission( commandSender ) ) {
        return true;
    }

    //execute
    try {
        success = executor.onCommand( commandSender, this, commandLabel, args );
    } catch ( Throwable ex ) {
        throw new CommandException( "Unhandled exception executing command '" + commandLabel + "' in plugin "
                + plugin.getDescription().getFullName(), ex );
    }

    // print usage
    if ( !success && usageMessage.length() > 0 ) {
        for ( String line : usageMessage.replace( "<command>", commandLabel ).split( "\n" ) ) {
            commandSender.sendMessage( line );
        }
    }

    return success;
}
项目:Commons    文件:CommandWrapper.java   
@Override
public List<String> tabComplete( CommandSender sender, String alias, String[] args )
        throws CommandException, IllegalArgumentException {
    checkNotNull( sender );
    checkNotNull( alias );
    checkNotNull( args );

    List<String> completions = null;
    try {
        // if we have a completer, get the completions from it
        if ( completer != null ) {
            completions = completer.onTabComplete( sender, this, alias, args );
        }
        // if not succeeded, try bukkits completer
        if ( completions == null && executor instanceof TabCompleter ) {
            completions = ( (TabCompleter) executor ).onTabComplete( sender, this, alias, args );
        }
    } catch ( Throwable ex ) {
        StringBuilder message = new StringBuilder();
        message.append( "Unhandled exception during tab completion for command '/" ).append( alias ).append( ' ' );
        for ( String arg : args ) {
            message.append( arg ).append( ' ' );
        }
        message.deleteCharAt( message.length() - 1 ).append( "' in plugin " )
                .append( plugin.getDescription().getFullName() );
        throw new CommandException( message.toString(), ex );
    }

    if ( completions == null ) {
        return super.tabComplete( sender, alias, args );
    }
    return completions;
}
项目:ExilePearl    文件:TestServer.java   
@Override
public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException {
       Validate.notNull(sender, "Sender cannot be null");
       Validate.notNull(commandLine, "CommandLine cannot be null");

       if (commandMap.dispatch(sender, commandLine)) {
           return true;
       }

       sender.sendMessage("Unknown command. Type \"/help\" for help.");

       return false;
}
项目:Thermos    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:KCauldron    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:CauldronGit    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:Cauldron-Old    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:DiffUtils    文件:CraftServer_188.java   
public List<String> tabCompleteCommand(Player player, String message) {
    List<String> completions = null;
    try {
        completions = getCommandMap().tabComplete(player, message.substring(1));
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions == null ? ImmutableList.<String>of() : completions;
}
项目:DiffUtils    文件:CraftServer_1710.java   
public List<String> tabCompleteCommand(Player player, String message) {
    List<String> completions = null;
    try {
        completions = getCommandMap().tabComplete(player, message.substring(1));
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions == null ? ImmutableList.<String>of() : completions;
}
项目:Cauldron-Reloaded    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:Zephyr    文件:BukkitCommandHandler.java   
@Override
public boolean execute(CommandSender sender, String commandLabel,
        String[] args) {
    boolean success = false;
    if (!owningPlugin.isEnabled()) {
        return false;
    }
    if (!testPermission(sender)) {
        return true;
    }
    try {
        success = executor.onCommand(sender, this, commandLabel, args);
    } catch (Throwable ex) {
        throw new CommandException(
                "Unhandled exception executing command '"
                        + commandLabel + "' in plugin "
                        + owningPlugin.getDescription().getFullName(),
                ex);
    }
    if (!success && usageMessage.length() > 0) {
        for (String line : usageMessage.replace("<command>",
                commandLabel).split("\n")) {
            sender.sendMessage(line);
        }
    }
    return success;
}
项目:FFoKC    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:CraftBukkit    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    List<String> completions = null;
    try {
        completions = getCommandMap().tabComplete(player, message.substring(1));
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions == null ? ImmutableList.<String>of() : completions;
}
项目:Craftbukkit    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    List<String> completions = null;
    try {
        completions = getCommandMap().tabComplete(player, message.substring(1));
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions == null ? ImmutableList.<String>of() : completions;
}
项目:AdvancedCommands    文件:BasicCommand.java   
@Override
public boolean onCommand(CommandSender paramCommandSender, Command paramCommand, String paramString,
        String[] paramArrayOfString) {
    try {
        doExecute(paramCommandSender, paramArrayOfString);
    } catch (Throwable e) {
        paramCommandSender.sendMessage(ChatColor.RED
                + ExceptionHelper.getExceptionMessage(e, getErrorMessageHead()));
        throw new CommandException(e.getMessage() == null ? "" : e.getMessage(), e);
    }
    return true;
}
项目:NovaGuilds    文件:CommandManager.java   
/**
 * Executes a command
 *
 * @param command command enum
 * @param sender  sender instance
 * @param args    command arguments
 */
public void execute(CommandWrapper command, CommandSender sender, String[] args) {
    CommandExecutor executor = getExecutor(command);

    if(command.getPermission() != null && !command.hasPermission(sender)) {
        Message.CHAT_NOPERMISSIONS.send(sender);
        return;
    }

    if(!command.allowedSender(sender)) {
        Message.CHAT_CMDFROMCONSOLE.send(sender);
        return;
    }

    NovaPlayer nPlayer = PlayerManager.getPlayer(sender);

    if((sender instanceof Player) && (command.hasFlag(CommandWrapper.Flag.CONFIRM) && !Permission.NOVAGUILDS_ADMIN_NOCONFIRM.has(sender) && (nPlayer.getCommandExecutorHandler() == null || nPlayer.getCommandExecutorHandler().getState() != CommandExecutorHandler.State.CONFIRMED))) {
        nPlayer.newCommandExecutorHandler(command, args);
        nPlayer.getCommandExecutorHandler().executorVariable(command.getExecutorVariable());
    }
    else {
        if(executor instanceof CommandExecutor.Reversed) {
            ((CommandExecutor.Reversed) executor).set(command.getExecutorVariable());
            command.executorVariable(null);
        }

        try {
            executor.execute(sender, args);
        }
        catch(Exception e) {
            LoggerUtils.exception(new CommandException("Unhandled exception executing command '" + command.getName() + "' in plugin NovaGuilds", e));
        }
    }
}
项目:WorldGifts    文件:ReloadCommand.java   
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    WorldGifts.getSelf().reloadConfig();
    PhraseConfig.reloadConfig();

    Msg.send(sender, PhraseConfig.Plugin_Reloaded.val());
}
项目:WorldGifts    文件:RemoveCommand.java   
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    if (!(sender instanceof Player)) return;

    Player p = (Player) sender;
    WorldGifts.getSelf().getWorldManager().removeItem(p, args[1], Integer.parseInt(args[2]));
}
项目:WorldGifts    文件:SetMaxTimesCommand.java   
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    WorldGifts.getSelf().getWorldManager().setMaxGetTimes(
            sender,
            args[1],
            Integer.parseInt(args[2]));
}
项目:WorldGifts    文件:HelpCommand.java   
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    Msg.send(sender, "&b\u2592\u2592\u2592\u2592\u2592 WorldGifts Help \u2592\u2592\u2592\u2592\u2592");
    Msg.send(sender, "&f/worldgifts &7" + PhraseConfig.Help__Cmd_PluginInfo.val());
    Msg.send(sender, "&f/worldgifts help &7" + PhraseConfig.Help__Cmd_Help.val());
    Msg.send(sender, "&f/worldgifts list <world> &7" + PhraseConfig.Help__Cmd_List.val());
    Msg.send(sender, "&f/worldgifts setmaxtimes <world> <max get times> &7" + PhraseConfig.Help__Cmd_SetMaxTimes.val());
    Msg.send(sender, "&f/worldgifts resetplayer <world> <player name> &7" + PhraseConfig.Help__Cmd_Reset_Player.val());
    Msg.send(sender, "&f/worldgifts put <world> &7" + PhraseConfig.Help__Cmd_Put.val());
    Msg.send(sender, "&f/worldgifts remove <world> <item index> &7" + PhraseConfig.Help__Cmd_Remove.val());
    Msg.send(sender, "&f/worldgifts reload &7" + PhraseConfig.Help__Cmd_Reload.val());
    Msg.send(sender, "&b\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592");
}
项目:WorldGifts    文件:ResetPlayerCommand.java   
@SuppressWarnings("deprecation")
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    UUID targetUUID = WorldGifts.getSelf().getServer().getPlayer(args[2]).getUniqueId();

    WorldGifts.getSelf().getPlayerSaves().resetPlayer(
            sender,
            args[1],
            targetUUID);
}
项目:WorldGifts    文件:PutCommand.java   
@Override
public void action (CommandSender sender, String[] args) throws CommandException
{
    if (!(sender instanceof Player)) return;

    Player p = (Player) sender;
    WorldGifts.getSelf().getWorldManager().addItem(p, args[1], p.getItemInHand());
}
项目:Almura-Server    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    List<String> completions = null;
    try {
        completions = (org.spigotmc.SpigotConfig.tabComplete) ? getCommandMap().tabComplete(player, message.substring(1)) : null;
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions == null ? ImmutableList.<String>of() : completions;
}
项目:PartyLobby    文件:CommandFramework.java   
@Override
public boolean execute(CommandSender sender, String commandLabel,
        String[] args) {
    boolean success = false;

    if (!owningPlugin.isEnabled()) {
        return false;
    }

    if (!testPermission(sender)) {
        return true;
    }

    try {
        success = executor.onCommand(sender, this, commandLabel, args);
    } catch (Throwable ex) {
        throw new CommandException(
                "Unhandled exception executing command '"
                        + commandLabel + "' in plugin "
                        + owningPlugin.getDescription().getFullName(),
                ex);
    }

    if (!success && usageMessage.length() > 0) {
        for (String line : usageMessage.replace("<command>",
                commandLabel).split("\n")) {
            sender.sendMessage(line);
        }
    }

    return success;
}
项目:PartyLobby    文件:CommandFramework.java   
@Override
public List<String> tabComplete(CommandSender sender, String alias,
        String[] args) throws CommandException,
        IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    List<String> completions = null;
    try {
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias,
                    args);
        }
        if (completions == null && executor instanceof TabCompleter) {
            completions = ((TabCompleter) executor).onTabComplete(
                    sender, this, alias, args);
        }
    } catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append(
                "Unhandled exception during tab completion for command '/")
                .append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1)
                .append("' in plugin ")
                .append(owningPlugin.getDescription().getFullName());
        throw new CommandException(message.toString(), ex);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}
项目:Zephyrus-II    文件:BukkitCommand.java   
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    boolean success = false;

    if (!owningPlugin.isEnabled()) {
        return false;
    }

    if (!testPermission(sender)) {
        return true;
    }

    try {
        success = executor.onCommand(sender, this, commandLabel, args);
    } catch (Throwable ex) {
        throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin "
                + owningPlugin.getDescription().getFullName(), ex);
    }

    if (!success && usageMessage.length() > 0) {
        for (String line : usageMessage.replace("<command>", commandLabel).split("\n")) {
            sender.sendMessage(line);
        }
    }

    return success;
}
项目:Zephyrus-II    文件:BukkitCommand.java   
@Override
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args)
        throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    List<String> completions = null;
    try {
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias, args);
        }
        if (completions == null && executor instanceof TabCompleter) {
            completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
        }
    } catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1).append("' in plugin ")
                .append(owningPlugin.getDescription().getFullName());
        throw new CommandException(message.toString(), ex);
    }

    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}
项目:AreaShop    文件:GeneralRegion.java   
/**
 * Run commands as the CommandsSender, replacing all tags with the relevant values.
 * @param sender   The sender that should perform the command
 * @param commands A list of the commands to run (without slash and with tags)
 */
public void runCommands(CommandSender sender, List<String> commands) {
    if(commands == null || commands.isEmpty()) {
        return;
    }

    for(String command : commands) {
        if(command == null || command.length() == 0) {
            continue;
        }
        // It is not ideal we have to disable language replacements here, but otherwise giving language variables
        // to '/areashop message' by a command in the config gets replaced and messes up the fancy formatting.
        command = Message.fromString(command).replacements(this).noLanguageReplacements().getSingle();

        boolean result;
        String error = null;
        String stacktrace = null;
        try {
            result = plugin.getServer().dispatchCommand(sender, command);
        } catch(CommandException e) {
            result = false;
            error = e.getMessage();
            stacktrace = ExceptionUtils.getStackTrace(e);
        }
        boolean printed = false;
        if(!result) {
            printed = true;
            if(error != null) {
                AreaShop.warn("Command execution failed, command=" + command + ", error=" + error + ", stacktrace:");
                AreaShop.warn(stacktrace);
                AreaShop.warn("--- End of stacktrace ---");
            } else {
                AreaShop.warn("Command execution failed, command=" + command);
            }
        }
        if(!printed) {
            AreaShop.debug("Command run, executor=" + sender.getName() + ", command=" + command);
        }
    }
}
项目:Cauldron    文件:CraftServer.java   
public List<String> tabCompleteCommand(Player player, String message) {
    // Spigot Start
    if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) )
    {
        return ImmutableList.of();
    }
    // Spigot End

    // Spigot Start
    List<String> completions = new ArrayList<String>();
    try {
        message = message.substring( 1 );
        List<String> bukkitCompletions = getCommandMap().tabComplete( player, message );
        if ( bukkitCompletions != null )
        {
            completions.addAll( bukkitCompletions );
        }
        List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message );
        if ( vanillaCompletions != null )
        {
            completions.addAll( vanillaCompletions );
        }
        // Spigot End
    } catch (CommandException ex) {
        player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
        getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
    }

    return completions; // Spigot
}
项目:TheSurvivalGames    文件:CommandHandler.java   
/**
 * Gets the SubCommand represnted by a specific Command
 * 
 * @param cmd The name of the command to get
 * @return The SubCommand of the command
 * @throws CommandException when the command was not found. Should be caught.
 */
SubCommand getCommand(String cmd) throws CommandException {
    if (commands.containsKey(cmd)) {
        return commands.get(cmd);
    } else {
        throw new CommandException("This command was not found.");
    }
}