Skip to content

Commit

Permalink
Added GameStateEndEvent call in GameStateTimer (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKaVu committed May 24, 2023
1 parent 6cc891a commit 828abaf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/dev/kavu/gameapi/GameStateTimer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.kavu.gameapi;

import dev.kavu.gameapi.event.GameStateEndEvent;
import org.bukkit.plugin.Plugin;

import java.util.Timer;
Expand Down Expand Up @@ -123,9 +124,10 @@ private boolean shouldCancel(){
boolean timerOvercount = (timerReversed ? (stateTime <= 0) : (stateTime >= currentState.getDuration())) && currentState.getDuration() >= 0;

if (timerOvercount || currentState.shouldEnd()) {
plugin.getServer().getPluginManager().callEvent(new GameStateEndEvent(this, currentState, schedule != null ? schedule.next() : null));
currentState.onEnd();
if(schedule != null){
initialize(schedule.next());
initialize(schedule.getCurrent());
}
return true;
}
Expand Down

0 comments on commit 828abaf

Please sign in to comment.