Skip to content

Commit

Permalink
We go again.
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl committed Dec 11, 2023
1 parent 6d6c539 commit b547121
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/main/java/io/github/townyadvanced/flagwar/FlagWar.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@ public class FlagWar extends JavaPlugin {
/** Holds instance of the {@link OutlawListener}. */
private OutlawListener outlawListener;

/**
* Initializes the Scheduler object based on whether we're using Folia/Paper or Spigot/Bukkit.
*/
public FlagWar() {
this.scheduler = townyVersionCheck() ? isFoliaClassPresent() ? new FoliaTaskScheduler(this) : new BukkitTaskScheduler(this) : null;
this.scheduler = townyVersionCheck() ? isFoliaClassPresent() ?
new FoliaTaskScheduler(this) : new BukkitTaskScheduler(this) : null;
}

/**
* Operations to perform when called by {@link org.bukkit.plugin.PluginLoader#enablePlugin(Plugin)}.
*/
Expand Down Expand Up @@ -834,6 +839,10 @@ public static void townFlagged(final Town town) {
}
}

/**
* Used to get the Scheduler whether it is Folia or Bukkit based.
* @return a TaskScheduler suitable for the server implementation.
*/
public TaskScheduler getScheduler() {
return (TaskScheduler) this.scheduler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class CellUnderAttack extends Cell {
private List<Block> beaconWireframeBlocks;
/** 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. */
/** A thread used to update the state of the {@link CellUnderAttack} using the Scheduler's repeating task.*/
private ScheduledTask thread;
/** A thread used to update the {@link #hologram}'s {@link #timerLine}. */
private BukkitTask hologramThread;
Expand Down Expand Up @@ -364,7 +364,8 @@ public void beginAttack() {
final int tps = 20;
final int milliTicks = 50;
final long ticksFromMs = this.flagPhaseDuration.toMillis() / milliTicks;
thread = FlagWar.getFlagWar().getScheduler().runRepeating(() -> new CellAttackThread(this), ticksFromMs, ticksFromMs);
thread = FlagWar.getFlagWar().getScheduler()
.runRepeating(() -> new CellAttackThread(this), ticksFromMs, ticksFromMs);
if (FlagWarConfig.isHologramEnabled()) {
drawHologram();
if (FlagWarConfig.hasTimerLine()) {
Expand Down

0 comments on commit b547121

Please sign in to comment.