Added various 1.6 portal events.
This commit is contained in:
parent
91b68e82cf
commit
55bc828c2c
@ -229,6 +229,12 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.player.PlayerMoveEvent
|
* @see org.bukkit.event.player.PlayerMoveEvent
|
||||||
*/
|
*/
|
||||||
PLAYER_TELEPORT (Category.PLAYER),
|
PLAYER_TELEPORT (Category.PLAYER),
|
||||||
|
/**
|
||||||
|
* Called when a player completes the portaling process by standing in a portal
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerPortalEvent
|
||||||
|
*/
|
||||||
|
PLAYER_PORTAL (Category.PLAYER),
|
||||||
/**
|
/**
|
||||||
* Called when a player changes their held item
|
* Called when a player changes their held item
|
||||||
*
|
*
|
||||||
@ -483,6 +489,12 @@ public abstract class Event implements Serializable {
|
|||||||
* Called when a World is unloaded
|
* Called when a World is unloaded
|
||||||
*/
|
*/
|
||||||
WORLD_UNLOAD (Category.WORLD),
|
WORLD_UNLOAD (Category.WORLD),
|
||||||
|
/**
|
||||||
|
* Called when world attempts to create a matching end to a portal
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.world.PortalCreateEvent
|
||||||
|
*/
|
||||||
|
PORTAL_CREATE (Category.WORLD),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ENTITY EVENTS
|
* ENTITY EVENTS
|
||||||
@ -500,6 +512,12 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.painting.PaintingRemoveEvent
|
* @see org.bukkit.event.painting.PaintingRemoveEvent
|
||||||
*/
|
*/
|
||||||
PAINTING_BREAK (Category.ENTITY),
|
PAINTING_BREAK (Category.ENTITY),
|
||||||
|
/**
|
||||||
|
* Called when an entity touches a portal block
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.entity.EntityPortalEnterEvent
|
||||||
|
*/
|
||||||
|
ENTITY_PORTAL_ENTER (Category.ENTITY),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIVING_ENTITY EVENTS
|
* LIVING_ENTITY EVENTS
|
||||||
|
@ -26,6 +26,8 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
public void onEntityInteract(EntityInteractEvent event) {}
|
public void onEntityInteract(EntityInteractEvent event) {}
|
||||||
|
|
||||||
|
public void onEntityPortalEnter(EntityPortalEnterEvent event) {}
|
||||||
|
|
||||||
public void onPaintingPlace(PaintingPlaceEvent event) {}
|
public void onPaintingPlace(PaintingPlaceEvent event) {}
|
||||||
|
|
||||||
public void onPaintingBreak(PaintingBreakEvent event) {}
|
public void onPaintingBreak(PaintingBreakEvent event) {}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data for entities standing inside a portal block
|
||||||
|
*/
|
||||||
|
public class EntityPortalEnterEvent extends EntityEvent {
|
||||||
|
|
||||||
|
private Location location;
|
||||||
|
|
||||||
|
public EntityPortalEnterEvent(Entity entity, Location location) {
|
||||||
|
super(Type.ENTITY_PORTAL_ENTER, entity);
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the portal block the entity is touching
|
||||||
|
* @return The portal block the entity is touching
|
||||||
|
*/
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
@ -183,6 +183,13 @@ public class PlayerListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {}
|
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player is teleporting in a portal (after the animation)
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerPortal(PlayerPortalEvent event) {}
|
||||||
|
|
||||||
// TODO: Remove after RB
|
// TODO: Remove after RB
|
||||||
@Deprecated public void onPlayerQuit(PlayerEvent event) {}
|
@Deprecated public void onPlayerQuit(PlayerEvent event) {}
|
||||||
@Deprecated public void onPlayerCommandPreprocess(PlayerChatEvent event) {}
|
@Deprecated public void onPlayerCommandPreprocess(PlayerChatEvent event) {}
|
||||||
|
22
src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
Normal file
22
src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player completes the portaling process by standing in a portal
|
||||||
|
*/
|
||||||
|
public class PlayerPortalEvent extends PlayerTeleportEvent {
|
||||||
|
private boolean useTravelAgent = true;
|
||||||
|
public PlayerPortalEvent(Player player, Location from, Location to) {
|
||||||
|
super(Type.PLAYER_PORTAL, player, from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void useTravelAgent(boolean useTravelAgent){
|
||||||
|
this.useTravelAgent = useTravelAgent;
|
||||||
|
}
|
||||||
|
public boolean useTravelAgent(){
|
||||||
|
return useTravelAgent;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package org.bukkit.event.player;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds information for player teleport events
|
* Holds information for player teleport events
|
||||||
@ -10,4 +11,7 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
|
|||||||
public PlayerTeleportEvent(Player player, Location from, Location to) {
|
public PlayerTeleportEvent(Player player, Location from, Location to) {
|
||||||
super(Type.PLAYER_TELEPORT, player, from, to);
|
super(Type.PLAYER_TELEPORT, player, from, to);
|
||||||
}
|
}
|
||||||
|
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to) {
|
||||||
|
super(type, player, from, to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
43
src/main/java/org/bukkit/event/world/PortalCreateEvent.java
Normal file
43
src/main/java/org/bukkit/event/world/PortalCreateEvent.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package org.bukkit.event.world;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the world attempts to create a matching end to a portal
|
||||||
|
*/
|
||||||
|
public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||||
|
private boolean cancel = false;
|
||||||
|
private ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
|
||||||
|
public PortalCreateEvent(final ArrayList<Block> blocks, final World world) {
|
||||||
|
super(Type.PORTAL_CREATE, world);
|
||||||
|
this.blocks = blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Block> getBlocks(){
|
||||||
|
return this.blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cancellation state of this event. A canceled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* @return true if this event is canceled
|
||||||
|
*/
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event. A canceled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,13 @@ public class WorldListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
public void onSpawnChange(SpawnChangeEvent event) {}
|
public void onSpawnChange(SpawnChangeEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the world generates a portal end point
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPortalCreate(PortalCreateEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a world is saved
|
* Called when a world is saved
|
||||||
*
|
*
|
||||||
|
@ -293,6 +293,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case PLAYER_PORTAL:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((PlayerListener) listener).onPlayerPortal((PlayerPortalEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
case PLAYER_INTERACT:
|
case PLAYER_INTERACT:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
@ -562,6 +569,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case PORTAL_CREATE:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((WorldListener) listener).onPortalCreate((PortalCreateEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Painting Events
|
// Painting Events
|
||||||
case PAINTING_PLACE:
|
case PAINTING_PLACE:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
@ -627,6 +641,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case ENTITY_PORTAL_ENTER:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((EntityListener) listener).onEntityPortalEnter((EntityPortalEnterEvent) 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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user