/**
   * Execute the command.
   *
   * @param sender the sender of the command
   * @param command the command being done
   * @param label the name of the command
   * @param args the arguments supplied
   */
  @Override
  public void execute(CommandSender sender, Command command, String label, String[] args) {

    if (!hasPermission()) {
      sender.sendMessage(PlugMan.getInstance().getMessageFormatter().format("error.no-permission"));
      return;
    }

    if (args.length < 2) {
      sender.sendMessage(
          PlugMan.getInstance().getMessageFormatter().format("error.specify-plugin"));
      sendUsage();
      return;
    }

    Plugin potential = PluginUtil.getPluginByName(args, 1);

    if (potential != null) {
      sender.sendMessage(
          PlugMan.getInstance()
              .getMessageFormatter()
              .format("load.already-loaded", potential.getName()));
      return;
    }

    String name = StringUtil.consolidateStrings(args, 1);

    if (PluginUtil.isIgnored(name)) {
      sender.sendMessage(PlugMan.getInstance().getMessageFormatter().format("error.ignored"));
      return;
    }

    sender.sendMessage(PluginUtil.load(name));
  }
Beispiel #2
0
  @Override
  public void execute(CommandSender sender, Command command, String label, String[] args) {

    if (!hasPermission()) {
      sender.sendMessage(PlugMan.getInstance().getMessageManager().format("error.no-permission"));
      return;
    }

    boolean includeVersions = includeVersions(args);

    List<String> pluginList = Lists.newArrayList();

    for (Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()) {
      pluginList.add(PluginUtils.getFormattedName(plugin, includeVersions));
    }

    Collections.sort(pluginList, String.CASE_INSENSITIVE_ORDER);

    String plugins = Joiner.on(", ").join(pluginList);

    sender.sendMessage(
        PlugMan.getInstance().getMessageManager().format("list.list", pluginList.size(), plugins));
  }