fixed bug in teamtasks
This commit is contained in:
@ -91,7 +91,7 @@ public class Countdown {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
private boolean isDone() {
|
||||
return this.current <= 0;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,6 @@ public class ProjectStart extends Appliance {
|
||||
private final Map<GameRule<Boolean>, Boolean> gameRulesAfterStart = Map.ofEntries(
|
||||
entry(GameRule.DO_DAYLIGHT_CYCLE, true),
|
||||
entry(GameRule.DO_INSOMNIA, true),
|
||||
entry(GameRule.ANNOUNCE_ADVANCEMENTS, true),
|
||||
entry(GameRule.DISABLE_RAIDS, false),
|
||||
entry(GameRule.DO_FIRE_TICK, true),
|
||||
entry(GameRule.DO_ENTITY_DROPS, true),
|
||||
|
@ -2,5 +2,5 @@ package eu.mhsl.craftattack.spawn.varo.appliances.internal.teamTasks;
|
||||
|
||||
public interface Task {
|
||||
void stopTask();
|
||||
boolean isRunning();
|
||||
boolean isTaskRunning();
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ public abstract class BukkitTeamTask implements Task, BukkitTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
public boolean isTaskRunning() {
|
||||
return !this.isCancelled();
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class CountdownTeamTask extends Countdown implements Task {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !super.isDone();
|
||||
public boolean isTaskRunning() {
|
||||
return super.isRunning();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user