Exemplo n.º 1
0
  /** Stops the display of the warning messages. */
  public void cancelWarning() {
    if (warningTask != null) {
      try {
        warningTask.cancel();
      } catch (IllegalStateException e) {

      }
    }

    UHTimer timer = getWarningTimer();
    if (timer != null) {
      timer.stop();
      p.getTimerManager().unregisterTimer(timer);
    }
  }
Exemplo n.º 2
0
  /**
   * Sets the size of the future border, used in the warning messages sent to the players out of
   * this future border.
   *
   * <p>This also starts the display of the warning messages, every 90 seconds by default
   * (configurable, see config.yml, map.border.warningInterval).
   *
   * <p>If timeLeft is not null, the time available for the players to go inside the future border
   * is displayed in the warning message.
   *
   * @param diameter
   * @param timeLeft The time available for the players to go inside the future border (minutes).
   */
  public void setWarningSize(int diameter, int timeLeft, CommandSender sender) {
    cancelWarning();

    this.warningSize = diameter;

    if (timeLeft != 0) {
      UHTimer timer = new UHTimer(this.warningTimerName);
      timer.setDuration(timeLeft * 60);

      p.getTimerManager().registerTimer(timer);

      timer.start();
    }

    if (sender != null) {
      this.warningSender = sender;
    }

    warningTask = new BorderWarningTask(p);
    warningTask.runTaskTimer(p, 20L, 20L * p.getConfig().getInt("map.border.warningInterval", 90));
  }