forked from foncused/LongerDays
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b2d76e
commit 121a6cd
Showing
4 changed files
with
93 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/net/pupskuchen/timecontrol/nightskipping/NightSkipScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.pupskuchen.timecontrol.nightskipping; | ||
|
||
import org.bukkit.scheduler.BukkitRunnable; | ||
import org.bukkit.scheduler.BukkitTask; | ||
import net.pupskuchen.timecontrol.TimeControl; | ||
|
||
class SkipAttempt extends BukkitRunnable { | ||
private final NightSkipper skipper; | ||
|
||
public SkipAttempt(final NightSkipper skipper) { | ||
this.skipper = skipper; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
this.skipper.skipNight(); | ||
} | ||
} | ||
|
||
|
||
class NightSkipScheduler { | ||
private final TimeControl plugin; | ||
private final NightSkipper skipper; | ||
private final int sleepTicksToWake; | ||
|
||
private BukkitTask skipTask; | ||
|
||
public NightSkipScheduler(final TimeControl plugin, final NightSkipper skipper, | ||
final int sleepTicksToWake) { | ||
this.plugin = plugin; | ||
this.skipper = skipper; | ||
this.sleepTicksToWake = sleepTicksToWake; | ||
} | ||
|
||
public void scheduleSkip() { | ||
this.cancel(); | ||
skipTask = new SkipAttempt(skipper).runTaskLater(plugin, sleepTicksToWake); | ||
} | ||
|
||
public void cancel() { | ||
if (skipTask == null) { | ||
return; | ||
} | ||
|
||
skipTask.cancel(); | ||
skipTask = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: ${project.name} | ||
main: net.pupskuchen.timecontrol.TimeControl | ||
version: ${project.version} | ||
api-version: 1.15 | ||
api-version: 1.14 | ||
author: pupskuchen | ||
website: https://github.com/Pupskuchen/spigot-TimeControl | ||
load: STARTUP |