当前位置: 首页>>代码示例>>Java>>正文


Java PlayerPortalEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerPortalEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerPortalEvent.isCancelled方法的具体用法?Java PlayerPortalEvent.isCancelled怎么用?Java PlayerPortalEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerPortalEvent的用法示例。


在下文中一共展示了PlayerPortalEvent.isCancelled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSound

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@Deprecated
@EventHandler
public void onSound(final PlayerPortalEvent e) {
	if(e.isCancelled()) {
		return;
	}
	
	new BukkitRunnable() {

		@Override
		public void run() {
			e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 1F, 1F);
		}
		
	}.runTaskLater(pl, 5L);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:17,代码来源:PlayerFixPortalSoundEvent.java

示例2: onEntityPortalEvent

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityPortalEvent(PlayerPortalEvent event) {
	if (!event.isCancelled()) {
		ThePlayer tp = plugin.getPlayerHandler().getPlayer(event.getPlayer().getUniqueId());
		
		if (tp.getPortalTimeout() != -1)
			event.setCancelled(true);
	}
}
 
开发者ID:AlessioDP,项目名称:Parties,代码行数:10,代码来源:FollowListener.java

示例3: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:55,代码来源:PlayerList.java

示例4: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPortal(final PlayerPortalEvent event) {
	if (event.isCancelled()) {
		return;
	}
	final Player player = event.getPlayer();

	// Ok so a player portal event begins
	// Find the nearest gate!
	final WorldCoord playerCoord = new WorldCoord(this.playerLocationAtEvent.get(player));
	final Gate nearestGate = Gates.gateFromPortal(playerCoord);

	if (nearestGate != null) {
		event.setCancelled(true);

		// Check teleportation method
		if (!Conf.useVanillaPortals) {
			return;
		}

		// Check player is not carrying a passenger
		if (player.getPassenger() != null) {
			return;
		}

		// Get current time
		final Long now = Calendar.getInstance().getTimeInMillis();

		// Check player has passed cooldown period
		if (Plugin.lastTeleportTime.containsKey(player.getName()) && Plugin.lastTeleportTime.get(player.getName()) > now - Conf.getGateCooldownMillis()) {
			return;
		}

		// Check player has permission to enter the gate.
		if (!Plugin.hasPermManage(player, "ancientgates.use." + nearestGate.getId()) && !Plugin.hasPermManage(player, "ancientgates.use.*") && Conf.enforceAccess) {
			player.sendMessage("You lack the permissions to enter this gate.");
			return;
		}

		// Handle economy (check player has funds to use gate)
		if (!Plugin.handleEconManage(player, nearestGate.getCost())) {
			player.sendMessage("This gate costs: " + nearestGate.getCost() + ". You have insufficient funds.");
			return;
		}

		// Handle BungeeCord gates (BungeeCord support disabled)
		if (nearestGate.getBungeeTo() != null && Conf.bungeeCordSupport == false) {
			player.sendMessage(String.format("BungeeCord support not enabled."));
			return;
		}

		// Teleport the player (Nether method)
		if (nearestGate.getTo() == null && nearestGate.getBungeeTo() == null && nearestGate.getCommand() == null) {
			player.sendMessage(String.format("This gate does not point anywhere :P"));
		} else if (nearestGate.getTo() != null) {
			TeleportUtil.teleportPlayer(player, nearestGate.getTo(), nearestGate.getTeleportEntities(), nearestGate.getTeleportInventory());

			if (nearestGate.getCommand() != null)
				ExecuteUtil.execCommand(player, nearestGate.getCommand(), nearestGate.getCommandType());
			if (nearestGate.getMessage() != null)
				player.sendMessage(nearestGate.getMessage());

			Plugin.lastTeleportTime.put(player.getName(), now);
		} else if (nearestGate.getBungeeTo() != null) {
			TeleportUtil.teleportPlayer(player, nearestGate.getBungeeTo(), nearestGate.getBungeeType(), nearestGate.getTeleportEntities(), nearestGate.getTeleportInventory(), false, nearestGate.getCommand(), nearestGate.getCommandType(),
					nearestGate.getMessage());
		} else {
			ExecuteUtil.execCommand(player, nearestGate.getCommand(), nearestGate.getCommandType(), true);
			Plugin.lastTeleportTime.put(player.getName(), now);
		}
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:73,代码来源:PluginPlayerListener.java

示例5: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().t() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.t().adjustExit(entityplayer, exit, velocity); // Should be getTravelAgent
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:55,代码来源:PlayerList.java

示例6: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(entityplayer.getBukkitEntity(), enter, exit, cause);
    Bukkit.getServer().getPluginManager().callEvent(tpEvent);
    if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
        return;
    }

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);

   
    entityplayer.ck = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:59,代码来源:PlayerList.java

示例7: onEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onEnter(PlayerPortalEvent e) {
	if(e.isCancelled()) {
		return;
	}

	e.setCancelled(true);

	Block block = getPortalNearby(e.getPlayer().getLocation().getBlock());
	if(!(block instanceof Block)) {
		return;
	}
	for(Portal portal : pl.getConfiguration().getPortalConfig().getPortals().values()) {
		if(portal.getInnerBlocks().contains(block)) {
			if(pl.getConfiguration().getPortalConfig().getCooldown() > 0) {
				if(time.containsKey(e.getPlayer().getName())) {
					if(time.get(e.getPlayer().getName()) < System.currentTimeMillis()) {
						time.remove(e.getPlayer().getName());
					} else {
						e.setCancelled(true);
						Long millis = (time.get(e.getPlayer().getName())-System.currentTimeMillis());
						String msg = String.format("%d:%s", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
						sendMessage(e.getPlayer(), ChatColor.GRAY + "cooldown please wait: " + ChatColor.GREEN + msg + ChatColor.GRAY + " minutes");
						return;
					}
				} else {
					Date date = new Date(System.currentTimeMillis());
					date.setSeconds(date.getSeconds()+pl.getConfiguration().getPortalConfig().getCooldown());
					time.put(e.getPlayer().getName(), date.getTime());
				}
			}
			e.useTravelAgent(false);
			if(portal.isLinked()) {
				Portal linked = portal.getLinkedPortal();
				if(!(linked instanceof Portal)) {
					e.setCancelled(true);
					return;
				}
				//e.setTo(linked.getInnerBlocks()[(linked.getInnerBlocks().length-1)].getLocation());
				
				e.setTo(linked.getExitLocation());
				e.setCancelled(false);
			} else {
				e.setCancelled(true);
			}
			break;
		}
	}
	e.setCancelled(false);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:52,代码来源:PortalEvent.java

示例8: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.s().adjustExit(entityplayer, exit, velocity);
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:55,代码来源:PlayerList.java


注:本文中的org.bukkit.event.player.PlayerPortalEvent.isCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。