mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-09-18 21:45:12 +00:00
SPIGOT-4570: Add FluidLevelChangeEvent
This commit is contained in:
parent
6de6ac4a8b
commit
d4e8c8b3b3
2 changed files with 72 additions and 0 deletions
|
@ -9,6 +9,8 @@ package org.bukkit.block.data;
|
|||
* to "falling" fluids. All falling fluids have the same behaviour, but the
|
||||
* level corresponds to that of the block above them, equal to
|
||||
* <code>this.level - 8</code>
|
||||
* <b>Note that counterintuitively, an adjusted level of 1 is the highest level,
|
||||
* whilst 7 is the lowest.</b>
|
||||
* <br>
|
||||
* May not be higher than {@link #getMaximumLevel()}.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.bukkit.event.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when the fluid level of a block changes due to changes in adjacent
|
||||
* blocks.
|
||||
*
|
||||
* @deprecated draft API
|
||||
*/
|
||||
@Deprecated
|
||||
@Warning(false)
|
||||
public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
//
|
||||
private BlockData newData;
|
||||
|
||||
public FluidLevelChangeEvent(Block theBlock, BlockData newData) {
|
||||
super(theBlock);
|
||||
this.newData = newData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the new data of the changed block.
|
||||
*
|
||||
* @return new data
|
||||
*/
|
||||
public BlockData getNewData() {
|
||||
return newData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new data of the changed block. Must be of the same Material as
|
||||
* the old one.
|
||||
*
|
||||
* @param newData the new data
|
||||
*/
|
||||
public void setNewData(BlockData newData) {
|
||||
Preconditions.checkArgument(newData != null, "newData null");
|
||||
Preconditions.checkArgument(this.newData.getMaterial().equals(newData.getMaterial()), "Cannot change fluid type");
|
||||
|
||||
this.newData = newData;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue