Class CustomFoodComponent
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomFoodComponent
- All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable,org.bukkit.inventory.meta.components.FoodComponent
public class CustomFoodComponent
extends Object
implements org.bukkit.inventory.meta.components.FoodComponent
Represents a custom implementation of the
FoodComponent.
This class allows defining custom food properties such as nutrition, saturation,
and whether the item can be eaten when the player is not hungry.-
Constructor Summary
ConstructorsConstructorDescriptionCustomFoodComponent(int nutrition, float saturation, boolean canEatOnFull) Constructs a new CustomFoodComponent with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the food can be eaten when the player is not hungry.intGets the nutrition value of the food.floatGets the saturation value of the food.Serializes the food component properties into a map.voidsetCanAlwaysEat(boolean canAlwaysEat) Sets whether the food can be eaten when the player is not hungry.voidsetNutrition(int nutrition) Sets the nutrition value of the food.voidsetSaturation(float saturation) Sets the saturation value of the food.
-
Constructor Details
-
CustomFoodComponent
public CustomFoodComponent(int nutrition, float saturation, boolean canEatOnFull) Constructs a new CustomFoodComponent with the specified properties.- Parameters:
nutrition- the amount of nutrition the food providessaturation- the saturation modifier of the foodcanEatOnFull- whether the food can be eaten even if the player is not hungry
-
-
Method Details
-
getNutrition
public int getNutrition()Gets the nutrition value of the food.- Specified by:
getNutritionin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Returns:
- the nutrition value
-
setNutrition
public void setNutrition(int nutrition) Sets the nutrition value of the food.- Specified by:
setNutritionin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Parameters:
nutrition- the new nutrition value
-
getSaturation
public float getSaturation()Gets the saturation value of the food.- Specified by:
getSaturationin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Returns:
- the saturation value
-
setSaturation
public void setSaturation(float saturation) Sets the saturation value of the food.- Specified by:
setSaturationin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Parameters:
saturation- the new saturation value
-
canAlwaysEat
public boolean canAlwaysEat()Checks if the food can be eaten when the player is not hungry.- Specified by:
canAlwaysEatin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Returns:
- true if the food can be eaten on full hunger, false otherwise
-
setCanAlwaysEat
public void setCanAlwaysEat(boolean canAlwaysEat) Sets whether the food can be eaten when the player is not hungry.- Specified by:
setCanAlwaysEatin interfaceorg.bukkit.inventory.meta.components.FoodComponent- Parameters:
canAlwaysEat- true if the food can be eaten on full hunger, false otherwise
-
serialize
Serializes the food component properties into a map.- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Returns:
- a map containing the serialized properties of the food component
-