Allow setting a time when it should poll again

This commit is contained in:
Shaun Bennett 2014-08-17 17:53:38 -05:00
parent 43fd604695
commit 6e9d2b3244
2 changed files with 15 additions and 6 deletions

View File

@ -13,7 +13,7 @@ public class PlayerPollData
private static long POLL_COOLDOWN = 10000;
private Poll _currentPoll;
private long _lastPollTime;
private long _nextPollTime;
private Queue<Poll> _pollQueue;
private NautHashMap<Integer, Integer> _pollAnswers;
@ -50,17 +50,22 @@ public class PlayerPollData
public void setLastPollTime(long lastPollTime)
{
_lastPollTime = lastPollTime;
_nextPollTime = lastPollTime + POLL_COOLDOWN;
}
public long getLastPollTime()
public void setNextPollTime(long nextPollTime)
{
return _lastPollTime;
_nextPollTime = nextPollTime;
}
public long getNextPollTime()
{
return _nextPollTime;
}
public boolean shouldPoll()
{
return System.currentTimeMillis() - _lastPollTime > POLL_COOLDOWN;
return System.currentTimeMillis() - _nextPollTime > 0;
}
public synchronized Queue<Poll> getPollQueue()

View File

@ -36,8 +36,12 @@ public class PollCommand extends CommandBase<PollManager>
if (args[0].equalsIgnoreCase("exit") && currentPoll != null)
{
// Add the current poll to end of queue
pollData.getPollQueue().add(currentPoll);
pollData.setCurrentPoll(null);
pollData.setLastPollTime(System.currentTimeMillis());
// Don't poll again for 3 minutes
pollData.setNextPollTime(System.currentTimeMillis() + 180000);
UtilPlayer.message(caller, F.main("Poll", "Poll cancelled!"));
return;
}