Пример #1
0
  /** Removes votes of players who have left. */
  public void handleEvent(PlayerLeft event) {
    if (!isEnabled) return;

    if (tasks.size() == 0) return;

    Player p = m_botAction.getPlayer(event.getPlayerID());

    if (p == null) return;

    for (int i = 0; i < tasks.size(); i++) {
      AutoTask c = tasks.get(i);

      if (c != null) c.removeVote(p.getPlayerName());
    }
  }
Пример #2
0
  /**
   * Removes a command.
   *
   * @param name Name of op
   * @param msg Command parameters
   */
  public void cmdRemove(String name, String msg) {
    try {
      int num = Integer.parseInt(msg);
      AutoTask c = tasks.remove(num - 1);

      if (c != null) {
        m_botAction.sendSmartPrivateMessage(
            name, "Removed command: " + c.getCommand() + "  (" + c.getDisplay() + ")");
      } else {
        m_botAction.sendSmartPrivateMessage(
            name, "Couldn't find that number.  Use !list to verify.");
      }
    } catch (Exception e) {
      m_botAction.sendSmartPrivateMessage(
          name, "Couldn't parse that.  Do !list to verify your number.  Ex: !remove 1");
    }
  }
Пример #3
0
  /**
   * Default command. Checks for players voting for tasks, and executes the task if enough votes
   * have been reached.
   *
   * @param name Name of player
   * @param msg Command parameters
   */
  public void cmdDefault(String name, String msg) {
    if (!isEnabled || tasks.size() == 0 || !msg.startsWith("!task")) return;

    try {
      int num = Integer.parseInt(msg.substring(5).trim()) - 1;
      AutoTask c = tasks.get(num);
      String execute = c.doVote(name);

      // Execute if number of votes have been reached
      if (execute != null) {
        if (execute.contains(",")) {
          String cmds[] = execute.split(",");

          for (int i = 0; i < cmds.length; i++) {
            if (cmds[i].startsWith("-arena")) {
              String[] args = cmds[i].split(" ", 2);

              if (args.length == 2)
                m_botAction.sendArenaMessage(args[1] + " -" + m_botAction.getBotName());
            } else if (cmds[i].startsWith("-wait")) {
              String[] args = cmds[i].split(" ", 2);

              if (args.length == 2) {
                try {
                  Integer wait = Integer.getInteger(args[1]);

                  if (wait <= 60) this.wait(wait * 1000);
                } catch (Exception e) {
                }
              }
            } else {
              m_botAction.sendPrivateMessage(m_botAction.getBotName(), "!" + cmds[i]);
            }
          }
        } else {
          m_botAction.sendPrivateMessage(m_botAction.getBotName(), "!" + execute);
        }
      }
    } catch (Exception e) {
      m_botAction.sendSmartPrivateMessage(
          name,
          "Which task do you want to vote for?  Please try !info to verify this task still exists.");
    }
  }
Пример #4
0
  /**
   * Lists all commands.
   *
   * @param name Name of op
   */
  public void cmdList(String name) {
    if (tasks.size() == 0) {
      m_botAction.sendSmartPrivateMessage(name, "No commands entered yet.");
      return;
    }

    for (int i = 0; i < tasks.size(); i++) {
      AutoTask c = tasks.get(i);

      if (c != null)
        m_botAction.sendSmartPrivateMessage(
            name,
            (i + 1)
                + ") '"
                + c.getCommand()
                + "'  Votes: "
                + c.getVotes()
                + " of "
                + c.getVotesReq()
                + " needed.  Text: "
                + c.getDisplay());
    }
  }
Пример #5
0
  /**
   * Displays list of commands available to players.
   *
   * @param name Name of player
   */
  public void cmdInfo(String name) {
    if (!isEnabled) {
      m_botAction.sendSmartPrivateMessage(
          name, "Autopilot is not currently enabled.  Please hang up and try again later.");
      return;
    }

    m_botAction.sendSmartPrivateMessage(
        name, "Autopilot - The automated event host controlled by players.");
    m_botAction.sendSmartPrivateMessage(
        name, "If you wish for the bot to run one of the following tasks, send the command");
    m_botAction.sendSmartPrivateMessage(
        name, "next to it (!task#).  Your vote will be counted.  When enough votes have been");
    m_botAction.sendSmartPrivateMessage(
        name, "reached, the task will run.  If you leave the arena all your votes are removed.");

    m_botAction.sendSmartPrivateMessage(name, "List of tasks available to run:");

    if (tasks.size() == 0)
      m_botAction.sendSmartPrivateMessage(name, "No tasks have been entered yet.");

    for (int i = 0; i < tasks.size(); i++) {
      AutoTask c = tasks.get(i);

      if (c != null)
        m_botAction.sendSmartPrivateMessage(
            name,
            "!task"
                + (i + 1)
                + " ("
                + c.getVotes()
                + " of "
                + c.getVotesReq()
                + " votes needed)  "
                + c.getDisplay());
    }
  }