Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
a09723f0
Commit
a09723f0
authored
May 08, 2022
by
gentlespoon
Committed by
Melledy
May 08, 2022
Browse files
Fix: timer is already cancelled.
parent
7c35c51a
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java
View file @
a09723f0
...
@@ -29,9 +29,7 @@ public class StaminaManager {
...
@@ -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
;
...
@@ -136,21 +134,21 @@ public class StaminaManager {
...
@@ -136,21 +134,21 @@ public class StaminaManager {
entity
.
getWorld
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
entity
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
entity
.
getWorld
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
entity
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
entity
.
getWorld
().
broadcastPacket
(
new
PacketLifeStateChangeNotify
(
0
,
entity
,
LifeState
.
LIFE_DEAD
));
entity
.
getWorld
().
broadcastPacket
(
new
PacketLifeStateChangeNotify
(
0
,
entity
,
LifeState
.
LIFE_DEAD
));
player
.
getScene
().
removeEntity
(
entity
);
player
.
getScene
().
removeEntity
(
entity
);
((
EntityAvatar
)
entity
).
onDeath
(
dieType
,
0
);
((
EntityAvatar
)
entity
).
onDeath
(
dieType
,
0
);
}
}
public
void
startSustainedStaminaHandler
()
{
public
void
startSustainedStaminaHandler
()
{
if
(!
player
.
isPaused
()
&&
!
timerRunning
)
{
if
(!
player
.
isPaused
()
&&
sustainedStaminaHandlerTimer
==
null
)
{
timerRunning
=
true
;
sustainedStaminaHandlerTimer
=
new
Timer
()
;
sustainedStaminaHandlerTimer
.
scheduleAtFixedRate
(
handle
SustainedStamina
,
0
,
200
);
sustainedStaminaHandlerTimer
.
scheduleAtFixedRate
(
new
SustainedStamina
Handler
()
,
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");
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment