本文整理汇总了Java中org.bukkit.event.player.PlayerTeleportEvent.TeleportCause方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerTeleportEvent.TeleportCause方法的具体用法?Java PlayerTeleportEvent.TeleportCause怎么用?Java PlayerTeleportEvent.TeleportCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerTeleportEvent
的用法示例。
在下文中一共展示了PlayerTeleportEvent.TeleportCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
/**
* Teleports a {@link Player} to a {@link Location} with a delay.
*
* @param player
* the {@link Player} to teleport
* @param location
* the {@link Location} to teleport to
* @param millis
* the time in milliseconds until teleport
* @param warmupMessage
* the message to send whilst waiting
* @param cause
* the cause for teleporting
* @return true if {@link Player} was successfully teleported
*/
public boolean teleport(Player player, Location location, long millis, String warmupMessage, PlayerTeleportEvent.TeleportCause cause) {
cancelTeleport(player, null); // cancels any previous teleport for the player.
boolean result;
if (millis <= 0) { // if there is no delay, just instantly teleport.
result = player.teleport(location, cause);
clearCooldown(player.getUniqueId());
} else {
UUID uuid = player.getUniqueId();
player.sendMessage(warmupMessage);
destinationMap.put(uuid, location.clone());
setCooldown(player, uuid, millis, true, null);
result = true;
}
return result;
}
示例2: onTp
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onTp(PlayerTeleportEvent event) {
Player player = event.getPlayer();
PlayerTeleportEvent.TeleportCause cause = event.getCause();
if (cause.toString().equals("SPECTATE")) {
if (!player.hasPermission("spectatetp.tp")) {
event.setCancelled(true);
if (!deny_message.equals("")) {
player.sendMessage(deny_message);
}
}
}
}
示例3: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
if (getHealth() == 0) {
return false;
}
return super.teleport(location, cause);
}
示例4: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
public void teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
unstack();
for (EEntity entity : entities) {
entity.bukkit().teleport(location, cause);
}
stack();
}
示例5: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { PlayerTeleportEvent.TeleportCause cause = e.getCause();
Player player = e.getPlayer();
if (((redTeam.contains(player)) || (blueTeam.contains(player))) &&
(cause == PlayerTeleportEvent.TeleportCause.ENDER_PEARL))
e.setCancelled(true);
}
示例6: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
if (this.getPassenger() != null || this.isDead()) {
return false;
}
if (this.eject()) {
getHandle().setTransform(LocationConverter.toTransform(location));
// CraftBukkit apparently does not throw an event when this method is called
return true;
}
return false;
}
示例7: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
net.minecraft.entity.player.EntityPlayerMP entity = getHandle();
if (getHealth() == 0 || entity.isDead) {
return false;
}
if (entity.playerNetServerHandler == null || entity.playerNetServerHandler.isDisconnected()) {
return false;
}
// Spigot Start
// if (entity.vehicle != null || entity.passenger != null) {
// return false;
// }
// Spigot End
// From = Players current Location
Location from = this.getLocation();
// To = Players new Location if Teleport is Successful
Location to = location;
// Create & Call the Teleport Event.
PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
server.getPluginManager().callEvent(event);
// Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
if (event.isCancelled()) {
return false;
}
// Spigot Start
eject();
leaveVehicle();
// Spigot End
// Update the From Location
from = event.getFrom();
// Grab the new To Location dependent on whether the event was cancelled.
to = event.getTo();
// Grab the To and From World Handles.
net.minecraft.world.WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle();
net.minecraft.world.WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
// Close any foreign inventory
if (getHandle().openContainer != getHandle().inventoryContainer) {
getHandle().closeScreen();
}
// Check if the fromWorld and toWorld are the same.
if (fromWorld == toWorld) {
entity.playerNetServerHandler.teleport(to);
} else {
server.getHandle().respawnPlayer(entity, toWorld.dimension, cause, to); // Cauldron
}
return true;
}
示例8: DelayedPlayerTeleportEvent
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
public DelayedPlayerTeleportEvent(Player player, Location from, Location to, PlayerTeleportEvent.TeleportCause cause) {
this.player = PlayerModule.getInstance().getPlayer(player);
this.from = from;
this.to = to;
this.cause = cause;
}
示例9: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause teleportCause) {
return implementation.teleport(location, teleportCause);
}
示例10: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport( Location location, PlayerTeleportEvent.TeleportCause teleportCause ) {
return this.teleport( location );
}
示例11: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport( Location location, PlayerTeleportEvent.TeleportCause teleportCause ) {
return false;
}
示例12: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
return player.teleport(location, cause);
}
示例13: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
if (!Sponge.isServerAvailable()) return false;
return getSpongeEntity().setLocation(convertToSpongeLocation(location));
}
示例14: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
return false;
}
示例15: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
net.minecraft.entity.player.EntityPlayerMP entity = getHandle();
if (getHealth() == 0 || entity.isDead) {
return false;
}
if (entity.playerNetServerHandler == null || entity.playerNetServerHandler.isDisconnected()) {
return false;
}
// Spigot Start
// if (entity.vehicle != null || entity.passenger != null) {
// return false;
// }
// Spigot End
// From = Players current Location
Location from = this.getLocation();
// To = Players new Location if Teleport is Successful
Location to = location;
// Create & Call the Teleport Event.
PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
server.getPluginManager().callEvent(event);
// Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
if (event.isCancelled()) {
return false;
}
// Spigot Start
eject();
leaveVehicle();
// Spigot End
// Update the From Location
from = event.getFrom();
// Grab the new To Location dependent on whether the event was cancelled.
to = event.getTo();
// Grab the To and From World Handles.
net.minecraft.world.WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle();
net.minecraft.world.WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
// Close any foreign inventory
if (getHandle().openContainer != getHandle().inventoryContainer) {
getHandle().closeScreen();
}
// Check if the fromWorld and toWorld are the same.
if (fromWorld == toWorld) {
entity.playerNetServerHandler.teleport(to);
} else {
server.getHandle().respawnPlayer(entity, toWorld.dimension, false, to); // Cauldron
}
return true;
}