Make multiple small improvements
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2023-01-15 01:00:44 +01:00
parent fb752fb9a9
commit d6ef0da167
4 changed files with 13 additions and 11 deletions

View File

@ -217,7 +217,7 @@ public class Cache
public static long getExpiryTimeSeconds() { return expiryTimeSeconds; }
public static String getBotName() { return botName; };
public static String getBotName() { return botName; }
/**
* Get the bot's version.

View File

@ -192,13 +192,13 @@ public class HidekoBot
// start scheduled runnables
ScheduledExecutorService scheduler = Cache.getTaskScheduler();
ExpiredMessageTask expiredMessageTask = new ExpiredMessageTask();
scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds
scheduler.scheduleAtFixedRate(expiredMessageTask, 5L, 5L, TimeUnit.SECONDS); //every 5 seconds
HeartBeatTask heartBeatTask = new HeartBeatTask();
scheduler.scheduleAtFixedRate(heartBeatTask, 10, 30, TimeUnit.SECONDS); //every 30 seconds
scheduler.scheduleAtFixedRate(heartBeatTask, 10L, 30L, TimeUnit.SECONDS); //every 30 seconds
StatusUpdateTask statusUpdateTask = new StatusUpdateTask();
scheduler.scheduleAtFixedRate(statusUpdateTask, 0, 60 * 5, TimeUnit.SECONDS); // every 5 minutes
scheduler.scheduleAtFixedRate(statusUpdateTask, 0L, 60L * 5L, TimeUnit.SECONDS); // every 5 minutes
RandomSeedTask randomSeedTask = new RandomSeedTask();
scheduler.scheduleAtFixedRate(randomSeedTask, 0, 60, TimeUnit.SECONDS); // every minute
scheduler.scheduleAtFixedRate(randomSeedTask, 0L, 60L, TimeUnit.SECONDS); // every minute
// register shutdown interrupt signal listener for proper shutdown.
Signal.handle(new Signal("INT"), signal -> shutdown());

View File

@ -8,6 +8,7 @@ import wtf.beatrice.hidekobot.objects.fun.Dice;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.UUID;
public class DiceRoll
@ -15,8 +16,8 @@ public class DiceRoll
public static MessageResponse buildResponse(User author, String[] args)
{
LinkedHashMap<Dice, Integer> dicesToRoll = new LinkedHashMap<>();
String diceRegex = "d[0-9]+";
String amountRegex = "[0-9]+";
String diceRegex = "d\\d+";
String amountRegex = "\\d+";
Dice currentDice = null;
int currentAmount;
@ -106,9 +107,12 @@ public class DiceRoll
totalRolls = 1;
}
for(Dice dice : dicesToRoll.keySet())
for(Map.Entry<Dice, Integer> entry : dicesToRoll.entrySet())
{
for(int roll = 0; roll < dicesToRoll.get(dice); roll++)
Dice dice = entry.getKey();
Integer rollsToMake = entry.getValue();
for(int roll = 0; roll < rollsToMake; roll++)
{
dice.roll();
rolledDices.add(new Dice(dice));

View File

@ -11,8 +11,6 @@ import java.util.LinkedHashMap;
public class ConfigurationSource
{
private final LinkedHashMap<String, Object> configurationEntries = new LinkedHashMap<>();
private final Logger logger;
private final String configFilePath;