Class WEALTH
WEALTH is a beneficial effect that periodically generates magical currency coins and adds them to the target player's inventory. Every 120 game ticks (6 seconds), the effect generates a random coin based on weighted probability influenced by the strength multiplier. The higher the strength, the more likely the player receives high-value coins (Galleons) instead of low-value coins (Knuts). The probability distribution is: strength-adjusted random % 100, with Galleons (>90%), Sickles (>60%), and Knuts (default). The effect is detectable by both mind-reading spells (Legilimens) and information spells (Informous) which report the target "feels fortunate".
Wealth Configuration:
- Generation interval: every 120 game ticks (6 seconds)
- Coin types: Galleon (high value), Sickle (medium value), Knut (low value)
- Strength parameter: multiplies random value to affect coin probability
- Probability calculation: (random % 100) * strength
- Detection text: "feels fortunate"
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionWEALTH(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a wealth effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidAge the wealth effect and generate coins periodically.voiddoRemove()Perform cleanup when the wealth effect is removed.voidsetStrength(int strength) Set the strength multiplier for coin probability generation.Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill, setPermanent
-
Constructor Details
-
WEALTH
public WEALTH(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a wealth effect.Creates a wealth effect that periodically generates magical coins for the target player. Initializes the strength multiplier to 1 (normal probability). Detection text is set for both mind-reading spells (Legilimens) and information spells (Informous). The target player reference is acquired at initialization time.
- Parameters:
plugin- a callback to the MC pluginduration- the duration of the wealth effect in game ticksisPermanent- is this effect permanent (does not age)pid- the unique ID of the player to grant wealth
-
-
Method Details
-
checkEffect
public void checkEffect()Age the wealth effect and generate coins periodically.Called each game tick. This method ages the effect counter. Every 120 ticks (6 seconds), a random coin is generated based on weighted probability. The strength multiplier is applied to the random value to increase the chance of higher-value coins. Generated coins are immediately added to the target player's inventory.
- Specified by:
checkEffectin classO2Effect
-
setStrength
public void setStrength(int strength) Set the strength multiplier for coin probability generation.The strength multiplier affects the weighted probability of coin generation. A strength of 1 uses normal probability distribution. Higher values increase the likelihood of generating high-value coins (Galleons) over low-value coins (Knuts).
- Parameters:
strength- a positive integer multiplier where 1 is normal strength
-
doRemove
public void doRemove()Perform cleanup when the wealth effect is removed.The default implementation does nothing, as WEALTH has no persistent state to clean up. When removed, the player keeps all coins that were generated while the effect was active.
-