mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Add a CreateReason to PortalCreateEvent. Addresses BUKKIT-833
By: Sam Wilson <sam.wilson@gmail.com>
This commit is contained in:
parent
860011dcc1
commit
2e383f96df
1 changed files with 28 additions and 2 deletions
|
@ -9,16 +9,19 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Called when the world attempts to create a matching end to a portal
|
||||
* Called when a portal is created
|
||||
*/
|
||||
public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private final ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
private CreateReason reason = CreateReason.FIRE;
|
||||
|
||||
public PortalCreateEvent(final Collection<Block> blocks, final World world) {
|
||||
public PortalCreateEvent(final Collection<Block> blocks, final World world, CreateReason reason) {
|
||||
super(world);
|
||||
|
||||
this.blocks.addAll(blocks);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +41,15 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
|||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reason for the portal's creation
|
||||
*
|
||||
* @return CreateReason for the portal's creation
|
||||
*/
|
||||
public CreateReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -46,4 +58,18 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
|||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* An enum to specify the various reasons for a portal's creation
|
||||
*/
|
||||
public enum CreateReason {
|
||||
/**
|
||||
* When a portal is created 'traditionally' due to a portal frame being set on fire.
|
||||
*/
|
||||
FIRE,
|
||||
/**
|
||||
* When a portal is created as a destination for an existing portal when using the custom PortalTravelAgent
|
||||
*/
|
||||
OBC_DESTINATION
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue