diff options
author | md_5 <git@md-5.net> | 2016-03-01 08:30:03 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-01 08:30:03 +1100 |
commit | eb5cb1008e0602411f6cf1146204ff0a4cfbd640 (patch) | |
tree | afd420c86b4365c0712f65a491e23ce37389fd18 /src/main | |
parent | f042873c1d8f71dd22bd75f6a708971afea25d26 (diff) | |
download | bukkit-eb5cb1008e0602411f6cf1146204ff0a4cfbd640.tar bukkit-eb5cb1008e0602411f6cf1146204ff0a4cfbd640.tar.gz bukkit-eb5cb1008e0602411f6cf1146204ff0a4cfbd640.tar.lz bukkit-eb5cb1008e0602411f6cf1146204ff0a4cfbd640.tar.xz bukkit-eb5cb1008e0602411f6cf1146204ff0a4cfbd640.zip |
Implement CauldronLevelChangeEvent.
Idea for implementation via matiki1231 on IRC.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java b/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java new file mode 100644 index 00000000..3a0fbba5 --- /dev/null +++ b/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java @@ -0,0 +1,110 @@ +package org.bukkit.event.block; + +import com.google.common.base.Preconditions; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + // + private final Entity entity; + private final ChangeReason reason; + private final int oldLevel; + private int newLevel; + + public CauldronLevelChangeEvent(Block block, Entity entity, ChangeReason reason, int oldLevel, int newLevel) { + super(block); + this.entity = entity; + this.reason = reason; + this.oldLevel = oldLevel; + this.newLevel = newLevel; + } + + /** + * Get entity which did this. May be null. + * + * @return acting entity + */ + public Entity getEntity() { + return entity; + } + + public ChangeReason getReason() { + return reason; + } + + public int getOldLevel() { + return oldLevel; + } + + public int getNewLevel() { + return newLevel; + } + + public void setNewLevel(int newLevel) { + Preconditions.checkArgument(0 <= newLevel && newLevel <= 3, "Cauldron level out of bounds 0 <= %s <= 3", newLevel); + this.newLevel = newLevel; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + public enum ChangeReason { + /** + * Player emptying the cauldron by filling their bucket. + */ + BUCKET_FILL, + /** + * Player filling the cauldron by emptying their bucket. + */ + BUCKET_EMPTY, + /** + * Player emptying the cauldron by filling their bottle. + */ + BOTTLE_FILL, + /** + * Player filling the cauldron by emptying their bottle. + */ + BOTTLE_EMPTY, + /** + * Player cleaning their banner. + */ + BANNER_WASH, + /** + * Player cleaning their armor. + */ + ARMOR_WASH, + /** + * Entity being extinguished. + */ + EXTINGUISH, + /** + * Evaporating due to biome dryness. + */ + EVAPORATE, + /** + * Unknown. + */ + UNKNOWN + } +} |