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
5d917f18
Commit
5d917f18
authored
May 09, 2022
by
gentlespoon
Committed by
Melledy
May 09, 2022
Browse files
Move "if Grasscutter.getConfig().OpenStamina" to the correct place.
parent
eb2b2392
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java
View file @
5d917f18
...
@@ -190,14 +190,17 @@ public class StaminaManager {
...
@@ -190,14 +190,17 @@ public class StaminaManager {
// Returns new stamina and sends PlayerPropNotify
// Returns new stamina and sends PlayerPropNotify
public
int
setStamina
(
GameSession
session
,
String
reason
,
int
newStamina
)
{
public
int
setStamina
(
GameSession
session
,
String
reason
,
int
newStamina
)
{
// set stamina
if
(
Grasscutter
.
getConfig
().
OpenStamina
)
{
player
.
setProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
,
newStamina
);
// set stamina
session
.
send
(
new
PacketPlayerPropNotify
(
player
,
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
));
player
.
setProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
,
newStamina
);
// notify updated
session
.
send
(
new
PacketPlayerPropNotify
(
player
,
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
));
for
(
Map
.
Entry
<
String
,
AfterUpdateStaminaListener
>
listener
:
afterUpdateStaminaListeners
.
entrySet
())
{
// notify updated
listener
.
getValue
().
onAfterUpdateStamina
(
reason
,
newStamina
);
for
(
Map
.
Entry
<
String
,
AfterUpdateStaminaListener
>
listener
:
afterUpdateStaminaListeners
.
entrySet
())
{
listener
.
getValue
().
onAfterUpdateStamina
(
reason
,
newStamina
);
}
return
newStamina
;
}
}
return
newStamina
;
return
player
.
getProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
)
;
}
}
// Kills avatar, removes entity and sends notification.
// Kills avatar, removes entity and sends notification.
...
@@ -288,50 +291,48 @@ public class StaminaManager {
...
@@ -288,50 +291,48 @@ public class StaminaManager {
private
class
SustainedStaminaHandler
extends
TimerTask
{
private
class
SustainedStaminaHandler
extends
TimerTask
{
public
void
run
()
{
public
void
run
()
{
if
(
Grasscutter
.
getConfig
().
OpenStamina
)
{
boolean
moving
=
isPlayerMoving
();
boolean
moving
=
isPlayerMoving
();
int
currentStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
);
int
currentStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
);
int
maxStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_MAX_STAMINA
);
int
maxStamina
=
player
.
getProperty
(
PlayerProperty
.
PROP_MAX_STAMINA
);
if
(
moving
||
(
currentStamina
<
maxStamina
))
{
if
(
moving
||
(
currentStamina
<
maxStamina
))
{
Grasscutter
.
getLogger
().
trace
(
"Player moving: "
+
moving
+
", stamina full: "
+
Grasscutter
.
getLogger
().
trace
(
"Player moving: "
+
moving
+
", stamina full: "
+
(
currentStamina
>=
maxStamina
)
+
", recalculate stamina"
);
(
currentStamina
>=
maxStamina
)
+
", recalculate stamina"
);
Consumption
consumption
=
new
Consumption
(
ConsumptionType
.
None
);
Consumption
consumption
=
new
Consumption
(
ConsumptionType
.
None
);
if
(
MotionStatesCategorized
.
get
(
"CLIMB"
).
contains
(
currentState
))
{
if
(
MotionStatesCategorized
.
get
(
"CLIMB"
).
contains
(
currentState
))
{
consumption
=
getClimbSustainedConsumption
();
consumption
=
getClimbSustainedConsumption
();
}
else
if
(
MotionStatesCategorized
.
get
(
"SWIM"
).
contains
((
currentState
)))
{
}
else
if
(
MotionStatesCategorized
.
get
(
"SWIM"
).
contains
((
currentState
)))
{
consumption
=
getSwimSustainedConsumptions
();
consumption
=
getSwimSustainedConsumptions
();
}
else
if
(
MotionStatesCategorized
.
get
(
"RUN"
).
contains
(
currentState
))
{
}
else
if
(
MotionStatesCategorized
.
get
(
"RUN"
).
contains
(
currentState
))
{
consumption
=
getRunWalkDashSustainedConsumption
();
consumption
=
getRunWalkDashSustainedConsumption
();
}
else
if
(
MotionStatesCategorized
.
get
(
"FLY"
).
contains
(
currentState
))
{
}
else
if
(
MotionStatesCategorized
.
get
(
"FLY"
).
contains
(
currentState
))
{
consumption
=
getFlySustainedConsumption
();
consumption
=
getFlySustainedConsumption
();
}
else
if
(
MotionStatesCategorized
.
get
(
"STANDBY"
).
contains
(
currentState
))
{
}
else
if
(
MotionStatesCategorized
.
get
(
"STANDBY"
).
contains
(
currentState
))
{
consumption
=
getStandSustainedConsumption
();
consumption
=
getStandSustainedConsumption
();
}
}
/*
/*
TODO: Reductions that apply to all motion types:
TODO: Reductions that apply to all motion types:
Elemental Resonance
Elemental Resonance
Wind: -15%
Wind: -15%
Skills
Skills
Diona E: -10% while shield lasts
Diona E: -10% while shield lasts
Barbara E: -12% while lasts
Barbara E: -12% while lasts
*/
*/
if
(
cachedSession
!=
null
)
{
if
(
cachedSession
!=
null
)
{
if
(
consumption
.
amount
<
0
)
{
if
(
consumption
.
amount
<
0
)
{
staminaRecoverDelay
=
0
;
staminaRecoverDelay
=
0
;
}
}
if
(
consumption
.
amount
>
0
&&
consumption
.
consumptionType
!=
ConsumptionType
.
POWERED_FLY
)
{
if
(
consumption
.
amount
>
0
&&
consumption
.
consumptionType
!=
ConsumptionType
.
POWERED_FLY
)
{
// For POWERED_FLY recover immediately - things like Amber's gliding exam may require this.
// For POWERED_FLY recover immediately - things like Amber's gliding exam may require this.
if
(
staminaRecoverDelay
<
10
)
{
if
(
staminaRecoverDelay
<
10
)
{
// For others recover after 2 seconds (10 ticks) - as official server does.
// For others recover after 2 seconds (10 ticks) - as official server does.
staminaRecoverDelay
++;
staminaRecoverDelay
++;
consumption
.
amount
=
0
;
consumption
.
amount
=
0
;
Grasscutter
.
getLogger
().
trace
(
"[StaminaManager] Delaying recovery: "
+
staminaRecoverDelay
);
Grasscutter
.
getLogger
().
trace
(
"[StaminaManager] Delaying recovery: "
+
staminaRecoverDelay
);
}
}
}
updateStaminaRelative
(
cachedSession
,
consumption
);
}
}
updateStaminaRelative
(
cachedSession
,
consumption
);
}
}
}
}
previousState
=
currentState
;
previousState
=
currentState
;
...
...
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