mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-24 01:01:51 +01:00
Add MVTeleportEvent back in.
This commit is contained in:
parent
e556261e84
commit
5fe8f76c34
@ -13,6 +13,7 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVTeleport;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
|
||||
import com.onarandombox.utils.DestinationFactory;
|
||||
import com.onarandombox.utils.InvalidDestination;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
@ -87,6 +88,12 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
}
|
||||
DestinationFactory df = this.plugin.getDestinationFactory();
|
||||
MVDestination d = df.getDestination(destinationName);
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if(teleportEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d != null && d instanceof InvalidDestination) {
|
||||
sender.sendMessage("Multiverse does not know how to take you to: " + ChatColor.RED + destinationName);
|
||||
return;
|
||||
|
@ -1,33 +1,74 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.onarandombox.utils.MVDestination;
|
||||
|
||||
public class MVTeleportEvent extends Event {
|
||||
/**
|
||||
* Event that gets called when a player use the /mvtp command
|
||||
* @author fernferret
|
||||
*
|
||||
*/
|
||||
public class MVTeleportEvent extends Event implements Cancellable {
|
||||
private static final long serialVersionUID = 854826818438649269L;
|
||||
private Player player;
|
||||
private Player teleportee;
|
||||
private CommandSender teleporter;
|
||||
private MVDestination dest;
|
||||
private String teleportString;
|
||||
private boolean isCancelled;
|
||||
|
||||
|
||||
public MVTeleportEvent(MVDestination dest, Player p, String teleportString) {
|
||||
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter) {
|
||||
super("MVTeleport");
|
||||
this.player = p;
|
||||
this.teleportee = teleportee;
|
||||
this.teleporter = teleporter;
|
||||
this.dest = dest;
|
||||
this.teleportString = teleportString;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
/**
|
||||
* Returns the player who will be teleported by this event.
|
||||
*
|
||||
* @return The player who will be teleported by this event.
|
||||
*/
|
||||
public Player getTeleportee() {
|
||||
return this.teleportee;
|
||||
}
|
||||
|
||||
public String getDestString() {
|
||||
return this.teleportString;
|
||||
/**
|
||||
* Returns the location the player was before the teleport.
|
||||
*
|
||||
* @return The location the player was before the teleport.
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return this.teleportee.getLocation();
|
||||
}
|
||||
|
||||
public Class<? extends MVDestination> getDestType() {
|
||||
return this.dest.getClass();
|
||||
/**
|
||||
* Returns the player who requested the Teleport
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CommandSender getTeleporter() {
|
||||
return this.teleporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the destination that the player will spawn at.
|
||||
*
|
||||
* @return The destination the player will spawn at.
|
||||
*/
|
||||
public MVDestination getDestination() {
|
||||
return this.dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.isCancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user