refactor: make cloop remove return command name
This commit is contained in:
parent
627b18ebf9
commit
159cb8ce11
2 changed files with 6 additions and 7 deletions
|
@ -52,11 +52,12 @@ public class CloopCommand extends Command {
|
|||
|
||||
try {
|
||||
final int index = context.getInteger(true);
|
||||
bot.cloop.remove(index);
|
||||
|
||||
final CommandLoop cloop = bot.cloop.remove(index);
|
||||
|
||||
return Component.translatable(
|
||||
"Removed cloop %s",
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
Component.text(cloop.command()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
|
||||
throw new CommandException(Component.text("Invalid index"));
|
||||
|
@ -96,9 +97,7 @@ public class CloopCommand extends Command {
|
|||
Component.join(JoinConfiguration.newlines(), cloopsComponent)
|
||||
);
|
||||
}
|
||||
default -> {
|
||||
throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
default -> throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ public class CloopPlugin {
|
|||
loopTasks.add(bot.executor.scheduleAtFixedRate(loopTask, 0, interval, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public void remove (int index) {
|
||||
public CommandLoop remove (int index) {
|
||||
ScheduledFuture<?> loopTask = loopTasks.remove(index);
|
||||
|
||||
if (loopTask != null) {
|
||||
loopTask.cancel(true);
|
||||
}
|
||||
|
||||
loops.remove(index);
|
||||
return loops.remove(index);
|
||||
}
|
||||
|
||||
public void clear () {
|
||||
|
|
Loading…
Reference in a new issue