本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerTeleportEvent.isCancelled方法的具體用法?Java PlayerTeleportEvent.isCancelled怎麽用?Java PlayerTeleportEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerTeleportEvent
的用法示例。
在下文中一共展示了PlayerTeleportEvent.isCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isAuthorizedFor
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public boolean isAuthorizedFor(Player base, Location to) {
if (to == null || to.getWorld() == null) {
instance.logToFile(getClass(), base.getUniqueId() + " (" + base.getName() + ") is not authorized to teleport to " + to + "!", Level.WARNING);
return false;
}
Helper.refreshChunk(to);
Helper.updatePosition(base, to);
if (config.isPatchesForceAllowTeleportation()) {
return true;
}
PlayerTeleportEvent event = new PlayerTeleportEvent(base, base.getLocation(), to, PlayerTeleportEvent.TeleportCause.PLUGIN);
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled();
}
示例2: onTeleportation
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onTeleportation(final TeleportHook hook) {
PlayerTeleportEvent event =
new PlayerTeleportEvent(new CanaryPlayer(hook.getPlayer()), new CanaryLocation(hook.getPlayer()
.getLocation(), new CanaryWorld(hook.getDestination().getWorld())), new CanaryLocation(hook
.getDestination(), new CanaryWorld(hook.getDestination().getWorld())),
TeleportCauseConverter.of(hook.getTeleportReason())) {
@Override
public void setFrom(Location from) {
super.setFrom(from);
// How can you do this in Canary?
}
@Override
public void setTo(Location to) {
super.setTo(to);
// How can you do this in Canary?
}
};
event.setCancelled(hook.isCanceled());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
hook.setCanceled();
}
}
示例3: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
return;
}
Location from = event.getFrom();
Location to = event.getTo();
if (from.getWorld().equals(to.getWorld())) {
return;
}
ConsoleLogger.debug("[EVENTS] Player '" + event.getPlayer().getName() + "' going from world '" + from + "' to world '" + to + "'");
Group groupFrom = groupManager.getGroupFromWorld(from.getWorld().getName());
Group groupTo = groupManager.getGroupFromWorld(to.getWorld().getName());
if (groupFrom.equals(groupTo)) {
return;
}
playerManager.addPlayer(event.getPlayer(), groupFrom);
event.getPlayer().closeInventory();
}
示例4: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e){
if (e.isCancelled()) {
return;
}
final Player p = e.getPlayer();
Location lfrom = e.getFrom();
Location lto = e.getTo();
if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)){
final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom);
final Region rto = RedProtect.get().rm.getTopRegion(lto);
if (rfrom != null && !rfrom.canTeleport(p)){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
if (rto != null && !rto.canTeleport(p)){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
}
}
示例5: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onTeleport(PlayerTeleportEvent event) {
if (event.isCancelled() || !plugin.isSkyWorld(event.getTo().getWorld())) {
return;
}
final Player player = event.getPlayer();
boolean isAdmin = player.isOp() || hasPermission(player, "usb.mod.bypassprotection");
IslandInfo islandInfo = uSkyBlock.getInstance().getIslandInfo(WorldGuardHandler.getIslandNameAt(event.getTo()));
if (!isAdmin && islandInfo != null && islandInfo.isBanned(player.getUniqueId())) {
event.setCancelled(true);
player.sendMessage(tr("\u00a74That player has forbidden you from teleporting to their island."));
}
if (!isAdmin && islandInfo != null && islandInfo.isLocked() && !islandInfo.getMembers().contains(player.getName()) && !islandInfo.getTrustees().contains(player.getName())) {
event.setCancelled(true);
player.sendMessage(tr("\u00a74That island is \u00a7clocked.\u00a7e No teleporting to the island."));
}
if (!event.isCancelled()) {
final PlayerInfo playerInfo = plugin.getPlayerInfo(player);
playerInfo.onTeleport(player);
}
}
示例6: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if(event.isCancelled()) return;
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && event.getTo() != tos.get(event.getPlayer().getName())) {
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
to.setPitch(event.getTo().getPitch());
to.setYaw(event.getTo().getYaw());
tos.put(event.getPlayer().getName(), to);
event.getPlayer().teleport(to);
if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
}
}
}
示例7: onPlayerMove
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(PlayerTeleportEvent event) {
if (event.isCancelled() || TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver()) return;
if (region.contains(event.getTo().toVector()) && !region.contains(event.getFrom().toVector()) && (filter == null || filter.evaluate(event.getPlayer(), event.getTo(), event).equals(FilterState.ALLOW))) {
kit.apply(event.getPlayer());
}
}
示例8: a
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void a(double d0, double d1, double d2, float f, float f1) {
// CraftBukkit start - Delegate to teleport(Location)
Player player = this.getPlayer();
Location from = player.getLocation();
Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1);
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
this.teleport(to);
}
示例9: setPlayerLocation
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_)
{
// CraftBukkit start - Delegate to teleport(Location)
Player player = this.getPlayerB();
Location from = player.getLocation();
Location to = new Location(this.getPlayerB().getWorld(), p_147364_1_, p_147364_3_, p_147364_5_, p_147364_7_, p_147364_8_);
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
this.teleport(to);
}
示例10: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerTeleport(final PlayerTeleportEvent event) {
if (!this.frozenPlayers.isEmpty() && !event.isCancelled() && this.frozenPlayers.containsKey(event.getPlayer().getUniqueId())) {
final Location l = event.getTo();
final Location3w frozenLoc = this.frozenPlayers.get(event.getPlayer().getUniqueId());
if (l.getBlockX() != frozenLoc.getBlockX() || l.getBlockY() != frozenLoc.getBlockY() || l.getBlockZ() != frozenLoc.getBlockZ()) {
event.setCancelled(true);
}
}
}
示例11: a
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void a(Entity entity) {
if (!this.world.isClientSide && !this.e()) {
this.g = 100;
if (this.exitPortal == null && this.world.worldProvider instanceof WorldProviderTheEnd) {
this.l();
}
if (this.exitPortal != null) {
BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.k();
// CraftBukkit start - Fire PlayerTeleportEvent
if (entity instanceof EntityPlayer) {
org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity.getBukkitEntity();
org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
Bukkit.getPluginManager().callEvent(teleEvent);
if (teleEvent.isCancelled()) {
return;
}
((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo());
this.i();
return;
}
// CraftBukkit end
entity.enderTeleportTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
}
this.i();
}
}
示例12: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerTeleport(final ExtendedPlayerTeleportEvent ext) {
final PlayerTeleportEvent event = (PlayerTeleportEvent)ext.getBaseEvent();
if (!event.isCancelled()) {
if (!ext.getToRegion().getFlag(Flag.PVP_HIDE) && !ext.getToRegion().getFlag(Flag.PVP) && !ext.getFromRegions().contains(ext.getToRegion())) {
// Entering PVP Area
this.getPlugin().sendMessage(event.getPlayer(), MessageId.cuboid_enteringPvpArea, ext.getToRegion().getRegionName());
} else if (!ext.getFromRegion().getFlag(Flag.PVP_HIDE) && !ext.getFromRegion().getFlag(Flag.PVP) && !ext.getToRegions().contains(ext.getFromRegion())) {
// Exiting PVP Area
this.getPlugin().sendMessage(event.getPlayer(), MessageId.cuboid_exitingPvpArea, ext.getFromRegion().getRegionName());
}
}
}
示例13: illegalTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void illegalTeleport(PlayerTeleportEvent event) {
if (!event.getPlayer().getName().equals(player.getName()))
return;
if (event.isCancelled() == true)
return;
if (player.hasPermission("kidstimeout"))
return;
player.sendMessage("Your attempt to escape prison was foiled!");
event.setCancelled(true);
return;
}
示例14: 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;
}
示例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;
}