diff --git a/CHANGELOG.md b/CHANGELOG.md
index 714229a9..1684faf3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,24 @@ If a change is missing, it is likely simple or was forgotten about when this log
Feel free to PR corrections to this file.
+## [0.6.2][0.6.2]
+
+### Added
+
+* None.
+
+### Changed
+
+* None.
+
+### Fixed
+
+- Fix attacks tasks not being cancelled correctly.
+
+### Removed
+
+- None
+
## [0.6.1][0.6.1]
### Added
diff --git a/pom.xml b/pom.xml
index 29f08da7..8b709cb7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
io.github.townyadvanced.flagwar
FlagWar
jar
- 0.6.1
+ 0.6.2
An OG war system for TownyAdvanced. Celebrating a decade of Flag-based Towny Warfare.
diff --git a/src/main/java/io/github/townyadvanced/flagwar/objects/CellUnderAttack.java b/src/main/java/io/github/townyadvanced/flagwar/objects/CellUnderAttack.java
index 5ec7aacc..4691236b 100644
--- a/src/main/java/io/github/townyadvanced/flagwar/objects/CellUnderAttack.java
+++ b/src/main/java/io/github/townyadvanced/flagwar/objects/CellUnderAttack.java
@@ -21,6 +21,7 @@
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
import com.palmergames.bukkit.towny.object.Coord;
+import com.palmergames.bukkit.towny.scheduling.ScheduledTask;
import com.palmergames.bukkit.towny.scheduling.TaskScheduler;
import io.github.townyadvanced.flagwar.CellAttackThread;
@@ -69,8 +70,12 @@ public class CellUnderAttack extends Cell {
private int flagPhaseID;
/** A thread used to update the state of the {@link CellUnderAttack} using the Scheduler's repeating task.*/
private CellAttackThread thread;
+ /** A task used to the thread used to cancel the repeating task.*/
+ private ScheduledTask threadTask;
/** A thread used to update the {@link #hologram}'s {@link #timerLine}. */
private HologramUpdateThread hologramThread;
+ /** A task used to the hologramThread used to cancel the repeating task.*/
+ private ScheduledTask hologramTask;
/** Holds the war flag hologram. */
private Hologram hologram;
/** Holds the time, in seconds, assuming 20 ticks is 1 second, of the war flag. */
@@ -361,11 +366,11 @@ public void beginAttack() {
final int tps = 20;
final int milliTicks = 50;
final long ticksFromMs = this.flagPhaseDuration.toMillis() / milliTicks;
- scheduler.runRepeating(() -> thread.run(), ticksFromMs, ticksFromMs);
+ threadTask = scheduler.runRepeating(() -> thread.run(), ticksFromMs, ticksFromMs);
if (FlagWarConfig.isHologramEnabled()) {
drawHologram();
if (FlagWarConfig.hasTimerLine()) {
- scheduler.runRepeating(() -> hologramThread.run(), tps, tps);
+ hologramTask = scheduler.runRepeating(() -> hologramThread.run(), tps, tps);
}
}
}
@@ -376,11 +381,11 @@ public void beginAttack() {
* exists, using {@link #destroyHologram()}.
*/
public void cancel() {
- if (thread != null) {
- thread.cancel();
+ if (threadTask != null) {
+ threadTask.cancel();
}
- if (FlagWarConfig.isHologramEnabled() && hologramThread != null) {
- hologramThread.cancel();
+ if (FlagWarConfig.isHologramEnabled() && hologramTask != null) {
+ hologramTask.cancel();
}
destroyFlag();
if (hologram != null) {