コード例 #1
0
ファイル: InfoCommand.java プロジェクト: ValorVl/jDcHub
  @Override
  public String execute(String cmd, String args, AbstractClient commandOwner) {
    this.client = commandOwner;
    this.cmd = cmd;
    this.args = args;

    StringBuilder info = new StringBuilder();
    info.append("\n >> Information about client:");

    if (args == null || args.isEmpty()) {
      // send info client's stats
      info.append(ClientUtils.getClientStats(commandOwner));
      commandOwner.sendPrivateMessageFromHub(info.toString());
    } else if ((args.equals("?"))) {
      showHelp();
      return null;
    } else {
      AbstractClient clientAbout = ClientManager.getInstance().getClientByNick(args);

      if (clientAbout == null) {
        String result = "Client with nick \'" + args + "\' not found!";
        commandOwner.sendPrivateMessageFromHub(result);
        return result;
      }

      info.append(ClientUtils.getClientStats(clientAbout));
      commandOwner.sendPrivateMessageFromHub(info.toString());
    }

    return info.toString();
  }
コード例 #2
0
ファイル: ReloadCommand.java プロジェクト: ValorVl/jDcHub
  @Override
  public String execute(String cmd, String args, AbstractClient commandOwner) {
    ClientUtils.sendMessageToOpChat(commandOwner.getNick() + " called !reload command.");

    ClientUtils.broadcastTextMessageFromHub("Hub will be freezed due to configs loading...");

    try {
      Thread.sleep(timeout);
    } catch (InterruptedException ex) {
      // ignored
    }

    String result;
    if (ConfigurationManager.getInstance().loadConfigs()) {
      result = "Configs reloaded.";
      commandOwner.sendPrivateMessageFromHub(result);
    } else {
      result = "Configs doesn\'t reloaded. See logs for more information.";
      commandOwner.sendPrivateMessageFromHub(result);
    }

    return result;
  }