Revert "feat: use ChronoUnit for cloop (forever cloop now real!!!)"
This reverts commit 04a8d10e1f
.
This commit is contained in:
parent
04a8d10e1f
commit
52130e85ae
4 changed files with 8 additions and 9 deletions
build-number.txt
src/main/java/me/chayapak1/chomens_bot
|
@ -1 +1 @@
|
|||
1916
|
||||
1913
|
|
@ -11,16 +11,16 @@ import net.kyori.adventure.text.Component;
|
|||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CloopCommand extends Command {
|
||||
public CloopCommand () {
|
||||
super(
|
||||
"cloop",
|
||||
"Loops commands",
|
||||
new String[] { "add <interval> <ChronoUnit> <command>", "remove <index>", "clear", "list" },
|
||||
new String[] { "add <interval> <TimeUnit> <command>", "remove <index>", "clear", "list" },
|
||||
new String[] { "commandloop" },
|
||||
TrustLevel.TRUSTED,
|
||||
false
|
||||
|
@ -38,7 +38,7 @@ public class CloopCommand extends Command {
|
|||
int interval = context.getInteger(true);
|
||||
if (interval < 1) interval = 1;
|
||||
|
||||
final ChronoUnit unit = context.getEnum(ChronoUnit.class);
|
||||
final TimeUnit unit = context.getEnum(TimeUnit.class);
|
||||
|
||||
final String command = context.getString(true, true);
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package me.chayapak1.chomens_bot.data.cloop;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public record CommandLoop (
|
||||
String command,
|
||||
int interval,
|
||||
ChronoUnit unit
|
||||
TimeUnit unit
|
||||
) {}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package me.chayapak1.chomens_bot.plugins;
|
|||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.data.cloop.CommandLoop;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
@ -19,11 +18,11 @@ public class CloopPlugin {
|
|||
this.bot = bot;
|
||||
}
|
||||
|
||||
public void add (ChronoUnit unit, int interval, String command) {
|
||||
public void add (TimeUnit unit, int interval, String command) {
|
||||
Runnable loopTask = () -> bot.core.run(command);
|
||||
|
||||
loops.add(new CommandLoop(command, interval, unit));
|
||||
loopTasks.add(bot.executor.scheduleAtFixedRate(loopTask, 0, interval, TimeUnit.of(unit)));
|
||||
loopTasks.add(bot.executor.scheduleAtFixedRate(loopTask, 0, interval, unit));
|
||||
}
|
||||
|
||||
public CommandLoop remove (int index) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue