Commits

md_5 authored 5ffd2392101
Implement CauldronLevelChangeEvent.

Idea for implementation via matiki1231 on IRC.
No tags

src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java

Added
1 +package org.bukkit.event.block;
2 +
3 +import com.google.common.base.Preconditions;
4 +import org.bukkit.block.Block;
5 +import org.bukkit.entity.Entity;
6 +import org.bukkit.event.Cancellable;
7 +import org.bukkit.event.HandlerList;
8 +
9 +public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable {
10 +
11 + private static final HandlerList handlers = new HandlerList();
12 + private boolean cancelled;
13 + //
14 + private final Entity entity;
15 + private final ChangeReason reason;
16 + private final int oldLevel;
17 + private int newLevel;
18 +
19 + public CauldronLevelChangeEvent(Block block, Entity entity, ChangeReason reason, int oldLevel, int newLevel) {
20 + super(block);
21 + this.entity = entity;
22 + this.reason = reason;
23 + this.oldLevel = oldLevel;
24 + this.newLevel = newLevel;
25 + }
26 +
27 + /**
28 + * Get entity which did this. May be null.
29 + *
30 + * @return acting entity
31 + */
32 + public Entity getEntity() {
33 + return entity;
34 + }
35 +
36 + public ChangeReason getReason() {
37 + return reason;
38 + }
39 +
40 + public int getOldLevel() {
41 + return oldLevel;
42 + }
43 +
44 + public int getNewLevel() {
45 + return newLevel;
46 + }
47 +
48 + public void setNewLevel(int newLevel) {
49 + Preconditions.checkArgument(0 <= newLevel && newLevel <= 3, "Cauldron level out of bounds 0 <= %s <= 3", newLevel);
50 + this.newLevel = newLevel;
51 + }
52 +
53 + @Override
54 + public boolean isCancelled() {
55 + return cancelled;
56 + }
57 +
58 + @Override
59 + public void setCancelled(boolean cancelled) {
60 + this.cancelled = cancelled;
61 + }
62 +
63 + @Override
64 + public HandlerList getHandlers() {
65 + return handlers;
66 + }
67 +
68 + public static HandlerList getHandlerList() {
69 + return handlers;
70 + }
71 +
72 + public enum ChangeReason {
73 + /**
74 + * Player emptying the cauldron by filling their bucket.
75 + */
76 + BUCKET_FILL,
77 + /**
78 + * Player filling the cauldron by emptying their bucket.
79 + */
80 + BUCKET_EMPTY,
81 + /**
82 + * Player emptying the cauldron by filling their bottle.
83 + */
84 + BOTTLE_FILL,
85 + /**
86 + * Player filling the cauldron by emptying their bottle.
87 + */
88 + BOTTLE_EMPTY,
89 + /**
90 + * Player cleaning their banner.
91 + */
92 + BANNER_WASH,
93 + /**
94 + * Player cleaning their armor.
95 + */
96 + ARMOR_WASH,
97 + /**
98 + * Entity being extinguished.
99 + */
100 + EXTINGUISH,
101 + /**
102 + * Evaporating due to biome dryness.
103 + */
104 + EVAPORATE,
105 + /**
106 + * Unknown.
107 + */
108 + UNKNOWN
109 + }
110 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut