本文整理匯總了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;
}