fixed bug in teamtasks

This commit is contained in:
2025-06-21 17:55:52 +02:00
parent 0d1e6070ce
commit 427aed9a7e
6 changed files with 8 additions and 9 deletions

View File

@ -2,5 +2,5 @@ package eu.mhsl.craftattack.spawn.varo.appliances.internal.teamTasks;
public interface Task {
void stopTask();
boolean isRunning();
boolean isTaskRunning();
}

View File

@ -27,17 +27,17 @@ public class TeamTasks extends Appliance {
public Map<Type, Task> getRunningTeamTasks(VaroTeam team) {
return this.getTeamTasks(team).entrySet().stream()
.filter(entry -> entry.getValue().isRunning())
.filter(entry -> entry.getValue().isTaskRunning())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
public void cancelTeamTasks(VaroTeam team) {
Main.logger().info(String.format("All TeamTasks for Team %s were cancelled: %s", team.name, this.getRunningTeamTasks(team)));
this.getTeamTasks(team).forEach((type, bukkitTask) -> bukkitTask.stopTask());
this.getTeamTasks(team).forEach((type, task) -> task.stopTask());
}
public void addTask(VaroTeam team, Type type, Task runnable) {
if(this.getTeamTasks(team).containsKey(type) && this.getTeamTasks(team).get(type).isRunning()) {
if(this.getTeamTasks(team).containsKey(type) && this.getTeamTasks(team).get(type).isTaskRunning()) {
throw new IllegalStateException(String.format("Task %s for Team %s was already running!", type.name(), team.name));
}

View File

@ -10,7 +10,7 @@ public abstract class BukkitTeamTask implements Task, BukkitTask {
}
@Override
public boolean isRunning() {
public boolean isTaskRunning() {
return !this.isCancelled();
}
}

View File

@ -18,7 +18,7 @@ public class CountdownTeamTask extends Countdown implements Task {
}
@Override
public boolean isRunning() {
return !super.isDone();
public boolean isTaskRunning() {
return super.isRunning();
}
}