Skip to content

Commit

Permalink
Fix/cell attack thread not running (#334)
Browse files Browse the repository at this point in the history
* Fix flag scheduler not running properly.

* Update pom and changelog for release
  • Loading branch information
LlmDl authored Jan 15, 2024
1 parent dd10ee8 commit a502ea4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ If a change is missing, it is likely simple or was forgotten about when this log
Feel free to PR corrections to this file.

<!-- ## [Unreleased][Unreleased]-->
## [0.6.1][0.6.1]

### Added

* None.

### Changed

* Bump com.github.spotbugs:spotbugs-annotations from 4.7.3 to 4.8.3
* Bump org.apache.maven.plugins:maven-checkstyle-plugin from 3.3.0 to 3.3.1
* Bump com.puppycrawl.tools:checkstyle from 10.12.4 to 10.12.7
* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.2.5
* Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.1.2 to 3.2.5

### Fixed

- Fix scheduler not running properly for flags.

### Removed

- None

## [0.6.0][0.6.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.townyadvanced.flagwar</groupId>
<artifactId>FlagWar</artifactId>
<packaging>jar</packaging>
<version>0.6.0</version>
<version>0.6.1</version>
<description>An OG war system for TownyAdvanced. Celebrating a decade of Flag-based Towny Warfare.</description>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public FlagWarCustomListener(final FlagWar flagWar) {
* {@link FlagWar#registerAttack(CellUnderAttack)} using the cell from the CellAttackEvent.
* @param cellAttackEvent the associated CellAttackEvent.
*/
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@SuppressWarnings("unused")
public void onCellAttackEvent(final CellAttackEvent cellAttackEvent) {
if (cellAttackEvent.isCancelled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand Down Expand Up @@ -69,9 +68,9 @@ public class CellUnderAttack extends Cell {
/** Identifies the phase the war flag is in. **/
private int flagPhaseID;
/** A thread used to update the state of the {@link CellUnderAttack} using the Scheduler's repeating task.*/
private ScheduledTask thread;
private CellAttackThread thread;
/** A thread used to update the {@link #hologram}'s {@link #timerLine}. */
private ScheduledTask hologramThread;
private HologramUpdateThread hologramThread;
/** Holds the war flag hologram. */
private Hologram hologram;
/** Holds the time, in seconds, assuming 20 ticks is 1 second, of the war flag. */
Expand Down Expand Up @@ -99,6 +98,8 @@ public CellUnderAttack(final String flagOwner, final Block base, final Duration
this.flagLightBlock = world.getBlockAt(base.getX(), base.getY() + 2, base.getZ());

this.flagPhaseDuration = timerPhase;
this.thread = new CellAttackThread(this);
this.hologramThread = new HologramUpdateThread(this);
}

/** @return if {@link CellUnderAttack} equals a given {@link Object}. (Defers to {@link Cell#equals(Object)}.) */
Expand Down Expand Up @@ -360,11 +361,11 @@ public void beginAttack() {
final int tps = 20;
final int milliTicks = 50;
final long ticksFromMs = this.flagPhaseDuration.toMillis() / milliTicks;
thread = scheduler.runRepeating(() -> new CellAttackThread(this), ticksFromMs, ticksFromMs);
scheduler.runRepeating(() -> thread.run(), ticksFromMs, ticksFromMs);
if (FlagWarConfig.isHologramEnabled()) {
drawHologram();
if (FlagWarConfig.hasTimerLine()) {
hologramThread = scheduler.runRepeating(() -> new HologramUpdateThread(this), tps, tps);
scheduler.runRepeating(() -> hologramThread.run(), tps, tps);
}
}
}
Expand Down

0 comments on commit a502ea4

Please sign in to comment.