- Add proper javadoc to all events - Use proper handling of the Eventlist in all events: each event has its own EventList and its static method, as specified by Bukkit's Event class - Add common supertype to all AuthMe events - Remove unused events - Remove unused methods (setters to fields that we ignore entirely)
91 lines
2.1 KiB
Java
91 lines
2.1 KiB
Java
package fr.xephi.authme.events;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.Cancellable;
|
|
|
|
/**
|
|
* Common supertype for all AuthMe teleport events.
|
|
*/
|
|
public abstract class AbstractTeleportEvent extends CustomEvent implements Cancellable {
|
|
|
|
private final Player player;
|
|
private final Location from;
|
|
private Location to;
|
|
private boolean isCancelled;
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param isAsync Whether to fire the event asynchronously or not
|
|
* @param player The player
|
|
* @param from The location the player is being teleported away from
|
|
* @param to The teleport destination
|
|
*/
|
|
public AbstractTeleportEvent(boolean isAsync, Player player, Location from, Location to) {
|
|
super(isAsync);
|
|
this.player = player;
|
|
this.from = from;
|
|
this.to = to;
|
|
}
|
|
|
|
/**
|
|
* Constructor, using the player's current location as "from" location.
|
|
*
|
|
* @param isAsync Whether to fire the event asynchronously or not
|
|
* @param player The player
|
|
* @param to The teleport destination
|
|
*/
|
|
public AbstractTeleportEvent(boolean isAsync, Player player, Location to) {
|
|
this(isAsync, player, player.getLocation(), to);
|
|
}
|
|
|
|
/**
|
|
* Return the player planned to be teleported.
|
|
*
|
|
* @return The player
|
|
*/
|
|
public Player getPlayer() {
|
|
return player;
|
|
}
|
|
|
|
/**
|
|
* Return the location the player is being teleported away from.
|
|
*
|
|
* @return The location prior to the teleport
|
|
*/
|
|
public Location getFrom() {
|
|
return from;
|
|
}
|
|
|
|
/**
|
|
* Set the destination of the teleport.
|
|
*
|
|
* @param to The location to teleport the player to
|
|
*/
|
|
public void setTo(Location to) {
|
|
this.to = to;
|
|
}
|
|
|
|
/**
|
|
* Return the destination the player is being teleported to.
|
|
*
|
|
* @return The teleport destination
|
|
*/
|
|
public Location getTo() {
|
|
return to;
|
|
}
|
|
|
|
@Override
|
|
public void setCancelled(boolean isCancelled) {
|
|
this.isCancelled = isCancelled;
|
|
}
|
|
|
|
@Override
|
|
public boolean isCancelled() {
|
|
return isCancelled;
|
|
}
|
|
|
|
|
|
}
|