mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 02:31:27 +00:00
Fix null reference on stamina timer when paused player disconnects.
This commit is contained in:
parent
04a58d43d5
commit
8ddd7b125d
@ -29,19 +29,16 @@ 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 Timer sustainedStaminaHandlerTimer;
|
private final Timer sustainedStaminaHandlerTimer = new Timer();
|
||||||
|
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;
|
||||||
private boolean isInSkillMove = false;
|
private boolean isInSkillMove = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getIsInSkillMove() {
|
public boolean getIsInSkillMove() {
|
||||||
return isInSkillMove;
|
return isInSkillMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsInSkillMove(boolean b) {
|
public void setIsInSkillMove(boolean b) {
|
||||||
isInSkillMove = b;
|
isInSkillMove = b;
|
||||||
}
|
}
|
||||||
@ -143,20 +140,19 @@ public class StaminaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startSustainedStaminaHandler() {
|
public void startSustainedStaminaHandler() {
|
||||||
if (!player.isPaused()) {
|
if (!player.isPaused() && !timerRunning) {
|
||||||
if (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() {
|
||||||
Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped");
|
if (timerRunning) {
|
||||||
|
timerRunning = false;
|
||||||
sustainedStaminaHandlerTimer.cancel();
|
sustainedStaminaHandlerTimer.cancel();
|
||||||
sustainedStaminaHandlerTimer = null;
|
// Grasscutter.getLogger().debug("[MovementManager] SustainedStaminaHandlerTimer stopped");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
|
@ -872,11 +872,11 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
staminaManager.stopSustainedStaminaHandler();
|
getStaminaManager().stopSustainedStaminaHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUnpause() {
|
public void onUnpause() {
|
||||||
staminaManager.startSustainedStaminaHandler();
|
getStaminaManager().startSustainedStaminaHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPacket(BasePacket packet) {
|
public void sendPacket(BasePacket packet) {
|
||||||
|
Loading…
Reference in New Issue
Block a user