diff --git a/src/main/java/wtf/beatrice/hidekobot/Cache.java b/src/main/java/wtf/beatrice/hidekobot/Cache.java index c43b87b..7d6346a 100644 --- a/src/main/java/wtf/beatrice/hidekobot/Cache.java +++ b/src/main/java/wtf/beatrice/hidekobot/Cache.java @@ -52,7 +52,7 @@ public class Cache private static LocalDateTime startupTime = null; // the scheduler that should always be used when running a scheduled task. - private final static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources + private final static ScheduledExecutorService taskScheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources private final static String execPath = System.getProperty("user.dir"); private static final String botName = "Hideko"; @@ -322,8 +322,8 @@ public class Cache loveCalculatorValues.remove(userId2 + "|" + userId1); } - public static ScheduledExecutorService getScheduler() { - return scheduler; + public static ScheduledExecutorService getTaskScheduler() { + return taskScheduler; } } diff --git a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java index b4ea2eb..2870cca 100644 --- a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java +++ b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java @@ -178,7 +178,7 @@ public class HidekoBot } // start scheduled runnables - ScheduledExecutorService scheduler = Cache.getScheduler(); + ScheduledExecutorService scheduler = Cache.getTaskScheduler(); ExpiredMessageTask expiredMessageTask = new ExpiredMessageTask(); scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds HeartBeatTask heartBeatTask = new HeartBeatTask(); diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/base/LoveCalculator.java b/src/main/java/wtf/beatrice/hidekobot/commands/base/LoveCalculator.java index b75d750..de47518 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/base/LoveCalculator.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/base/LoveCalculator.java @@ -20,7 +20,7 @@ public class LoveCalculator { loveAmount = RandomUtil.getRandomNumber(0, 100); Cache.cacheLoveCalculatorValue(userId1, userId2, loveAmount); - Cache.getScheduler().schedule(() -> + Cache.getTaskScheduler().schedule(() -> Cache.removeLoveCalculatorValue(userId1, userId2), 10, TimeUnit.MINUTES); }