mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
SPIGOT-6562: Add more specific sculk sensor event
By: md_5 <git@md-5.net>
This commit is contained in:
parent
e0d1266d3e
commit
14e4e9a16c
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user