Stats cleanup and finalizer improvements.

This commit is contained in:
MobiusDevelopment
2019-03-29 15:50:39 +00:00
parent 03f0eb0bcc
commit f89c360163
330 changed files with 957 additions and 957 deletions

View File

@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@@ -733,7 +733,7 @@ public class CreatureStat
public double getValue(Stats stat, double baseValue) public double getValue(Stats stat, double baseValue)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.of(baseValue)); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.of(baseValue));
} }
/** /**
@@ -743,7 +743,7 @@ public class CreatureStat
public double getValue(Stats stat) public double getValue(Stats stat)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.empty()); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.empty());
} }
protected void resetStats() protected void resetStats()
@@ -755,11 +755,11 @@ public class CreatureStat
// Initialize default values // Initialize default values
for (Stats stat : Stats.values()) for (Stats stat : Stats.values())
{ {
if (stat.getResetAddValue() != null) if (stat.getResetAddValue() != 0)
{ {
_statsAdd.put(stat, stat.getResetAddValue()); _statsAdd.put(stat, stat.getResetAddValue());
} }
if (stat.getResetMulValue() != null) if (stat.getResetMulValue() != 0)
{ {
_statsMul.put(stat, stat.getResetMulValue()); _statsMul.put(stat, stat.getResetMulValue());
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.PlayerCondOverride; import com.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
@FunctionalInterface @FunctionalInterface
public interface IStatsFunction public interface IStatsFunction
{ {
default void throwIfPresent(Optional<Double> base) default void throwIfPresent(OptionalDouble base)
{ {
if (base.isPresent()) if (base.isPresent())
{ {
@@ -312,5 +312,5 @@ public interface IStatsFunction
return Math.max(minValue, value); return Math.max(minValue, value);
} }
double calc(Creature creature, Optional<Double> base, Stats stat); double calc(Creature creature, OptionalDouble base, Stats stat);
} }

View File

@@ -17,8 +17,8 @@
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.function.BiFunction; import java.util.function.DoubleBinaryOperator;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
@@ -120,8 +120,8 @@ public enum Stats
CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"), CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"),
MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"), MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"),
SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()), SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()),
CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, 0, 1),
CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, 0, 1),
MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()), MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()),
BLOW_RATE("blowRate"), BLOW_RATE("blowRate"),
DEFENCE_CRITICAL_RATE("defCritRate"), DEFENCE_CRITICAL_RATE("defCritRate"),
@@ -286,10 +286,10 @@ public enum Stats
private final String _value; private final String _value;
private final IStatsFunction _valueFinalizer; private final IStatsFunction _valueFinalizer;
private final BiFunction<Double, Double, Double> _addFunction; private final DoubleBinaryOperator _addFunction;
private final BiFunction<Double, Double, Double> _mulFunction; private final DoubleBinaryOperator _mulFunction;
private final Double _resetAddValue; private final double _resetAddValue;
private final Double _resetMulValue; private final double _resetMulValue;
public String getValue() public String getValue()
{ {
@@ -298,16 +298,16 @@ public enum Stats
Stats(String xmlString) Stats(String xmlString)
{ {
this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, null, null); this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer) Stats(String xmlString, IStatsFunction valueFinalizer)
{ {
this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, null, null); this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer, BiFunction<Double, Double, Double> addFunction, BiFunction<Double, Double, Double> mulFunction, Double resetAddValue, Double resetMulValue) Stats(String xmlString, IStatsFunction valueFinalizer, DoubleBinaryOperator addFunction, DoubleBinaryOperator mulFunction, double resetAddValue, double resetMulValue)
{ {
_value = xmlString; _value = xmlString;
_valueFinalizer = valueFinalizer; _valueFinalizer = valueFinalizer;
@@ -336,7 +336,7 @@ public enum Stats
* @param baseValue * @param baseValue
* @return the final value * @return the final value
*/ */
public Double finalize(Creature creature, Optional<Double> baseValue) public double finalize(Creature creature, OptionalDouble baseValue)
{ {
try try
{ {
@@ -351,20 +351,20 @@ public enum Stats
public double functionAdd(double oldValue, double value) public double functionAdd(double oldValue, double value)
{ {
return _addFunction.apply(oldValue, value); return _addFunction.applyAsDouble(oldValue, value);
} }
public double functionMul(double oldValue, double value) public double functionMul(double oldValue, double value)
{ {
return _mulFunction.apply(oldValue, value); return _mulFunction.applyAsDouble(oldValue, value);
} }
public Double getResetAddValue() public double getResetAddValue()
{ {
return _resetAddValue; return _resetAddValue;
} }
public Double getResetMulValue() public double getResetMulValue()
{ {
return _resetMulValue; return _resetMulValue;
} }
@@ -374,17 +374,17 @@ public enum Stats
return stat._valueFinalizer.calcWeaponBaseValue(creature, stat); return stat._valueFinalizer.calcWeaponBaseValue(creature, stat);
} }
public static double defaultValue(Creature creature, Optional<Double> base, Stats stat) public static double defaultValue(Creature creature, OptionalDouble base, Stats stat)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return base.isPresent() ? defaultValue(creature, stat, base.get()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType())); return base.isPresent() ? defaultValue(creature, stat, base.getAsDouble()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
public static double defaultValue(Creature creature, Stats stat, double baseValue) public static double defaultValue(Creature creature, Stats stat, double baseValue)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()); return mul * (baseValue + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -41,7 +41,7 @@ public class AttributeFinalizer implements IStatsFunction
} }
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData; import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class BaseStatsFinalizer implements IStatsFunction public class BaseStatsFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAccuracyFinalizer implements IStatsFunction public class MAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackFinalizer implements IStatsFunction public class MAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
@@ -55,7 +55,7 @@ public class MAttackFinalizer implements IStatsFunction
// Calculate modifiers Magic Attack // Calculate modifiers Magic Attack
final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.; final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
final double intBonus = BaseStats.INT.calcBonus(creature); final double intBonus = BaseStats.INT.calcBonus(creature);
baseValue *= Math.pow(intBonus, 2) * Math.pow(creature.getLevelMod(), 2) * chaMod; baseValue *= intBonus * creature.getLevelMod() * chaMod;
return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK); return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK);
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackSpeedFinalizer implements IStatsFunction public class MAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MCritRateFinalizer implements IStatsFunction public class MCritRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -43,7 +43,7 @@ public class MDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MEvasionRateFinalizer implements IStatsFunction public class MEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxCpFinalizer implements IStatsFunction public class MaxCpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData; import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxHpFinalizer implements IStatsFunction public class MaxHpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,11 +16,11 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
import com.l2jmobius.gameserver.model.stats.Stats; import com.l2jmobius.gameserver.model.stats.Stats;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxMpFinalizer implements IStatsFunction public class MaxMpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAccuracyFinalizer implements IStatsFunction public class PAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackFinalizer implements IStatsFunction public class PAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackSpeedFinalizer implements IStatsFunction public class PAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = calcWeaponBaseValue(creature, stat); double baseValue = calcWeaponBaseValue(creature, stat);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PCriticalRateFinalizer implements IStatsFunction public class PCriticalRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -47,7 +47,7 @@ public class PDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PEvasionRateFinalizer implements IStatsFunction public class PEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PRangeFinalizer implements IStatsFunction public class PRangeFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RandomDamageFinalizer implements IStatsFunction public class RandomDamageFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RegenCPFinalizer implements IStatsFunction public class RegenCPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
if (!creature.isPlayer()) if (!creature.isPlayer())

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -52,7 +52,7 @@ import com.l2jmobius.gameserver.util.Util;
public class RegenHPFinalizer implements IStatsFunction public class RegenHPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -24,8 +24,8 @@ import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager; import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager; import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.entity.Castle; import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction; import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction;
import com.l2jmobius.gameserver.model.entity.Fort; import com.l2jmobius.gameserver.model.entity.Fort;
@@ -48,7 +48,7 @@ import com.l2jmobius.gameserver.model.zone.type.MotherTreeZone;
public class RegenMPFinalizer implements IStatsFunction public class RegenMPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceFinalizer implements IStatsFunction public class ShieldDefenceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceRateFinalizer implements IStatsFunction public class ShieldDefenceRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShotsBonusFinalizer implements IStatsFunction public class ShotsBonusFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.model.zone.type.SwampZone;
public class SpeedFinalizer implements IStatsFunction public class SpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class VampiricChanceFinalizer implements IStatsFunction public class VampiricChanceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@@ -733,7 +733,7 @@ public class CreatureStat
public double getValue(Stats stat, double baseValue) public double getValue(Stats stat, double baseValue)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.of(baseValue)); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.of(baseValue));
} }
/** /**
@@ -743,7 +743,7 @@ public class CreatureStat
public double getValue(Stats stat) public double getValue(Stats stat)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.empty()); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.empty());
} }
protected void resetStats() protected void resetStats()
@@ -755,11 +755,11 @@ public class CreatureStat
// Initialize default values // Initialize default values
for (Stats stat : Stats.values()) for (Stats stat : Stats.values())
{ {
if (stat.getResetAddValue() != null) if (stat.getResetAddValue() != 0)
{ {
_statsAdd.put(stat, stat.getResetAddValue()); _statsAdd.put(stat, stat.getResetAddValue());
} }
if (stat.getResetMulValue() != null) if (stat.getResetMulValue() != 0)
{ {
_statsMul.put(stat, stat.getResetMulValue()); _statsMul.put(stat, stat.getResetMulValue());
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.PlayerCondOverride; import com.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
@FunctionalInterface @FunctionalInterface
public interface IStatsFunction public interface IStatsFunction
{ {
default void throwIfPresent(Optional<Double> base) default void throwIfPresent(OptionalDouble base)
{ {
if (base.isPresent()) if (base.isPresent())
{ {
@@ -312,5 +312,5 @@ public interface IStatsFunction
return Math.max(minValue, value); return Math.max(minValue, value);
} }
double calc(Creature creature, Optional<Double> base, Stats stat); double calc(Creature creature, OptionalDouble base, Stats stat);
} }

View File

@@ -17,8 +17,8 @@
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.function.BiFunction; import java.util.function.DoubleBinaryOperator;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
@@ -120,8 +120,8 @@ public enum Stats
CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"), CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"),
MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"), MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"),
SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()), SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()),
CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, 0, 1),
CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, 0, 1),
MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()), MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()),
BLOW_RATE("blowRate"), BLOW_RATE("blowRate"),
DEFENCE_CRITICAL_RATE("defCritRate"), DEFENCE_CRITICAL_RATE("defCritRate"),
@@ -286,10 +286,10 @@ public enum Stats
private final String _value; private final String _value;
private final IStatsFunction _valueFinalizer; private final IStatsFunction _valueFinalizer;
private final BiFunction<Double, Double, Double> _addFunction; private final DoubleBinaryOperator _addFunction;
private final BiFunction<Double, Double, Double> _mulFunction; private final DoubleBinaryOperator _mulFunction;
private final Double _resetAddValue; private final double _resetAddValue;
private final Double _resetMulValue; private final double _resetMulValue;
public String getValue() public String getValue()
{ {
@@ -298,16 +298,16 @@ public enum Stats
Stats(String xmlString) Stats(String xmlString)
{ {
this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, null, null); this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer) Stats(String xmlString, IStatsFunction valueFinalizer)
{ {
this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, null, null); this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer, BiFunction<Double, Double, Double> addFunction, BiFunction<Double, Double, Double> mulFunction, Double resetAddValue, Double resetMulValue) Stats(String xmlString, IStatsFunction valueFinalizer, DoubleBinaryOperator addFunction, DoubleBinaryOperator mulFunction, double resetAddValue, double resetMulValue)
{ {
_value = xmlString; _value = xmlString;
_valueFinalizer = valueFinalizer; _valueFinalizer = valueFinalizer;
@@ -336,7 +336,7 @@ public enum Stats
* @param baseValue * @param baseValue
* @return the final value * @return the final value
*/ */
public Double finalize(Creature creature, Optional<Double> baseValue) public double finalize(Creature creature, OptionalDouble baseValue)
{ {
try try
{ {
@@ -351,20 +351,20 @@ public enum Stats
public double functionAdd(double oldValue, double value) public double functionAdd(double oldValue, double value)
{ {
return _addFunction.apply(oldValue, value); return _addFunction.applyAsDouble(oldValue, value);
} }
public double functionMul(double oldValue, double value) public double functionMul(double oldValue, double value)
{ {
return _mulFunction.apply(oldValue, value); return _mulFunction.applyAsDouble(oldValue, value);
} }
public Double getResetAddValue() public double getResetAddValue()
{ {
return _resetAddValue; return _resetAddValue;
} }
public Double getResetMulValue() public double getResetMulValue()
{ {
return _resetMulValue; return _resetMulValue;
} }
@@ -374,17 +374,17 @@ public enum Stats
return stat._valueFinalizer.calcWeaponBaseValue(creature, stat); return stat._valueFinalizer.calcWeaponBaseValue(creature, stat);
} }
public static double defaultValue(Creature creature, Optional<Double> base, Stats stat) public static double defaultValue(Creature creature, OptionalDouble base, Stats stat)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return base.isPresent() ? defaultValue(creature, stat, base.get()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType())); return base.isPresent() ? defaultValue(creature, stat, base.getAsDouble()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
public static double defaultValue(Creature creature, Stats stat, double baseValue) public static double defaultValue(Creature creature, Stats stat, double baseValue)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()); return mul * (baseValue + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -41,7 +41,7 @@ public class AttributeFinalizer implements IStatsFunction
} }
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData; import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class BaseStatsFinalizer implements IStatsFunction public class BaseStatsFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAccuracyFinalizer implements IStatsFunction public class MAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackFinalizer implements IStatsFunction public class MAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
@@ -55,7 +55,7 @@ public class MAttackFinalizer implements IStatsFunction
// Calculate modifiers Magic Attack // Calculate modifiers Magic Attack
final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.; final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
final double intBonus = BaseStats.INT.calcBonus(creature); final double intBonus = BaseStats.INT.calcBonus(creature);
baseValue *= Math.pow(intBonus, 2) * Math.pow(creature.getLevelMod(), 2) * chaMod; baseValue *= intBonus * creature.getLevelMod() * chaMod;
return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK); return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK);
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackSpeedFinalizer implements IStatsFunction public class MAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MCritRateFinalizer implements IStatsFunction public class MCritRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -43,7 +43,7 @@ public class MDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MEvasionRateFinalizer implements IStatsFunction public class MEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxCpFinalizer implements IStatsFunction public class MaxCpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData; import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxHpFinalizer implements IStatsFunction public class MaxHpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,11 +16,11 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
import com.l2jmobius.gameserver.model.stats.Stats; import com.l2jmobius.gameserver.model.stats.Stats;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxMpFinalizer implements IStatsFunction public class MaxMpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAccuracyFinalizer implements IStatsFunction public class PAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackFinalizer implements IStatsFunction public class PAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackSpeedFinalizer implements IStatsFunction public class PAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = calcWeaponBaseValue(creature, stat); double baseValue = calcWeaponBaseValue(creature, stat);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PCriticalRateFinalizer implements IStatsFunction public class PCriticalRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -47,7 +47,7 @@ public class PDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PEvasionRateFinalizer implements IStatsFunction public class PEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PRangeFinalizer implements IStatsFunction public class PRangeFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RandomDamageFinalizer implements IStatsFunction public class RandomDamageFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RegenCPFinalizer implements IStatsFunction public class RegenCPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
if (!creature.isPlayer()) if (!creature.isPlayer())

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -52,7 +52,7 @@ import com.l2jmobius.gameserver.util.Util;
public class RegenHPFinalizer implements IStatsFunction public class RegenHPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -24,8 +24,8 @@ import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager; import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager; import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.entity.Castle; import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction; import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction;
import com.l2jmobius.gameserver.model.entity.Fort; import com.l2jmobius.gameserver.model.entity.Fort;
@@ -48,7 +48,7 @@ import com.l2jmobius.gameserver.model.zone.type.MotherTreeZone;
public class RegenMPFinalizer implements IStatsFunction public class RegenMPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceFinalizer implements IStatsFunction public class ShieldDefenceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceRateFinalizer implements IStatsFunction public class ShieldDefenceRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShotsBonusFinalizer implements IStatsFunction public class ShotsBonusFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.model.zone.type.SwampZone;
public class SpeedFinalizer implements IStatsFunction public class SpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class VampiricChanceFinalizer implements IStatsFunction public class VampiricChanceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@@ -733,7 +733,7 @@ public class CreatureStat
public double getValue(Stats stat, double baseValue) public double getValue(Stats stat, double baseValue)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.of(baseValue)); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.of(baseValue));
} }
/** /**
@@ -743,7 +743,7 @@ public class CreatureStat
public double getValue(Stats stat) public double getValue(Stats stat)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.empty()); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.empty());
} }
protected void resetStats() protected void resetStats()
@@ -755,11 +755,11 @@ public class CreatureStat
// Initialize default values // Initialize default values
for (Stats stat : Stats.values()) for (Stats stat : Stats.values())
{ {
if (stat.getResetAddValue() != null) if (stat.getResetAddValue() != 0)
{ {
_statsAdd.put(stat, stat.getResetAddValue()); _statsAdd.put(stat, stat.getResetAddValue());
} }
if (stat.getResetMulValue() != null) if (stat.getResetMulValue() != 0)
{ {
_statsMul.put(stat, stat.getResetMulValue()); _statsMul.put(stat, stat.getResetMulValue());
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.PlayerCondOverride; import com.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
@FunctionalInterface @FunctionalInterface
public interface IStatsFunction public interface IStatsFunction
{ {
default void throwIfPresent(Optional<Double> base) default void throwIfPresent(OptionalDouble base)
{ {
if (base.isPresent()) if (base.isPresent())
{ {
@@ -312,5 +312,5 @@ public interface IStatsFunction
return Math.max(minValue, value); return Math.max(minValue, value);
} }
double calc(Creature creature, Optional<Double> base, Stats stat); double calc(Creature creature, OptionalDouble base, Stats stat);
} }

View File

@@ -17,8 +17,8 @@
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.function.BiFunction; import java.util.function.DoubleBinaryOperator;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
@@ -120,8 +120,8 @@ public enum Stats
CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"), CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"),
MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"), MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"),
SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()), SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()),
CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, 0, 1),
CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, 0, 1),
MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()), MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()),
BLOW_RATE("blowRate"), BLOW_RATE("blowRate"),
DEFENCE_CRITICAL_RATE("defCritRate"), DEFENCE_CRITICAL_RATE("defCritRate"),
@@ -286,10 +286,10 @@ public enum Stats
private final String _value; private final String _value;
private final IStatsFunction _valueFinalizer; private final IStatsFunction _valueFinalizer;
private final BiFunction<Double, Double, Double> _addFunction; private final DoubleBinaryOperator _addFunction;
private final BiFunction<Double, Double, Double> _mulFunction; private final DoubleBinaryOperator _mulFunction;
private final Double _resetAddValue; private final double _resetAddValue;
private final Double _resetMulValue; private final double _resetMulValue;
public String getValue() public String getValue()
{ {
@@ -298,16 +298,16 @@ public enum Stats
Stats(String xmlString) Stats(String xmlString)
{ {
this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, null, null); this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer) Stats(String xmlString, IStatsFunction valueFinalizer)
{ {
this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, null, null); this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer, BiFunction<Double, Double, Double> addFunction, BiFunction<Double, Double, Double> mulFunction, Double resetAddValue, Double resetMulValue) Stats(String xmlString, IStatsFunction valueFinalizer, DoubleBinaryOperator addFunction, DoubleBinaryOperator mulFunction, double resetAddValue, double resetMulValue)
{ {
_value = xmlString; _value = xmlString;
_valueFinalizer = valueFinalizer; _valueFinalizer = valueFinalizer;
@@ -336,7 +336,7 @@ public enum Stats
* @param baseValue * @param baseValue
* @return the final value * @return the final value
*/ */
public Double finalize(Creature creature, Optional<Double> baseValue) public double finalize(Creature creature, OptionalDouble baseValue)
{ {
try try
{ {
@@ -351,20 +351,20 @@ public enum Stats
public double functionAdd(double oldValue, double value) public double functionAdd(double oldValue, double value)
{ {
return _addFunction.apply(oldValue, value); return _addFunction.applyAsDouble(oldValue, value);
} }
public double functionMul(double oldValue, double value) public double functionMul(double oldValue, double value)
{ {
return _mulFunction.apply(oldValue, value); return _mulFunction.applyAsDouble(oldValue, value);
} }
public Double getResetAddValue() public double getResetAddValue()
{ {
return _resetAddValue; return _resetAddValue;
} }
public Double getResetMulValue() public double getResetMulValue()
{ {
return _resetMulValue; return _resetMulValue;
} }
@@ -374,17 +374,17 @@ public enum Stats
return stat._valueFinalizer.calcWeaponBaseValue(creature, stat); return stat._valueFinalizer.calcWeaponBaseValue(creature, stat);
} }
public static double defaultValue(Creature creature, Optional<Double> base, Stats stat) public static double defaultValue(Creature creature, OptionalDouble base, Stats stat)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return base.isPresent() ? defaultValue(creature, stat, base.get()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType())); return base.isPresent() ? defaultValue(creature, stat, base.getAsDouble()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
public static double defaultValue(Creature creature, Stats stat, double baseValue) public static double defaultValue(Creature creature, Stats stat, double baseValue)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()); return mul * (baseValue + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -41,7 +41,7 @@ public class AttributeFinalizer implements IStatsFunction
} }
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData; import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class BaseStatsFinalizer implements IStatsFunction public class BaseStatsFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAccuracyFinalizer implements IStatsFunction public class MAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackFinalizer implements IStatsFunction public class MAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
@@ -55,7 +55,7 @@ public class MAttackFinalizer implements IStatsFunction
// Calculate modifiers Magic Attack // Calculate modifiers Magic Attack
final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.; final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
final double intBonus = BaseStats.INT.calcBonus(creature); final double intBonus = BaseStats.INT.calcBonus(creature);
baseValue *= Math.pow(intBonus, 2) * Math.pow(creature.getLevelMod(), 2) * chaMod; baseValue *= intBonus * creature.getLevelMod() * chaMod;
return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK); return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK);
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackSpeedFinalizer implements IStatsFunction public class MAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MCritRateFinalizer implements IStatsFunction public class MCritRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -43,7 +43,7 @@ public class MDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MEvasionRateFinalizer implements IStatsFunction public class MEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxCpFinalizer implements IStatsFunction public class MaxCpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData; import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxHpFinalizer implements IStatsFunction public class MaxHpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,11 +16,11 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
import com.l2jmobius.gameserver.model.stats.Stats; import com.l2jmobius.gameserver.model.stats.Stats;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MaxMpFinalizer implements IStatsFunction public class MaxMpFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAccuracyFinalizer implements IStatsFunction public class PAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackFinalizer implements IStatsFunction public class PAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PAttackSpeedFinalizer implements IStatsFunction public class PAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = calcWeaponBaseValue(creature, stat); double baseValue = calcWeaponBaseValue(creature, stat);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PCriticalRateFinalizer implements IStatsFunction public class PCriticalRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -47,7 +47,7 @@ public class PDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PEvasionRateFinalizer implements IStatsFunction public class PEvasionRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class PRangeFinalizer implements IStatsFunction public class PRangeFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RandomDamageFinalizer implements IStatsFunction public class RandomDamageFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class RegenCPFinalizer implements IStatsFunction public class RegenCPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
if (!creature.isPlayer()) if (!creature.isPlayer())

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -52,7 +52,7 @@ import com.l2jmobius.gameserver.util.Util;
public class RegenHPFinalizer implements IStatsFunction public class RegenHPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData; import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
@@ -24,8 +24,8 @@ import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager; import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager; import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.entity.Castle; import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction; import com.l2jmobius.gameserver.model.entity.Castle.CastleFunction;
import com.l2jmobius.gameserver.model.entity.Fort; import com.l2jmobius.gameserver.model.entity.Fort;
@@ -48,7 +48,7 @@ import com.l2jmobius.gameserver.model.zone.type.MotherTreeZone;
public class RegenMPFinalizer implements IStatsFunction public class RegenMPFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceFinalizer implements IStatsFunction public class ShieldDefenceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShieldDefenceRateFinalizer implements IStatsFunction public class ShieldDefenceRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class ShotsBonusFinalizer implements IStatsFunction public class ShotsBonusFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.model.zone.type.SwampZone;
public class SpeedFinalizer implements IStatsFunction public class SpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.stats.IStatsFunction; import com.l2jmobius.gameserver.model.stats.IStatsFunction;
@@ -28,7 +28,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class VampiricChanceFinalizer implements IStatsFunction public class VampiricChanceFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@@ -733,7 +733,7 @@ public class CreatureStat
public double getValue(Stats stat, double baseValue) public double getValue(Stats stat, double baseValue)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.of(baseValue)); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.of(baseValue));
} }
/** /**
@@ -743,7 +743,7 @@ public class CreatureStat
public double getValue(Stats stat) public double getValue(Stats stat)
{ {
final Double fixedValue = _fixedValue.get(stat); final Double fixedValue = _fixedValue.get(stat);
return fixedValue != null ? fixedValue : stat.finalize(_creature, Optional.empty()); return fixedValue != null ? fixedValue : stat.finalize(_creature, OptionalDouble.empty());
} }
protected void resetStats() protected void resetStats()
@@ -755,11 +755,11 @@ public class CreatureStat
// Initialize default values // Initialize default values
for (Stats stat : Stats.values()) for (Stats stat : Stats.values())
{ {
if (stat.getResetAddValue() != null) if (stat.getResetAddValue() != 0)
{ {
_statsAdd.put(stat, stat.getResetAddValue()); _statsAdd.put(stat, stat.getResetAddValue());
} }
if (stat.getResetMulValue() != null) if (stat.getResetMulValue() != 0)
{ {
_statsMul.put(stat, stat.getResetMulValue()); _statsMul.put(stat, stat.getResetMulValue());
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.PlayerCondOverride; import com.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
@FunctionalInterface @FunctionalInterface
public interface IStatsFunction public interface IStatsFunction
{ {
default void throwIfPresent(Optional<Double> base) default void throwIfPresent(OptionalDouble base)
{ {
if (base.isPresent()) if (base.isPresent())
{ {
@@ -312,5 +312,5 @@ public interface IStatsFunction
return Math.max(minValue, value); return Math.max(minValue, value);
} }
double calc(Creature creature, Optional<Double> base, Stats stat); double calc(Creature creature, OptionalDouble base, Stats stat);
} }

View File

@@ -17,8 +17,8 @@
package com.l2jmobius.gameserver.model.stats; package com.l2jmobius.gameserver.model.stats;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.function.BiFunction; import java.util.function.DoubleBinaryOperator;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
@@ -120,8 +120,8 @@ public enum Stats
CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"), CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"),
MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"), MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"),
SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()), SHIELD_DEFENCE_RATE("rShld", new ShieldDefenceRateFinalizer()),
CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, 0, 1),
CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, null, 1d), CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, 0, 1),
MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()), MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()),
BLOW_RATE("blowRate"), BLOW_RATE("blowRate"),
DEFENCE_CRITICAL_RATE("defCritRate"), DEFENCE_CRITICAL_RATE("defCritRate"),
@@ -287,10 +287,10 @@ public enum Stats
private final String _value; private final String _value;
private final IStatsFunction _valueFinalizer; private final IStatsFunction _valueFinalizer;
private final BiFunction<Double, Double, Double> _addFunction; private final DoubleBinaryOperator _addFunction;
private final BiFunction<Double, Double, Double> _mulFunction; private final DoubleBinaryOperator _mulFunction;
private final Double _resetAddValue; private final double _resetAddValue;
private final Double _resetMulValue; private final double _resetMulValue;
public String getValue() public String getValue()
{ {
@@ -299,16 +299,16 @@ public enum Stats
Stats(String xmlString) Stats(String xmlString)
{ {
this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, null, null); this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer) Stats(String xmlString, IStatsFunction valueFinalizer)
{ {
this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, null, null); this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, 0, 1);
} }
Stats(String xmlString, IStatsFunction valueFinalizer, BiFunction<Double, Double, Double> addFunction, BiFunction<Double, Double, Double> mulFunction, Double resetAddValue, Double resetMulValue) Stats(String xmlString, IStatsFunction valueFinalizer, DoubleBinaryOperator addFunction, DoubleBinaryOperator mulFunction, double resetAddValue, double resetMulValue)
{ {
_value = xmlString; _value = xmlString;
_valueFinalizer = valueFinalizer; _valueFinalizer = valueFinalizer;
@@ -337,7 +337,7 @@ public enum Stats
* @param baseValue * @param baseValue
* @return the final value * @return the final value
*/ */
public Double finalize(Creature creature, Optional<Double> baseValue) public double finalize(Creature creature, OptionalDouble baseValue)
{ {
try try
{ {
@@ -352,20 +352,20 @@ public enum Stats
public double functionAdd(double oldValue, double value) public double functionAdd(double oldValue, double value)
{ {
return _addFunction.apply(oldValue, value); return _addFunction.applyAsDouble(oldValue, value);
} }
public double functionMul(double oldValue, double value) public double functionMul(double oldValue, double value)
{ {
return _mulFunction.apply(oldValue, value); return _mulFunction.applyAsDouble(oldValue, value);
} }
public Double getResetAddValue() public double getResetAddValue()
{ {
return _resetAddValue; return _resetAddValue;
} }
public Double getResetMulValue() public double getResetMulValue()
{ {
return _resetMulValue; return _resetMulValue;
} }
@@ -375,17 +375,17 @@ public enum Stats
return stat._valueFinalizer.calcWeaponBaseValue(creature, stat); return stat._valueFinalizer.calcWeaponBaseValue(creature, stat);
} }
public static double defaultValue(Creature creature, Optional<Double> base, Stats stat) public static double defaultValue(Creature creature, OptionalDouble base, Stats stat)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return base.isPresent() ? defaultValue(creature, stat, base.get()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType())); return base.isPresent() ? defaultValue(creature, stat, base.getAsDouble()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
public static double defaultValue(Creature creature, Stats stat, double baseValue) public static double defaultValue(Creature creature, Stats stat, double baseValue)
{ {
final double mul = creature.getStat().getMul(stat); final double mul = creature.getStat().getMul(stat);
final double add = creature.getStat().getAdd(stat); final double add = creature.getStat().getAdd(stat);
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()); return mul * (baseValue + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
} }
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -41,7 +41,7 @@ public class AttributeFinalizer implements IStatsFunction
} }
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional; import java.util.OptionalDouble;
import java.util.Set; import java.util.Set;
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData; import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class BaseStatsFinalizer implements IStatsFunction public class BaseStatsFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.items.Item; import com.l2jmobius.gameserver.model.items.Item;
@@ -29,7 +29,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAccuracyFinalizer implements IStatsFunction public class MAccuracyFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackFinalizer implements IStatsFunction public class MAttackFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
@@ -55,7 +55,7 @@ public class MAttackFinalizer implements IStatsFunction
// Calculate modifiers Magic Attack // Calculate modifiers Magic Attack
final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.; final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
final double intBonus = BaseStats.INT.calcBonus(creature); final double intBonus = BaseStats.INT.calcBonus(creature);
baseValue *= Math.pow(intBonus, 2) * Math.pow(creature.getLevelMod(), 2) * chaMod; baseValue *= intBonus * creature.getLevelMod() * chaMod;
return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK); return Math.min(Stats.defaultValue(creature, stat, baseValue), Config.MAX_MATK);
} }

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -30,7 +30,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MAttackSpeedFinalizer implements IStatsFunction public class MAttackSpeedFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,7 +16,7 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
public class MCritRateFinalizer implements IStatsFunction public class MCritRateFinalizer implements IStatsFunction
{ {
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);

View File

@@ -16,12 +16,12 @@
*/ */
package com.l2jmobius.gameserver.model.stats.finalizers; package com.l2jmobius.gameserver.model.stats.finalizers;
import java.util.Optional; import java.util.OptionalDouble;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.Creature; import com.l2jmobius.gameserver.model.actor.Creature;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.actor.instance.PetInstance; import com.l2jmobius.gameserver.model.actor.instance.PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance; import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.stats.BaseStats; import com.l2jmobius.gameserver.model.stats.BaseStats;
@@ -43,7 +43,7 @@ public class MDefenseFinalizer implements IStatsFunction
}; };
@Override @Override
public double calc(Creature creature, Optional<Double> base, Stats stat) public double calc(Creature creature, OptionalDouble base, Stats stat)
{ {
throwIfPresent(base); throwIfPresent(base);
double baseValue = creature.getTemplate().getBaseValue(stat, 0); double baseValue = creature.getTemplate().getBaseValue(stat, 0);

Some files were not shown because too many files have changed in this diff Show More