Skip to content

Commit

Permalink
fix: fallback pausing/resuming to normal callbacks
Browse files Browse the repository at this point in the history
i, like, blacked out and forgot these existed or something
  • Loading branch information
qixils committed Feb 29, 2024
1 parent 561289a commit 4da5fff
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pojos/src/main/java/dev/qixils/crowdcontrol/TimedEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ public void pause() throws IllegalStateException { // TODO: change to boolean re

future.cancel(false);

if (pauseCallback != null) {
Consumer<TimedEffect> callback = pauseCallback != null ? pauseCallback : completionCallback;
if (callback != null) {
try {
pauseCallback.accept(this);
callback.accept(this);
} catch (Exception e) {
logger.error("Exception occurred during pause callback", e);
}
Expand All @@ -381,12 +382,11 @@ public void resume() throws IllegalStateException {
if (startedAt == -1)
throw new IllegalStateException("Effect has not started");

if (resumeCallback != null) {
try {
resumeCallback.accept(this);
} catch (Exception e) {
logger.error("Exception occurred during resume callback", e);
}
Consumer<TimedEffect> callback = resumeCallback != null ? resumeCallback : this.callback::apply;
try {
callback.accept(this);
} catch (Exception e) {
logger.error("Exception occurred during resume callback", e);
}

paused = false;
Expand Down

0 comments on commit 4da5fff

Please sign in to comment.