geforkt von Mirrors/Paper
Added cause to PlayerTeleportEvent
By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
c90d52a4d3
Commit
f3ddaaf09f
@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
public class TeleportCommand extends VanillaCommand {
|
public class TeleportCommand extends VanillaCommand {
|
||||||
public TeleportCommand() {
|
public TeleportCommand() {
|
||||||
@ -31,7 +32,7 @@ public class TeleportCommand extends VanillaCommand {
|
|||||||
sender.sendMessage("Can't find user " + args[1] + ". No tp.");
|
sender.sendMessage("Can't find user " + args[1] + ". No tp.");
|
||||||
} else {
|
} else {
|
||||||
Command.broadcastCommandMessage(sender, "Teleporting " + victim.getName() + " to " + target.getName());
|
Command.broadcastCommandMessage(sender, "Teleporting " + victim.getName() + " to " + target.getName());
|
||||||
victim.teleport(target);
|
victim.teleport(target, TeleportCause.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a base entity in the world
|
* Represents a base entity in the world
|
||||||
@ -50,6 +51,15 @@ public interface Entity {
|
|||||||
*/
|
*/
|
||||||
public boolean teleport(Location location);
|
public boolean teleport(Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports this entity to the given location
|
||||||
|
*
|
||||||
|
* @param location New location to teleport this entity to
|
||||||
|
* @praram cause The cause of this teleportation
|
||||||
|
* @return <code>true</code> if the teleport was successful
|
||||||
|
*/
|
||||||
|
public boolean teleport(Location location, TeleportCause cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports this entity to the target Entity
|
* Teleports this entity to the target Entity
|
||||||
*
|
*
|
||||||
@ -58,6 +68,15 @@ public interface Entity {
|
|||||||
*/
|
*/
|
||||||
public boolean teleport(Entity destination);
|
public boolean teleport(Entity destination);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports this entity to the target Entity
|
||||||
|
*
|
||||||
|
* @param destination Entity to teleport this entity to
|
||||||
|
* @praram cause The cause of this teleportation
|
||||||
|
* @return <code>true</code> if the teleport was successful
|
||||||
|
*/
|
||||||
|
public boolean teleport(Entity destination, TeleportCause cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of entities within a bounding box defined by x,y,z centered around player
|
* Returns a list of entities within a bounding box defined by x,y,z centered around player
|
||||||
*
|
*
|
||||||
|
@ -8,11 +8,52 @@ import org.bukkit.event.Event;
|
|||||||
* Holds information for player teleport events
|
* Holds information for player teleport events
|
||||||
*/
|
*/
|
||||||
public class PlayerTeleportEvent extends PlayerMoveEvent {
|
public class PlayerTeleportEvent extends PlayerMoveEvent {
|
||||||
|
private TeleportCause cause = TeleportCause.UNKNOWN;
|
||||||
|
|
||||||
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(Player player, Location from, Location to, TeleportCause cause) {
|
||||||
|
super(Type.PLAYER_TELEPORT, player, from, to);
|
||||||
|
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to) {
|
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to) {
|
||||||
super(type, player, from, to);
|
super(type, player, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerTeleportEvent(final Event.Type type, Player player, Location from, Location to, TeleportCause cause) {
|
||||||
|
super(type, player, from, to);
|
||||||
|
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cause of this teleportation event
|
||||||
|
* @return Cause of the event
|
||||||
|
*/
|
||||||
|
public TeleportCause getCause() {
|
||||||
|
return cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TeleportCause {
|
||||||
|
/**
|
||||||
|
* Indicates the teleporation was caused by a player throwing an Ender Pearl
|
||||||
|
*/
|
||||||
|
ENDER_PEARL,
|
||||||
|
/**
|
||||||
|
* Indicates the teleportation was caused by a player executing a command
|
||||||
|
*/
|
||||||
|
COMMAND,
|
||||||
|
/**
|
||||||
|
* Indicates the teleportation was caused by a plugin
|
||||||
|
*/
|
||||||
|
PLUGIN,
|
||||||
|
/**
|
||||||
|
* Indicates the teleportation was caused by an event not covered by this enum
|
||||||
|
*/
|
||||||
|
UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren