SPIGOT-6562: Add more specific sculk sensor event

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2021-06-16 08:34:08 +10:00
parent e0d1266d3e
commit 14e4e9a16c

View File

@ -0,0 +1,70 @@
package org.bukkit.event.block;
import org.bukkit.GameEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a Sculk sensor receives a game event and hence might activate.
*
* Will be called cancelled if the block's default behavior is to ignore the
* event.
*/
public class BlockReceiveGameEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final GameEvent event;
private final Entity entity;
private boolean cancelled;
public BlockReceiveGameEvent(@NotNull GameEvent event, @NotNull Block block, @Nullable Entity entity) {
super(block);
this.event = event;
this.entity = entity;
}
/**
* Get the underlying event.
*
* @return the event
*/
@NotNull
public GameEvent getEvent() {
return event;
}
/**
* Get the entity which triggered this event, if present.
*
* @return triggering entity or null
*/
@Nullable
public Entity getEntity() {
return entity;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}