fixed 'restore stamina'

This commit is contained in:
Indyuce 2021-10-30 12:46:38 +02:00
parent c0ec548e63
commit f033db14fa
5 changed files with 12 additions and 17 deletions

View File

@ -234,13 +234,13 @@ public class MMOUtils {
/**
* @param player Player to heal
* @param saturation Saturation amount
* @param allowNegatives If passing a negative saturation value will desaturatie the entity x)
* @param allowNegatives If passing a negative saturation value will desaturate the entity x)
* <br>
* If <code>false</code>, negative values are just ignored
*/
public static void saturate(@NotNull Player player, double saturation, boolean allowNegatives) {
if (saturation > 0 || allowNegatives)
player.setSaturation(Math.min(0, Math.min(20, player.getSaturation() + (float) saturation)));
player.setSaturation(Math.max(0, Math.min(20, player.getSaturation() + (float) saturation)));
}
/**

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* When a consumable is eaten, restores health.
* When a consumable is eaten, restores food.
*
* @author Gunging
*/
@ -31,7 +31,7 @@ public class RestoreFood extends DoubleStat implements PlayerConsumable {
// Get value
DoubleData d = (DoubleData) mmo.getData(ItemStats.RESTORE_FOOD);
// Any health being provided?
// Any food being provided?
if (d.getValue() != 0)
MMOUtils.feed(player, SilentNumbers.ceil(d.getValue()));
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* When a consumable is eaten, restores health.
* When a consumable is eaten, restores mana.
*
* @author Gunging
*/
@ -30,7 +30,7 @@ public class RestoreMana extends DoubleStat implements PlayerConsumable {
// Get value
DoubleData d = (DoubleData) mmo.getData(ItemStats.RESTORE_MANA);
// Any health being provided?
// Any mana being provided?
if (d.getValue() != 0)
PlayerData.get(player).getRPG().giveMana(d.getValue());
}

View File

@ -1,6 +1,5 @@
package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
@ -12,7 +11,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* When a consumable is eaten, restores health.
* When a consumable is eaten, restores saturation.
*
* @author Gunging
*/
@ -29,14 +28,10 @@ public class RestoreSaturation extends DoubleStat implements PlayerConsumable {
* For some reason, it was in the earlier code that the default value
* of restored saturation is 6... I am all for backwards compatibility
* such that this must be respected.
*
* 6 is the saturation for a cooked beef
*/
int saturation = 6;
if (mmo.hasData(ItemStats.RESTORE_SATURATION)) {
// Get value
DoubleData d = (DoubleData) mmo.getData(ItemStats.RESTORE_SATURATION);
saturation = SilentNumbers.ceil(d.getValue());
}
double saturation = mmo.hasData(ItemStats.RESTORE_SATURATION) ? ((DoubleData) mmo.getData(ItemStats.RESTORE_SATURATION)).getValue() : 6;
// Any saturation being provided?
if (saturation != 0)

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* When a consumable is eaten, restores health.
* When a consumable is eaten, restores stamina.
*
* @author Gunging
*/
@ -29,7 +29,7 @@ public class RestoreStamina extends DoubleStat implements PlayerConsumable {
// Get value
DoubleData d = (DoubleData) mmo.getData(ItemStats.RESTORE_STAMINA);
// Any health being provided?
// Any stamina being provided?
if (d.getValue() != 0)
PlayerData.get(player).getRPG().giveStamina(d.getValue());
}