Package com.hazebyte.crate.api.crate
Interface Crate
-
- All Superinterfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable
public interface Crate extends org.bukkit.configuration.serialization.ConfigurationSerializable
Represents a crate
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addReward(Reward reward)
Adds a reward to the prize list.org.bukkit.inventory.ItemStack
getAcceptButton()
AnimationType
getAnimationType()
Returns the animation that open when the crate activation is triggered.Message
getBroadcast()
Returns the message wrapper.List<Reward>
getConstantRewards()
Returns the list of rewards that will be given to the player no matter what.double
getCost()
Returns the cost of a crate.String
getCrateName()
Returns the name of the crate.org.bukkit.inventory.ItemStack
getDeclineButton()
org.bukkit.inventory.ItemStack
getDisplayItem()
Returns the display item that is specified to be used
in virtual menus.String
getDisplayName()
Returns the display name specified by the user.EndAnimationType
getEndAnimationType()
List<String>
getHolographicText()
Returns the set of strings used in an holographic.org.bukkit.inventory.ItemStack
getItem()
Returns the item that is given in-game to the player.int
getMaximumRewards()
Returns the user-set attribute used to generate prizes.int
getMinimumRewards()
Returns the user-set attribute used to generate prizes.Message
getOpenMessage()
Returns the message wrapper.int
getPreviewRows()
Returns the number of rows in a preview menu.int
getPreviewSlots()
Returns the number of slots in a preview menu.List<Reward>
getRewards()
Returns the list of rewards.CrateType
getType()
Returns the type that determines the minecraft action
that activates the crate.String
getUUID()
boolean
hasConfirmationToggle()
Returns whether the crate has an confirmation toggle.boolean
hasDisplayItem()
Checks whether this crate has a display item.boolean
hasDisplayName()
Checks whether this crate has a display name.boolean
is(org.bukkit.inventory.ItemStack item)
Checks if anItemStack
equals this crate's item.
The matching scheme is based on a configuration setting in the config.yml.
The strictest setting will match with NBT.boolean
isBuyable()
Returns whether this crate is for sale.boolean
isPlaceable()
Returns whether the crate is a placeable item.boolean
isPreviewable()
Returns whether this crate is previewable.void
onReward(org.bukkit.entity.Player player, Reward reward)
Called whenever a player triggers a win for this crate.void
onRewards(org.bukkit.entity.Player player, List<Reward> rewards)
Called whenever a player triggers a win for this crate.void
onRewards(org.bukkit.entity.Player player, List<Reward> rewards, org.bukkit.Location location)
void
onRewards(org.bukkit.entity.Player player, List<Reward> rewards, org.bukkit.Location location, Consumer consumer)
boolean
removeReward(Reward reward)
Removes a reward from the prize list.void
runEffect(org.bukkit.Location location, Category category)
void
runEffect(org.bukkit.Location location, Category category, org.bukkit.entity.Player player)
Starts all effects with the givenCategory
at the given location.void
setAcceptButton(org.bukkit.inventory.ItemStack acceptButton)
void
setAnimationType(AnimationType type)
Sets the animation to aAnimationType
void
setConfirmationToggle(boolean bool)
Sets the toggle that enables or disables the confirmation menu.void
setCost(double amount)
Sets the cost of the cratevoid
setDeclineButton(org.bukkit.inventory.ItemStack declineButton)
void
setDisplayItem(org.bukkit.inventory.ItemStack item)
Sets the display item which is displayed in virtual menus.void
setDisplayName(String name)
Sets the display name.void
setEndAnimationType(EndAnimationType type)
void
setHolographicText(List<String> texts)
Sets the holographic text.void
setItem(org.bukkit.inventory.ItemStack item)
Sets the item which is given to a player.void
setRewards(List<Reward> rewards)
Sets the list of rewards to a new list
-
-
-
Method Detail
-
getCrateName
String getCrateName()
Returns the name of the crate.
This is the first order key of the crate configuration.- Returns:
- the name of the crate
-
getUUID
String getUUID()
-
getDisplayName
String getDisplayName()
Returns the display name specified by the user.- Returns:
- the user set name
-
getDisplayItem
org.bukkit.inventory.ItemStack getDisplayItem()
Returns the display item that is specified to be used
in virtual menus.- Returns:
- the display item
-
hasDisplayName
boolean hasDisplayName()
Checks whether this crate has a display name.- Returns:
- true if the display name is not null, false otherwise.
-
hasDisplayItem
boolean hasDisplayItem()
Checks whether this crate has a display item.- Returns:
- true if the display item is not null, false otherwise.
-
getType
CrateType getType()
Returns the type that determines the minecraft action
that activates the crate.- Returns:
CrateType
-
getItem
org.bukkit.inventory.ItemStack getItem()
Returns the item that is given in-game to the player.- Returns:
- the physical item
-
getCost
double getCost()
Returns the cost of a crate. The amount is set to zero if the amount is less than zero.- Returns:
- the cost
-
setCost
void setCost(double amount) throws IllegalArgumentException
Sets the cost of the crate- Parameters:
amount
- the cost of the crate.
This value must be greater than or equal to zero.- Throws:
IllegalArgumentException
- If the cost is negative.
-
getAnimationType
AnimationType getAnimationType()
Returns the animation that open when the crate activation is triggered.- Returns:
AnimationType
-
getEndAnimationType
EndAnimationType getEndAnimationType()
-
addReward
void addReward(Reward reward)
Adds a reward to the prize list. CallsReward.setParent(Crate)
, and sets the parent to this crate.- Parameters:
reward
- The reward to add
-
removeReward
boolean removeReward(Reward reward)
Removes a reward from the prize list.- Parameters:
reward
- The reward to remove- Returns:
- true if reward was removed, false otherwise.
-
setRewards
void setRewards(List<Reward> rewards)
Sets the list of rewards to a new list- Parameters:
rewards
- The list to set
-
getRewards
List<Reward> getRewards()
Returns the list of rewards. If there are no rewards, it returns the empty list.- Returns:
- List of
Reward
-
getConstantRewards
List<Reward> getConstantRewards()
Returns the list of rewards that will be given to the player no matter what. If there are no rewards, it returns the empty list.- Returns:
- List of
Reward
-
getMinimumRewards
int getMinimumRewards()
Returns the user-set attribute used to generate prizes. If the minimum is greater than the maximum, it'll return the maximum.- Returns:
- minimum number of rewards.
-
getMaximumRewards
int getMaximumRewards()
Returns the user-set attribute used to generate prizes. If the maximum is less than the minimum, it'll return the minimum.- Returns:
- maximum number of rewards.
-
getPreviewRows
int getPreviewRows()
Returns the number of rows in a preview menu.- Returns:
- the number of rows.
-
getPreviewSlots
int getPreviewSlots()
Returns the number of slots in a preview menu.- Returns:
- the number of slots.
-
setDisplayName
void setDisplayName(String name) throws IllegalArgumentException
Sets the display name. If the name is null, it'll be set to the empty string.- Parameters:
name
- the name used to format.- Throws:
IllegalArgumentException
-
setAnimationType
void setAnimationType(AnimationType type)
Sets the animation to aAnimationType
- Parameters:
type
- the type of animation
-
setEndAnimationType
void setEndAnimationType(EndAnimationType type)
-
setDisplayItem
void setDisplayItem(org.bukkit.inventory.ItemStack item)
Sets the display item which is displayed in virtual menus.- Parameters:
item
- theItemStack
-
setItem
void setItem(org.bukkit.inventory.ItemStack item)
Sets the item which is given to a player.- Parameters:
item
- theItemStack
-
is
boolean is(org.bukkit.inventory.ItemStack item)
Checks if anItemStack
equals this crate's item.
The matching scheme is based on a configuration setting in the config.yml.
The strictest setting will match with NBT. The lightest setting will compare the item's meta.- Parameters:
item
- theItemStack
to compare- Returns:
- true if the item matches, false otherwise.
-
isBuyable
boolean isBuyable()
Returns whether this crate is for sale.- Returns:
- true if the crate is for sale, false otherwise.
-
isPreviewable
boolean isPreviewable()
Returns whether this crate is previewable.- Returns:
- true if the crate is previewable, false otherwise.
-
hasConfirmationToggle
boolean hasConfirmationToggle()
Returns whether the crate has an confirmation toggle.- Returns:
- true if there is an confirmation toggle, false otherwise.
-
setConfirmationToggle
void setConfirmationToggle(boolean bool)
Sets the toggle that enables or disables the confirmation menu.- Parameters:
bool
- the toggle.
-
setAcceptButton
void setAcceptButton(org.bukkit.inventory.ItemStack acceptButton)
-
getAcceptButton
org.bukkit.inventory.ItemStack getAcceptButton()
-
setDeclineButton
void setDeclineButton(org.bukkit.inventory.ItemStack declineButton)
-
getDeclineButton
org.bukkit.inventory.ItemStack getDeclineButton()
-
getHolographicText
List<String> getHolographicText()
Returns the set of strings used in an holographic.- Returns:
- a list of strings, otherwise the empty list.
-
setHolographicText
void setHolographicText(List<String> texts)
Sets the holographic text. This may be set to null to represent an empty holographic display.- Parameters:
texts
- a list of strings. This may be set to null.
-
runEffect
void runEffect(org.bukkit.Location location, Category category)
-
runEffect
void runEffect(org.bukkit.Location location, Category category, org.bukkit.entity.Player player)
Starts all effects with the givenCategory
at the given location. If the effect category is PERSISTENT, the effect will not run if there is a previous set of effects already running at that location. If a player is specified, the effect will only be shown for the target player.- Parameters:
location
- the location at which the effects start.category
- the category that triggers the effect.player
- the player to show the effects to.
-
onReward
void onReward(org.bukkit.entity.Player player, Reward reward)
Called whenever a player triggers a win for this crate.- Parameters:
player
- the player who activated the cratereward
- the reward that was generated
-
onRewards
void onRewards(org.bukkit.entity.Player player, List<Reward> rewards)
Called whenever a player triggers a win for this crate.- Parameters:
player
- the player who activated the crate.rewards
- the set of rewards that was generated.
-
onRewards
void onRewards(org.bukkit.entity.Player player, List<Reward> rewards, org.bukkit.Location location)
-
onRewards
void onRewards(org.bukkit.entity.Player player, List<Reward> rewards, org.bukkit.Location location, Consumer consumer)
-
getOpenMessage
Message getOpenMessage()
Returns the message wrapper. This message wrapper holds the set of messages individually sent to the player.- Returns:
Message
-
getBroadcast
Message getBroadcast()
Returns the message wrapper. This message wrapper holds the set of messages sent to every player.- Returns:
Message
-
isPlaceable
boolean isPlaceable()
Returns whether the crate is a placeable item.- Returns:
- true if the item is placeable, false otherwise.
-
-