Skip to content

Commit

Permalink
fix: fix execute command behaviour with ordered task (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
titivermeesch committed Mar 18, 2024
1 parent dea9802 commit 2e7af0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.5.4'
version = '8.5.5'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -61,7 +61,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.5.4'
version = '8.5.5'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java8-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.5.4'
version = '8.5.5'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -69,7 +69,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.5.4'
version = '8.5.5'

from components.java
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/me/playbosswar/com/commands/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Date;

public class MainCommand implements CommandExecutor {
private final LanguageManager languageManager = CommandTimerPlugin.getLanguageManager();

Expand Down Expand Up @@ -125,6 +127,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
return true;
}

if(task.getCommandExecutionMode().equals(CommandExecutionMode.ORDERED)) {
final int[] accumulatedDelaySeconds = {0};
task.getCommands().forEach(command -> {
Bukkit.getScheduler().scheduleSyncDelayedTask(CommandTimerPlugin.getPlugin(),
() -> tasksManager.addTaskCommandExecution(command), 20L * accumulatedDelaySeconds[0]);
accumulatedDelaySeconds[0] += command.getDelay().toSeconds();
});
Messages.sendMessage(sender, languageManager.get(LanguageKey.TASK_EXECUTION_ONGOING));
return true;
}

int selectedCommandIndex = tasksManager.getNextTaskCommandIndex(task);
if(selectedCommandIndex == -1) {
task.getCommands().forEach(tasksManager::addTaskCommandExecution);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: me.playbosswar.com.CommandTimerPlugin
name: "CommandTimer"
version: "8.5.4"
version: "8.5.5"
description: "Schedule commands like you want"
author: PlayBossWar
api-version: 1.13
Expand Down

0 comments on commit 2e7af0f

Please sign in to comment.