mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 17:51:16 +00:00
Fix: timer is already cancelled.
This commit is contained in:
parent
9020ee5b2a
commit
eab964de5c
@ -29,9 +29,7 @@ public class StaminaManager {
|
|||||||
private Position previousCoordinates = new Position(0, 0, 0);
|
private Position previousCoordinates = new Position(0, 0, 0);
|
||||||
private MotionState currentState = MotionState.MOTION_STANDBY;
|
private MotionState currentState = MotionState.MOTION_STANDBY;
|
||||||
private MotionState previousState = MotionState.MOTION_STANDBY;
|
private MotionState previousState = MotionState.MOTION_STANDBY;
|
||||||
private final Timer sustainedStaminaHandlerTimer = new Timer();
|
private Timer sustainedStaminaHandlerTimer;
|
||||||
private final SustainedStaminaHandler handleSustainedStamina = new SustainedStaminaHandler();
|
|
||||||
private boolean timerRunning = false;
|
|
||||||
private GameSession cachedSession = null;
|
private GameSession cachedSession = null;
|
||||||
private GameEntity cachedEntity = null;
|
private GameEntity cachedEntity = null;
|
||||||
private int staminaRecoverDelay = 0;
|
private int staminaRecoverDelay = 0;
|
||||||
@ -140,17 +138,17 @@ public class StaminaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startSustainedStaminaHandler() {
|
public void startSustainedStaminaHandler() {
|
||||||
if (!player.isPaused() && !timerRunning) {
|
if (!player.isPaused() && sustainedStaminaHandlerTimer == null) {
|
||||||
timerRunning = true;
|
sustainedStaminaHandlerTimer = new Timer();
|
||||||
sustainedStaminaHandlerTimer.scheduleAtFixedRate(handleSustainedStamina, 0, 200);
|
sustainedStaminaHandlerTimer.scheduleAtFixedRate(new SustainedStaminaHandler(), 0, 200);
|
||||||
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer started");
|
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer started");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSustainedStaminaHandler() {
|
public void stopSustainedStaminaHandler() {
|
||||||
if (timerRunning) {
|
if (sustainedStaminaHandlerTimer != null) {
|
||||||
timerRunning = false;
|
|
||||||
sustainedStaminaHandlerTimer.cancel();
|
sustainedStaminaHandlerTimer.cancel();
|
||||||
|
sustainedStaminaHandlerTimer = null;
|
||||||
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped");
|
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user