Stats can now be regenerated as FLAT or PERCENTAGE based values. This includes the Health, Mana, Stamina, Stellium stats.

By default, the stats are regenerated off the flat value of their respective Regeneration stats. Example, if Health Regeneration is 10, the player will gain 10 HP upon regeneration.

For percentage, the stats will be regenerated with the following formula (Stat Regen * Max Stat). So for example, if your Health Regeneration is .5 and your Max Health is 100, you'll gain 50 HP upon regeneration.

Refresh your config.yml or add this directly to it if you wish to adjust them from the default true.
```# Should these Stats regenrate with a FLAT value or PERCENTAGE value?
   # By default, they are set to TRUE, which means they will regenerate
   # based off the FLAT Regeneration value for the respective stat
   # Setting a stat to FALSE means that it will regenerate
   # with the formula (Stat Regen * Max Stat) for example (Mana Regeneration * Max Mana)
   stat-regen-flat:
       health: true
       mana: true
       stamina: true
       stellium: true
```
This commit is contained in:
Dancull47 2021-10-20 02:08:27 -04:00
parent 15cb4d7aa2
commit c5b661e3e2
2 changed files with 51 additions and 3 deletions

View File

@ -90,6 +90,11 @@ public class MMOCore extends LuminePlugin {
public final MMOLoadManager loadManager = new MMOLoadManager();
public boolean healthRegenFlat;
public boolean manaRegenFlat;
public boolean staminaRegenFlat;
public boolean stelliumRegenFlat;
public boolean shouldDebugSQL = false;
public MMOCore() {
@ -141,6 +146,13 @@ public class MMOCore extends LuminePlugin {
if (getConfig().isConfigurationSection("default-playerdata"))
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
if (getConfig().isConfigurationSection("stat-regen-flat")) {
healthRegenFlat = getConfig().getBoolean("stat-regen-flat.health", true);
manaRegenFlat = getConfig().getBoolean("stat-regen-flat.mana", true);
staminaRegenFlat = getConfig().getBoolean("stat-regen-flat.stamina", true);
stelliumRegenFlat = getConfig().getBoolean("stat-regen-flat.stellium", true);
}
if (Bukkit.getPluginManager().getPlugin("Vault") != null) economy = new VaultEconomy();
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
@ -177,8 +189,33 @@ public class MMOCore extends LuminePlugin {
for (PlayerData player : PlayerData.getAll())
if (player.isOnline() && !player.getPlayer().isDead())
for (PlayerResource resource : PlayerResource.values()) {
double d = player.getProfess().getHandler(resource).getRegen(player);
if (d != 0) resource.regen(player, d);
double regenAmount = player.getProfess().getHandler(resource).getRegen(player);
switch (resource) {
case HEALTH:
if (healthRegenFlat && regenAmount != 0)
resource.regen(player, regenAmount);
else if (!healthRegenFlat && regenAmount * player.getStats().getStat(StatType.HEALTH_REGENERATION) != 0)
resource.regen(player, player.getStats().getStat(StatType.MAX_HEALTH) * regenAmount);
break;
case MANA:
if (manaRegenFlat && regenAmount != 0)
resource.regen(player, regenAmount);
else if (!manaRegenFlat && regenAmount * player.getStats().getStat(StatType.MANA_REGENERATION) != 0)
resource.regen(player, player.getStats().getStat(StatType.MAX_MANA) * regenAmount);
break;
case STAMINA:
if (staminaRegenFlat && regenAmount != 0)
resource.regen(player, regenAmount);
else if (!staminaRegenFlat && regenAmount * player.getStats().getStat(StatType.STAMINA_REGENERATION) != 0)
resource.regen(player, player.getStats().getStat(StatType.MAX_STAMINA) * regenAmount);
break;
case STELLIUM:
if (stelliumRegenFlat && regenAmount != 0)
resource.regen(player, regenAmount);
else if (!stelliumRegenFlat && regenAmount * player.getStats().getStat(StatType.STELLIUM_REGENERATION) != 0)
resource.regen(player, player.getStats().getStat(StatType.MAX_STELLIUM) * regenAmount);
break;
}
}
}
}.runTaskTimer(MMOCore.plugin, 100, 20);

View File

@ -8,7 +8,7 @@
# a Spigot Plugin by Team Requiem
# DO NOT TOUCH
config-version: 7
config-version: 8
# Auto-Save feature automatically saves playerdata
# (class, level, etc.) and guild data
@ -42,6 +42,17 @@ default-playerdata:
attribute-points: 0
attribute-realloc-points: 0
# Should these Stats regenrate with a FLAT value or PERCENTAGE value?
# By default, they are set to TRUE, which means they will regenerate
# based off the FLAT Regeneration value for the respective stat
# Setting a stat to FALSE means that it will regenerate
# with the formula (Stat Regen * Max Stat) for example (Mana Regeneration * Max Mana)
stat-regen-flat:
health: true
mana: true
stamina: true
stellium: true
# The list of all conditions which must be met for the
# BLOCK REGEN and BLOCK RESTRICTIONS to apply. Set to
# 'custom-mine-conditions: []' to disable custom mining entirely.