Interface Rechargeable
- All Superinterfaces:
ItemAttribute
- All Known Implementing Classes:
JetBoots
,Jetpack
,MultiTool
,PortableTeleporter
A
Rechargeable
SlimefunItem
can hold energy and is able to
be recharged using a ChargingBench
.
Any SlimefunItem
which is supposed to be chargeable must implement this interface.- Author:
- TheBusyBiscuit
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
addItemCharge
(org.bukkit.inventory.ItemStack item, float charge) This method adds the given charge to the providedItemStack
.default float
getItemCharge
(org.bukkit.inventory.ItemStack item) This method returns the currently stored energy charge on the providedItemStack
.float
getMaxItemCharge
(org.bukkit.inventory.ItemStack item) This method returns the maximum charge the givenItemStack
is capable of holding.default boolean
removeItemCharge
(org.bukkit.inventory.ItemStack item, float charge) This method removes the given charge to the providedItemStack
.default void
setItemCharge
(org.bukkit.inventory.ItemStack item, float charge) This method sets the stored energy charge for a givenItemStack
.Methods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute
getId
-
Method Details
-
getMaxItemCharge
float getMaxItemCharge(org.bukkit.inventory.ItemStack item) This method returns the maximum charge the givenItemStack
is capable of holding.- Parameters:
item
- TheItemStack
for which to determine the maximum charge- Returns:
- The maximum energy charge for this
ItemStack
-
setItemCharge
default void setItemCharge(org.bukkit.inventory.ItemStack item, float charge) This method sets the stored energy charge for a givenItemStack
. The charge must be at least zero and at mostgetMaxItemCharge(ItemStack)
.- Parameters:
item
- TheItemStack
to chargecharge
- The amount of charge to store
-
getItemCharge
default float getItemCharge(org.bukkit.inventory.ItemStack item) This method returns the currently stored energy charge on the providedItemStack
.- Parameters:
item
- TheItemStack
to get the charge from- Returns:
- The charge stored on this
ItemStack
-
addItemCharge
default boolean addItemCharge(org.bukkit.inventory.ItemStack item, float charge) This method adds the given charge to the providedItemStack
. The method will also return whether this operation was successful. If theItemStack
is already at maximum charge, the method will returnfalse
.- Parameters:
item
- TheItemStack
to chargecharge
- The amount of charge to add- Returns:
- Whether the given charge could be added successfully
-
removeItemCharge
default boolean removeItemCharge(org.bukkit.inventory.ItemStack item, float charge) This method removes the given charge to the providedItemStack
. The method will also return whether this operation was successful. If theItemStack
does not have enough charge, the method will returnfalse
.- Parameters:
item
- TheItemStack
to remove the charge fromcharge
- The amount of charge to remove- Returns:
- Whether the given charge could be removed successfully
-