mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
SPIGOT-4966: Provide access to Entity in PortalCreateEvent
This commit is contained in:
parent
36ae34f06d
commit
142bdd6a35
2 changed files with 23 additions and 0 deletions
|
@ -6,11 +6,15 @@ import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.world.PortalCreateEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when a Living Entity creates a portal in a world.
|
* Thrown when a Living Entity creates a portal in a world.
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link PortalCreateEvent}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class EntityCreatePortalEvent extends EntityEvent implements Cancellable {
|
public class EntityCreatePortalEvent extends EntityEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final List<BlockState> blocks;
|
private final List<BlockState> blocks;
|
||||||
|
|
|
@ -3,9 +3,11 @@ package org.bukkit.event.world;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a portal is created
|
* Called when a portal is created
|
||||||
|
@ -14,12 +16,19 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
private final List<BlockState> blocks;
|
private final List<BlockState> blocks;
|
||||||
|
private final Entity entity;
|
||||||
private final CreateReason reason;
|
private final CreateReason reason;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public PortalCreateEvent(@NotNull final List<BlockState> blocks, @NotNull final World world, @NotNull CreateReason reason) {
|
public PortalCreateEvent(@NotNull final List<BlockState> blocks, @NotNull final World world, @NotNull CreateReason reason) {
|
||||||
|
this(blocks, world, null, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PortalCreateEvent(@NotNull final List<BlockState> blocks, @NotNull final World world, @Nullable Entity entity, @NotNull CreateReason reason) {
|
||||||
super(world);
|
super(world);
|
||||||
|
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
|
this.entity = entity;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +42,16 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||||
return this.blocks;
|
return this.blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Entity that triggered this portal creation (if available)
|
||||||
|
*
|
||||||
|
* @return Entity involved in this event
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Entity getEntity() {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancel;
|
return cancel;
|
||||||
|
|
Loading…
Add table
Reference in a new issue