Class TrophyRollEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.block.BlockEvent
com.github.crashdemons.miningtrophies.events.TrophyRollEvent
public class TrophyRollEvent
extends org.bukkit.event.block.BlockEvent
Event created by MiningTrophies (0.7.2+) to indicate that a trophy dropchance roll has occurred and the success/failure has been determined.
This event allows third-party plugin authors to analyze and modify drop chance success with all factors considered by MiningTrophies available.
If the success of this event is set to false, no trophy will be dropped. If it is set to true, a trophy will be dropped.
- Author:
- crashdemons (crashenator at gmail.com)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result
-
Field Summary
Fields inherited from class org.bukkit.event.block.BlockEvent
block
-
Constructor Summary
ConstructorDescriptionTrophyRollEvent
(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double originalDropRoll, double originalDropRate) Creates the Trophy dropchance event for MiningTrophies.TrophyRollEvent
(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double originalDropRoll, double effectiveDropRoll, double originalDropRate, double effectiveDropRate, boolean dropSuccess) Creates the Trophy dropchance event for MiningTrophies.TrophyRollEvent
(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double fortuneModifier, double originalDropRoll, double effectiveDropRoll, double originalDropRate, double effectiveDropRate, boolean dropSuccess) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Re-apply the current effective droproll and effective droprate values to make a new determination of the trophy drop's success.void
Re-apply all droprate modifiers to the original droprate and recalculate the effective droprate.getCustomModifier
(String yourPluginName, String modifierName) Gets a custom (plugin-added) modifier to the trophy-roll event.getCustomModifier
(org.bukkit.plugin.Plugin yourPlugin, String modifierName) Gets a custom (plugin-added) modifier to the trophy-roll event.static String
getCustomModifierName
(String pluginName, String modifierName) Constructs the internal name of a custom droprate modifier, provided the name of the plugin and modifier.boolean
Whether the effective drop roll was determined to be a success.double
Gets the configured droprate for the target as a fractional probability, after modification by fortune.double
Gets the effective drop roll value after modification by MiningTrophies.double
Deprecated.static org.bukkit.event.HandlerList
Get a list of handlers for the event.org.bukkit.event.HandlerList
Get a list of handlers for the event.org.bukkit.entity.Entity
getMiner()
Get the Miner's entity that may have done the mining.boolean
Gets whether the miner was configured to always be rewarded this type of target.getModifier
(String modifierName) Retrieve the value of a modifier of the effective droprate.Gets the list of modifiers to the effective droprate.double
Gets the configured droprate for the target as a fractional probability, unmodified.double
Gets the original PRNG-generated random value of the drop roll, uniform between 0 and 1 inclusively.org.bukkit.block.Block
Get the Target's block that may have been minedorg.bukkit.Material
void
Re-apply all factors (droprate modifiers then effective values) to determine suuccess.void
recalculateSuccess
(boolean applyModifiers) Re-apply all relevant factors (droprate modifiers then effective values) to determine suuccess.void
setCustomModifier
(org.bukkit.plugin.Plugin yourPlugin, String modifierName, DropRateModifier modifierValue) Add or change a note about your custom modifier to the trophy-roll event.void
setCustomModifier
(org.bukkit.plugin.Plugin yourPlugin, String modifierName, DropRateModifier modifierValue, boolean recalculateSuccess) Add or change a note about your custom modifier to the trophy-roll event.void
setDropSuccess
(boolean value) Sets whether the drop roll should be considered a success.void
setEffectiveDropRate
(double effectiveRate) Deprecated.this value is very likely to be overwritten by other plugins (or applyModifiers/recalculateSuccess) - use setCustomModifier instead.void
setEffectiveDropRoll
(double effectiveRoll) Sets the effective droproll value for the event.void
setModifier
(String modifierName, DropRateModifier value) Deprecated.using this method to modify existing modifiers should be avoided - use setCustomModifier to note new ones.void
setModifiers
(Map<String, DropRateModifier> entries) Deprecated.using this method to modify existing modifiers should be avoided - use setCustomModifier to note new ones.boolean
Whether the effective drop roll was determined to be a success.Methods inherited from class org.bukkit.event.block.BlockEvent
getBlock
Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
TrophyRollEvent
public TrophyRollEvent(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double originalDropRoll, double originalDropRate) Creates the Trophy dropchance event for MiningTrophies.- Parameters:
miner
- the Entity mining the blocktarget
- the Block being minedminerAlwaysRewarded
- whether the miner has the always-rewarded permissionoriginalDropRoll
- the randomized PRNG double droproll value inclusively between 0 to 1.originalDropRate
- the configured droprate of the target as a fraction (0.01 = 1%)
-
TrophyRollEvent
public TrophyRollEvent(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double originalDropRoll, double effectiveDropRoll, double originalDropRate, double effectiveDropRate, boolean dropSuccess) Creates the Trophy dropchance event for MiningTrophies.- Parameters:
miner
- the Entity mining the blocktarget
- the Block being minedminerAlwaysRewarded
- whether the miner has the always-rewarded permissionoriginalDropRoll
- the randomized PRNG double droproll value inclusively between 0 to 1.effectiveDropRoll
- the modified droproll value after permission logic was applied (alwaysrewarded sets to 0)originalDropRate
- the configured droprate of the target as a fraction (0.01 = 1%)effectiveDropRate
- the effective droprate of the target as a fraction (0.01 = 1%), as modified by fortune.dropSuccess
- whether the droproll was determined to be initially a successful roll.
-
TrophyRollEvent
@Deprecated public TrophyRollEvent(org.bukkit.entity.Entity miner, org.bukkit.block.Block target, boolean minerAlwaysRewarded, double fortuneModifier, double originalDropRoll, double effectiveDropRoll, double originalDropRate, double effectiveDropRate, boolean dropSuccess) Deprecated.Creates the Trophy dropchance event for MiningTrophies.- Parameters:
miner
- the Entity mining the blocktarget
- the Block being minedminerAlwaysRewarded
- whether the miner has the always-rewarded permissionfortuneModifier
- the fractional probability modifier (greater than or equal to 1.0) of fortune, as applied by MiningTrophies to the effective droprate.originalDropRoll
- the randomized PRNG double droproll value inclusively between 0 to 1.effectiveDropRoll
- the modified droproll value after permission logic was applied (alwaysrewarded sets to 0)originalDropRate
- the configured droprate of the target as a fraction (0.01 = 1%)effectiveDropRate
- the effective droprate of the target as a fraction (0.01 = 1%), as modified by fortune.dropSuccess
- whether the droproll was determined to be initially a successful roll.
-
-
Method Details
-
getFortuneModifier
Deprecated.Gets the fortune modifier (multiplier) that was applied to the effective droprate. This is generally 1 (no effect) or greater.- Returns:
- the fortune modifier
-
getMiner
public org.bukkit.entity.Entity getMiner()Get the Miner's entity that may have done the mining.- Returns:
- the entity of the miner, or null if the miner was a mob.
-
getTarget
public org.bukkit.block.Block getTarget()Get the Target's block that may have been mined- Returns:
- the entity of the target
-
getTargetMaterial
public org.bukkit.Material getTargetMaterial() -
getMinerAlwaysRewarded
public boolean getMinerAlwaysRewarded()Gets whether the miner was configured to always be rewarded this type of target. If this is true, the effective droproll may have been set to 0 to force success.- Returns:
- Whether the miner was configured to always be rewarded
-
getOriginalDropRoll
public double getOriginalDropRoll()Gets the original PRNG-generated random value of the drop roll, uniform between 0 and 1 inclusively. When this value is lower than the droprate value by chance, the roll is considered successful.- Returns:
- the drop roll value in the range [0,1]
-
getEffectiveDropRoll
public double getEffectiveDropRoll()Gets the effective drop roll value after modification by MiningTrophies. The droproll will normally be reflected by the original random droproll, except if the miner always is rewarded, then this may be 0. If this is below the droprate, the roll would have been determined to be a success.- Returns:
- the effective drop roll.
- See Also:
-
getOriginalDropRate
public double getOriginalDropRate()Gets the configured droprate for the target as a fractional probability, unmodified.- Returns:
- the droprate
-
getEffectiveDropRate
public double getEffectiveDropRate()Gets the configured droprate for the target as a fractional probability, after modification by fortune.- Returns:
- the droprate
-
getDropSuccess
public boolean getDropSuccess()Whether the effective drop roll was determined to be a success.- Returns:
- the success of the drop roll
-
setDropSuccess
public void setDropSuccess(boolean value) Sets whether the drop roll should be considered a success.- Parameters:
value
- whether the trophy drop should succeed or fail.
-
succeeded
public boolean succeeded()Whether the effective drop roll was determined to be a success. Alias of getDropSuccess- Returns:
- the success of the drop roll
- See Also:
-
getModifiers
Gets the list of modifiers to the effective droprate. This map will be in order that the modifiers are applied.- Returns:
- map containing the droprate modifiers by name.
- Since:
- 5.2.16-SNAPSHOT
-
applyDropRate
public void applyDropRate()Re-apply the current effective droproll and effective droprate values to make a new determination of the trophy drop's success. Modifiers are not considered by this method, only the two effective values. Note: if killerAlwaysBetrophys is enabled, the effective droproll will be set to 0. This is equivalent to recalculateSuccess(false).- Since:
- 5.2.16-SNAPSHOT
-
applyModifiers
public void applyModifiers()Re-apply all droprate modifiers to the original droprate and recalculate the effective droprate. This method will discard the current effective droprate, if you want to retain the original values, you should copy them before calling this method. Success is not updated by this method.- Since:
- 5.2.16-SNAPSHOT
-
recalculateSuccess
public void recalculateSuccess()Re-apply all factors (droprate modifiers then effective values) to determine suuccess. This method will discard the current effective droprate, if you want to retain the original values, you should copy them before calling this method. This is equivalent to recalculateSuccess(true) or applyModifiers();applyDropRate();- Since:
- 5.2.16-SNAPSHOT
-
recalculateSuccess
public void recalculateSuccess(boolean applyModifiers) Re-apply all relevant factors (droprate modifiers then effective values) to determine suuccess. This method will discard the current effective droprate (if set), if you want to retain the original values, you should copy them before calling this method. When the applyModifiers is true, this is equivalent to recalculateSuccess() or applyModifiers();applyDropRate(). When the applyModifiers is false, this is equivalent to applyDropRate().- Parameters:
applyModifiers
- If this is set, the current effective droprate will be discarded and recalculated from modifiers.- Since:
- 5.2.17-SNAPSHOT
-
getModifier
Retrieve the value of a modifier of the effective droprate. Note: this value does not impact calculations or success and is for you to use as a courtesy to other plugins at this point. This method can retrieve both internal and custom plugin modifiers (if the prefix is included).- Parameters:
modifierName
- the name of the modifier- Returns:
- the value of the modifier, or null if it is not present.
- Since:
- 5.2.16-SNAPSHOT
-
setModifier
Deprecated.using this method to modify existing modifiers should be avoided - use setCustomModifier to note new ones.Sets a note about an internal modifier of the effective droprate. Note: this value does not impact calculations or success unless applyModifiers+applyDropRate or recalculateSuccess is called Note: new modifies are generally applied AFTER other modifiers- Parameters:
modifierName
- the name of the modifier to set.value
- the value of the modifier to set- Since:
- 5.2.16-SNAPSHOT
-
setModifiers
Deprecated.using this method to modify existing modifiers should be avoided - use setCustomModifier to note new ones.Replaces notes about an internal modifiers of the effective droprate. Note: this value does not impact calculations or success unless applyModifiers+applyDropRate or recalculateSuccess is called Note: new modifies are generally applied AFTER other modifiers; this method will overwrite existing modifiers.- Parameters:
entries
- the modifiers to set- Since:
- 5.2.16-SNAPSHOT
-
getCustomModifierName
Constructs the internal name of a custom droprate modifier, provided the name of the plugin and modifier.- Parameters:
pluginName
- The name of the plugin that added the modifiermodifierName
- The name of the modifier- Returns:
- the internal name of the modifier;
- Since:
- 5.2.16-SNAPSHOT
-
setCustomModifier
public void setCustomModifier(org.bukkit.plugin.Plugin yourPlugin, String modifierName, DropRateModifier modifierValue) Add or change a note about your custom modifier to the trophy-roll event. Note: this value does not impact calculations unless applyModifiers+applyDropRate or recalculateSuccess is called.
Note: the name of the modifier will be prepended with "PluginName:" depending on your plugin's name.
Note: new modifies are generally applied AFTER other modifiers- Parameters:
yourPlugin
- the plugin adding the modifiermodifierName
- the name of the modifier, excluding any prefixmodifierValue
- the value of the modifier- Since:
- 5.2.16-SNAPSHOT
-
setCustomModifier
public void setCustomModifier(org.bukkit.plugin.Plugin yourPlugin, String modifierName, DropRateModifier modifierValue, boolean recalculateSuccess) Add or change a note about your custom modifier to the trophy-roll event. Note: this value does not impact calculations unless applyModifiers+applyDropRate or recalculateSuccess is called.
Note: the name of the modifier will be prepended with "PluginName:" depending on your plugin's name.
Note: new modifies are generally applied AFTER other modifiers- Parameters:
yourPlugin
- the plugin adding the modifiermodifierName
- the name of the modifier, excluding any prefixmodifierValue
- the value of the modifierrecalculateSuccess
- whether to force recalculation of success by applying this modifier. Note: this will erase any changes to the effective droprate.- Since:
- 5.2.17-SNAPSHOT
-
getCustomModifier
Gets a custom (plugin-added) modifier to the trophy-roll event. Note: this value does not impact calculations or success and is for you to use as a courtesy to other plugins at this point. Note: the name of the modifier will be prepended with "PluginName:" depending on your plugin's name.- Parameters:
yourPlugin
- the plugin which added the modifiermodifierName
- the name of the modifier, excluding any prefix- Returns:
- the value of the modifier, or the null if it is not found.
- Since:
- 5.2.16-SNAPSHOT
-
getCustomModifier
Gets a custom (plugin-added) modifier to the trophy-roll event. Note: this value does not impact calculations or success and is for you to use as a courtesy to other plugins at this point. Note: the name of the modifier will be prepended with "PluginName:" depending on your plugin's name.- Parameters:
yourPluginName
- the plugin name which added the modifiermodifierName
- the name of the modifier, excluding any prefix- Returns:
- the value of the modifier, or the null if it is not found.
- Since:
- 5.2.16-SNAPSHOT
-
setEffectiveDropRoll
public void setEffectiveDropRoll(double effectiveRoll) Sets the effective droproll value for the event. Note: this value will not impact the success value or calculations unless applyDropRate() or recalculateSuccess() is called.- Parameters:
effectiveRoll
- the value between 0.0 and 1.0 to use as the drop roll.- Since:
- 5.2.16-SNAPSHOT
-
setEffectiveDropRate
public void setEffectiveDropRate(double effectiveRate) Deprecated.this value is very likely to be overwritten by other plugins (or applyModifiers/recalculateSuccess) - use setCustomModifier instead.Sets the effective droprate value for the event. Note: this value will be overwritten by applyModifiers and recalculateSuccess methods and does not impact the success of the event unless you run applyDropRate(). Since other plugins are likely to overwrite this change, you are strongly recommended to use a Modifier instead (which is not likely to be erased) to get the result you want.- Parameters:
effectiveRate
- the effective droprate/fractional-chance value to set (0.0-1.0 inclusive)- Since:
- 5.2.16-SNAPSHOT
-
getHandlers
public org.bukkit.event.HandlerList getHandlers()Get a list of handlers for the event.- Specified by:
getHandlers
in classorg.bukkit.event.Event
- Returns:
- a list of handlers for the event
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Get a list of handlers for the event.- Returns:
- a list of handlers for the event
-