You can now specify for resources to ONLY regen outside of combat

This commit is contained in:
ASangarin 2020-10-19 21:22:35 +02:00
parent 3dd170bdc3
commit 7d227c874b
2 changed files with 18 additions and 9 deletions

View File

@ -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>

View File

@ -38,11 +38,15 @@ public class ResourceHandler {
this.resource = resource; this.resource = resource;
offCombatOnly = config.getBoolean("off-combat"); offCombatOnly = config.getBoolean("off-combat");
if(config.contains("type")) {
Validate.isTrue(config.contains("type"), "Could not find resource regen scaling type"); Validate.isTrue(config.contains("type"), "Could not find resource regen scaling type");
type = HandlerType.valueOf(config.getString("type").toUpperCase()); type = HandlerType.valueOf(config.getString("type").toUpperCase());
} else type = null;
if(type != null) {
Validate.notNull(config.getConfigurationSection("value"), "Could not find resource regen value config section"); Validate.notNull(config.getConfigurationSection("value"), "Could not find resource regen value config section");
scalar = new LinearValue(config.getConfigurationSection("value")); 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,7 +60,6 @@ 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
@ -71,7 +74,6 @@ public class ResourceHandler {
} }
public enum HandlerType { public enum HandlerType {
/* /*
* resource regeneration scales on max resource * resource regeneration scales on max resource
*/ */