Class DoubleOrNothing
java.lang.Object
dev.strwbry.eventhorizon.events.BaseEvent
dev.strwbry.eventhorizon.events.dropmodification.BaseDropModification
dev.strwbry.eventhorizon.events.dropmodification.DoubleOrNothing
- All Implemented Interfaces:
org.bukkit.event.Listener
A drop modification event that implements a double-or-nothing mechanic.
When active, each block break or entity death has a 50% chance to either:
- Double all drops and experience, or
- Drop nothing and no experience
The outcome is determined randomly but consistently for each block/entity.
-
Field Summary
Fields inherited from class dev.strwbry.eventhorizon.events.dropmodification.BaseDropModification
blockDrops, isActive, key, mobDrops, random -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DoubleOrNothing event with NEGATIVE classification. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Executes the double-or-nothing event by registering listeners.protected booleanhandleBlockDrops(org.bukkit.event.block.BlockDropItemEvent event) Processes block drops according to the stored outcome.protected booleanhandleEntityDrops(org.bukkit.event.entity.EntityDeathEvent event) Processes entity drops with a 50% chance to either double or remove drops.voidonBlockBreak(org.bukkit.event.block.BlockBreakEvent event) Handles block breaking events by determining and storing the drop outcome.protected voidNo setup required for this modification as it doesn't use predefined drops.voidTerminates the double-or-nothing event by unregistering listeners.Methods inherited from class dev.strwbry.eventhorizon.events.dropmodification.BaseDropModification
addBlockDrop, addMobDrop, disableDropModifications, dropItem, dropItems, generateSurvivalDropsList, getBlockDrops, getMobDrops, isActive, onBlockDropItem, onEntityDeath, selectRandomDrop, setBlockDrops, setFixedBlockDrop, setFixedMobDrop, setMobDropsMethods inherited from class dev.strwbry.eventhorizon.events.BaseEvent
getClassification, getEventClassification, getName, run
-
Constructor Details
-
DoubleOrNothing
public DoubleOrNothing()Constructs a new DoubleOrNothing event with NEGATIVE classification. Initializes the event with the name "doubleOrNothing".
-
-
Method Details
-
setupDropModifications
protected void setupDropModifications()No setup required for this modification as it doesn't use predefined drops.- Specified by:
setupDropModificationsin classBaseDropModification
-
onBlockBreak
public void onBlockBreak(org.bukkit.event.block.BlockBreakEvent event) Handles block breaking events by determining and storing the drop outcome. Uses a consistent random seed based on block location and player name. Sets metadata on the block and modifies XP drops accordingly.- Overrides:
onBlockBreakin classBaseDropModification- Parameters:
event- the block break event
-
handleBlockDrops
protected boolean handleBlockDrops(org.bukkit.event.block.BlockDropItemEvent event) Processes block drops according to the stored outcome. Either doubles all item drops or cancels them entirely.- Overrides:
handleBlockDropsin classBaseDropModification- Parameters:
event- the block drop item event- Returns:
- true if drops were modified, false if event was ignored
-
handleEntityDrops
protected boolean handleEntityDrops(org.bukkit.event.entity.EntityDeathEvent event) Processes entity drops with a 50% chance to either double or remove drops. Affects both item drops and experience points.- Overrides:
handleEntityDropsin classBaseDropModification- Parameters:
event- the entity death event- Returns:
- true if drops were modified, false if event was ignored
-
execute
public void execute()Executes the double-or-nothing event by registering listeners. Delegates to parent class.- Overrides:
executein classBaseDropModification
-
terminate
public void terminate()Terminates the double-or-nothing event by unregistering listeners. Delegates to parent class.- Overrides:
terminatein classBaseDropModification
-