Commit 5d917f18 authored by gentlespoon's avatar gentlespoon Committed by Melledy
Browse files

Move "if Grasscutter.getConfig().OpenStamina" to the correct place.

parent eb2b2392
...@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment