geforkt von Mirrors/Paper
SPIGOT-4966: Provide access to Entity in PortalCreateEvent
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
b2c53e8c68
Commit
5c4a9d5f13
@ -6,11 +6,15 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a Living Entity creates a portal in a world.
|
||||
*
|
||||
* @deprecated Use {@link PortalCreateEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class EntityCreatePortalEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final List<BlockState> blocks;
|
||||
|
@ -3,9 +3,11 @@ package org.bukkit.event.world;
|
||||
import java.util.List;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
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 portal is created
|
||||
@ -14,12 +16,19 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private final List<BlockState> blocks;
|
||||
private final Entity entity;
|
||||
private final CreateReason reason;
|
||||
|
||||
@Deprecated
|
||||
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);
|
||||
|
||||
this.blocks = blocks;
|
||||
this.entity = entity;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@ -33,6 +42,16 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||
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
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren