geforkt von Mirrors/Paper
Added an EntityCreatePortalEvent
By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
cff0c0ecc5
Commit
77c577bdf8
21
paper-api/src/main/java/org/bukkit/PortalType.java
Normale Datei
21
paper-api/src/main/java/org/bukkit/PortalType.java
Normale Datei
@ -0,0 +1,21 @@
|
|||||||
|
package org.bukkit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents various types of portals that can be made in a world.
|
||||||
|
*/
|
||||||
|
public enum PortalType {
|
||||||
|
/**
|
||||||
|
* This is a Nether portal, made of obsidian.
|
||||||
|
*/
|
||||||
|
NETHER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an Ender portal.
|
||||||
|
*/
|
||||||
|
ENDER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a custom Plugin portal.
|
||||||
|
*/
|
||||||
|
CUSTOM;
|
||||||
|
}
|
@ -745,6 +745,12 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.entity.FoodLevelChangeEvent
|
* @see org.bukkit.event.entity.FoodLevelChangeEvent
|
||||||
*/
|
*/
|
||||||
FOOD_LEVEL_CHANGE(Category.LIVING_ENTITY),
|
FOOD_LEVEL_CHANGE(Category.LIVING_ENTITY),
|
||||||
|
/**
|
||||||
|
* Called when an entity creates a portal in a world
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.entity.EntityCreatePortalEvent
|
||||||
|
*/
|
||||||
|
ENTITY_CREATE_PORTAL(Category.LIVING_ENTITY),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WEATHER EVENTS
|
* WEATHER EVENTS
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.PortalType;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a Living Entity creates a portal in a world.
|
||||||
|
*/
|
||||||
|
public class EntityCreatePortalEvent extends EntityEvent implements Cancellable {
|
||||||
|
private List<BlockState> blocks;
|
||||||
|
private boolean cancelled = false;
|
||||||
|
private PortalType type = PortalType.CUSTOM;
|
||||||
|
|
||||||
|
public EntityCreatePortalEvent(Entity what, List<BlockState> blocks, PortalType type) {
|
||||||
|
super(Type.ENTITY_CREATE_PORTAL, what);
|
||||||
|
|
||||||
|
this.blocks = blocks;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of all blocks associated with the portal.
|
||||||
|
*
|
||||||
|
* @return List of blocks that will be changed.
|
||||||
|
*/
|
||||||
|
public List<BlockState> getBlocks() {
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of portal that is trying to be created.
|
||||||
|
*
|
||||||
|
* @return Type of portal.
|
||||||
|
*/
|
||||||
|
public PortalType getPortalType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
@ -169,4 +169,11 @@ public class EntityListener implements Listener {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onItemDespawn(ItemDespawnEvent event) {}
|
public void onItemDespawn(ItemDespawnEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an entity creates a portal.
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onEntityCreatePortalEvent(EntityCreatePortalEvent event) {}
|
||||||
}
|
}
|
||||||
|
@ -763,6 +763,13 @@ public class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case ENTITY_CREATE_PORTAL:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((EntityListener) listener).onEntityCreatePortalEvent((EntityCreatePortalEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
case CREATURE_SPAWN:
|
case CREATURE_SPAWN:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren