13
0
geforkt von Mirrors/Paper

Added PlayerVelocityEvent. Thanks Evenprime!

By: EvilSeph <evilseph@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-07-28 01:17:07 -04:00
Ursprung 26707ee929
Commit c9b9f56903
4 geänderte Dateien mit 85 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -197,6 +197,13 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.player.PlayerMoveEvent
*/
PLAYER_MOVE (Category.PLAYER),
/**
* Called before a player gets a velocity vector sent, which will instruct him to
* get "pushed" into a specific direction, e.g. after an explosion
*
* @see org.bukkit.event.player.PlayerVelocityEvent
*/
PLAYER_VELOCITY (Category.PLAYER),
/**
* Called when a player undergoes an animation (Arm Swing is the only animation currently supported)
*

Datei anzeigen

@ -51,6 +51,14 @@ public class PlayerListener implements Listener {
*/
public void onPlayerMove(PlayerMoveEvent event) {}
/**
* Called before a player gets a velocity vector sent, which will "push"
* the player in a certain direction
*
* @param event Relevant event details
*/
public void onPlayerVelocity(PlayerVelocityEvent event) {}
/**
* Called when a player attempts to teleport to a new location in a world
*

Datei anzeigen

@ -0,0 +1,63 @@
package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.util.Vector;
public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
/**
* Holds information for player velocity events
*/
private boolean cancel = false;
private Vector velocity;
public PlayerVelocityEvent(final Player player, final Vector velocity) {
super(Type.PLAYER_VELOCITY, player);
this.velocity = velocity;
}
PlayerVelocityEvent(final Event.Type type, final Player player, final Vector velocity) {
super(type, player);
this.velocity = velocity;
}
/**
* Gets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is cancelled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A cancelled 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;
}
/**
* Gets the velocity vector that will be sent to the player
*
* @return Vector the player will get
*/
public Vector getVelocity() {
return velocity;
}
/**
* Sets the velocity vector that will be sent to the player
*
* @param velocity The velocity vector that will be sent to the player
*/
public void setVelocity(Vector velocity) {
this.velocity = velocity;
}
}

Datei anzeigen

@ -287,6 +287,13 @@ public final class JavaPluginLoader implements PluginLoader {
}
};
case PLAYER_VELOCITY:
return new EventExecutor() {
public void execute(Listener listener, Event event) {
((PlayerListener) listener).onPlayerVelocity((PlayerVelocityEvent) event);
}
};
case PLAYER_TELEPORT:
return new EventExecutor() {
public void execute(Listener listener, Event event) {