- All Superinterfaces:
BaseReward
Represents a crate reward in the crate system.
A Reward defines the items, commands, and behaviors that the player will receive when opening a crate.
-
Method Summary
Retrieves an alternative reward for this crate.
String
Gets the unique identifier for this crate reward.
default double
int
Gets the number of keys required to open the crate and potentially win this reward.
List<String>
Gets the list of permissions that are restricted for this reward.
double
Gets the weight of this reward, which represents its likelihood of being won during a crate opening.
int
Retrieves the win limits for this crate reward.
default boolean
Overrides the method from BaseReward to indicate if this is an alternative reward.
default boolean
Checks whether the given player is restricted from getting this reward.
-
Method Details
-
getIdentifier
String getIdentifier()
Gets the unique identifier for this crate reward.
The identifier is typically used to reference or track the reward within the crate system.
- Specified by:
-
getIdentifier in interface BaseReward
- Returns:
- the unique identifier for the reward.
-
getWeight
double getWeight()
Gets the weight of this reward, which represents its likelihood of being won during a crate opening.
The weight is a value used in the crate system's probability calculations to determine the chance of this reward being awarded.
- Specified by:
-
getWeight in interface BaseReward
- Returns:
- the weight of this reward.
-
getWinLimits
int getWinLimits()
Retrieves the win limits for this crate reward.
The win limits define the maximum number of times this reward can be won.
- Returns:
- the maximum number of times this reward can be won.
-
getRestrictedPermissions
List<String> getRestrictedPermissions()
Gets the list of permissions that are restricted for this reward.
Players who don't have the required permissions won't be able to win this reward.
- Returns:
- a list of permissions that are required to win this reward.
-
isRestricted
default boolean isRestricted(org.bukkit.entity.Player player)
Checks whether the given player is restricted from getting this reward.
Operators (OPs) are never restricted. Otherwise, the method checks if
the player has any of the restricted permissions defined by
getRestrictedPermissions().
- Parameters:
-
player - the player to check
- Returns:
- true if the player is restricted, false otherwise
-
getRequiredKeys
int getRequiredKeys()
Gets the number of keys required to open the crate and potentially win this reward.
Some crates may require a certain number of keys to open, and this method provides
the number of keys required to win this reward specifically. The returned value can
vary based on the crate configuration.
- Returns:
- the number of keys required to get this reward.
-
getAlternative
Retrieves an alternative reward for this crate.
If the player is unable to win the main reward, this alternative can be awarded instead.
- Returns:
- the alternative reward, or null if no alternative is provided.
-
isAlternative
default boolean isAlternative()
Overrides the method from BaseReward to indicate if this is an alternative reward.
- Specified by:
-
isAlternative in interface BaseReward
- Returns:
- false, since this is not an alternative reward.
-
getPercentage
@Deprecated
default double getPercentage()
Deprecated.
Gets the percentage chance of this reward being won during a crate opening.
This method is deprecated and only exists for cross-version compatibility.
Implementations should use getWeight() for probability calculations instead.
- Returns:
- the chance percentage (from 0.0 to 100.0) for winning this reward, or the weight value for compatibility.
getWeight()instead.