private void setTick(Info info, String time) { int addon = 0; try { addon = Integer.parseInt(time); } catch (NumberFormatException e) { info.sendMessage( "Format exception. Command should be !setTick # where # is the number of minutes till the next tick."); } tickSetter = info.getSender(); tickTime = System.currentTimeMillis(); OFFSET = (Utils.getRealMinutes(info) + addon) % 15; info.sendMessage("Tick set to " + OFFSET + " minutes off."); }
private void tick(Info info) { if (Utils.shouldDefer(info)) return; // else if (OFFSET == -1) { info.sendMessage( "Tick not sychronized yet. Wait for the next tick and execute /msg " + info.getBot().getName() + " !setTickor find out how long until the next tick and execute /msg " + info.getBot().getName() + " !setTick <mins>"); return; } int timeRemaining = 15 - ((15 + Utils.getRealMinutes(info) - OFFSET) % 15); long daysSinceSet = (System.currentTimeMillis() - tickTime) / (1000 * 60 * 60 * 24); info.sendMessage( timeRemaining + " minutes until the next tick (last set " + daysSinceSet + " days ago)"); }
private void tickAlarm(Info info) { if (OFFSET == -1) { info.sendMessage( "Tick not sychronized yet. Wait for the next tick and execute /msg " + info.getBot().getName() + " !setTick or find out how long until the next tick and execute /msg " + info.getBot().getName() + " !setTick <mins>"); return; } int timeRemaining = 15 - ((15 + Utils.getRealMinutes(info) - OFFSET) % 15); if (timeRemaining < 2) { info.sendMessage(Colors.BLUE + Colors.BOLD + "The tick is in " + timeRemaining + " minutes."); } else { PingTask ptask = new PingTask(info, "the tick is in one minute."); timer.schedule(ptask, (int) ((timeRemaining - 1) * 60 * 1000)); info.sendMessage("I'll alert you."); } }
private void setTick(Info info) { tickSetter = info.getSender(); tickTime = System.currentTimeMillis(); OFFSET = Utils.getRealMinutes(info) % 15; info.sendMessage("Tick set to " + OFFSET + " minutes off."); }