/** 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); } }
/** * 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)); }
/** * Returns the UHTimer object representing the countdown before the next border reduction. * * <p>Returns null if there isn't any countdown running currently. * * @return The timer. */ public UHTimer getWarningTimer() { return p.getTimerManager().getTimer(this.warningTimerName); }