forked from Upstream/mmocore
You can now specify for resources to ONLY regen outside of combat
This commit is contained in:
parent
3dd170bdc3
commit
7d227c874b
@ -4,7 +4,7 @@
|
|||||||
<groupId>net.Indyuce</groupId>
|
<groupId>net.Indyuce</groupId>
|
||||||
<artifactId>MMOCore</artifactId>
|
<artifactId>MMOCore</artifactId>
|
||||||
<name>MMOCore</name>
|
<name>MMOCore</name>
|
||||||
<version>1.4.9</version>
|
<version>1.4.10</version>
|
||||||
<description>Offer your players a brand new RPG experience.</description>
|
<description>Offer your players a brand new RPG experience.</description>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
@ -162,6 +162,13 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.vagdedes</groupId>
|
||||||
|
<artifactId>spartan</artifactId>
|
||||||
|
<version>Univsersal</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/SpartanAPI.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -38,11 +38,15 @@ public class ResourceHandler {
|
|||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
offCombatOnly = config.getBoolean("off-combat");
|
offCombatOnly = config.getBoolean("off-combat");
|
||||||
|
|
||||||
Validate.isTrue(config.contains("type"), "Could not find resource regen scaling type");
|
if(config.contains("type")) {
|
||||||
type = HandlerType.valueOf(config.getString("type").toUpperCase());
|
Validate.isTrue(config.contains("type"), "Could not find resource regen scaling type");
|
||||||
|
type = HandlerType.valueOf(config.getString("type").toUpperCase());
|
||||||
|
} else type = null;
|
||||||
|
|
||||||
Validate.notNull(config.getConfigurationSection("value"), "Could not find resource regen value config section");
|
if(type != null) {
|
||||||
scalar = new LinearValue(config.getConfigurationSection("value"));
|
Validate.notNull(config.getConfigurationSection("value"), "Could not find resource regen value config section");
|
||||||
|
scalar = new LinearValue(config.getConfigurationSection("value"));
|
||||||
|
} else scalar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceHandler(PlayerResource resource, HandlerType type, LinearValue scalar, boolean offCombatOnly) {
|
public ResourceHandler(PlayerResource resource, HandlerType type, LinearValue scalar, boolean offCombatOnly) {
|
||||||
@ -56,22 +60,20 @@ public class ResourceHandler {
|
|||||||
* REGENERATION FORMULAS HERE.
|
* REGENERATION FORMULAS HERE.
|
||||||
*/
|
*/
|
||||||
public double getRegen(PlayerData player) {
|
public double getRegen(PlayerData player) {
|
||||||
|
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
|
||||||
// base resource regeneration = value of the corresponding regen stat
|
// base resource regeneration = value of the corresponding regen stat
|
||||||
if (!player.isInCombat() || !player.getProfess().hasOption(resource.getOffCombatRegen()))
|
if (!player.isInCombat() || !player.getProfess().hasOption(resource.getOffCombatRegen()))
|
||||||
d += player.getStats().getStat(resource.getRegenStat());
|
d += player.getStats().getStat(resource.getRegenStat());
|
||||||
|
|
||||||
// extra resource regeneration based on CLASS, scales on LEVEL
|
// extra resource regeneration based on CLASS, scales on LEVEL
|
||||||
if (type != null && (!player.isInCombat() || !offCombatOnly))
|
if (type != null && (!player.isInCombat() || !offCombatOnly))
|
||||||
d = this.scalar.calculate(player.getLevel()) / 100 * type.getScaling(player, resource);
|
d = this.scalar.calculate(player.getLevel()) / 100 * type.getScaling(player, resource);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HandlerType {
|
public enum HandlerType {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* resource regeneration scales on max resource
|
* resource regeneration scales on max resource
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user