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


Java PlayerPortalEvent.setCancelled方法代码示例

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


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

示例1: onPlayerPortal

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

    Player player = event.getPlayer();
    if (!player.hasPermission("cuteportals.use")) {
        player.sendMessage(ChatColor.DARK_RED + "You don't have permission to use portals.");
        return;
    }

    Block block = player.getWorld().getBlockAt(player.getLocation());
    String data = String.format("%s#%s#%s#%s", block.getWorld().getName(),
            String.valueOf(block.getX()), String.valueOf(block.getY()), String.valueOf(block.getZ()));

    if (plugin.portalData.containsKey(data)) {
         String[] args = plugin.portalData.get(data).split("#");
         plugin.TransferPlayer(player, args[0], args[1]);
         event.setCancelled(true);
    }
}
 
开发者ID:worldbeater,项目名称:CutePortals,代码行数:21,代码来源:EventListener.java

示例2: ClassChanger

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void ClassChanger(final PlayerPortalEvent event)
{
	if(Game.isGameRunning() && event.getPlayer().getGameMode() != GameMode.CREATIVE)
	{
		AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId());
		if(p != null)
		{
			event.setCancelled(true);
			if(p.getTeam() != null)
			{
				final Player pl = event.getPlayer();
				pl.teleport(p.getTeam().getRandomSpawn());
				Bukkit.getScheduler().runTaskLater(AnnihilationMain.getInstance(), new Runnable(){

					@Override
					public void run()
					{
						openKitMap(pl);
					}}, 40);
			}
		}
	}
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:25,代码来源:KitLoading.java

示例3: onPlayerEnterPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerEnterPortal(PlayerPortalEvent e){
	Player p = e.getPlayer();
	
	Region rto = null;
	Region from = null;
	if (e.getTo() != null){
		rto = RedProtect.get().rm.getTopRegion(e.getTo());
	}
	if (e.getFrom() != null){
		from = RedProtect.get().rm.getTopRegion(e.getFrom());
	}
	
	
	if (rto != null && !rto.canExitPortal(p)){
		RPLang.sendMessage(p, "playerlistener.region.cantteleport");
		e.setCancelled(true);
	}    
	
	if (from != null && !from.canEnterPortal(p)){
		RPLang.sendMessage(p, "playerlistener.region.cantenterteleport");
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPPlayerListener.java

示例4: onPortalEvent

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPortalEvent(PlayerPortalEvent event) {
    Player player = event.getPlayer();
    if (usePortals || event.getTo() == null || event.getFrom() == null ||
            (!plugin.isSkyWorld(event.getTo().getWorld()) && !plugin.isSkyWorld(event.getFrom().getWorld())))
    {
        return; // We only care about portals going into or out of skyworld
    }
    if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) {
        return;
    }
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL ||
        event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(player);
        if (islandInfo == null || (!islandInfo.contains(event.getTo()) && !islandInfo.contains(event.getFrom()))) {
            event.setCancelled(true);
            player.sendMessage(tr("\u00a7eYou can not use another islands portals!"));
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:21,代码来源:ExploitEvents.java

示例5: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event) {
	if (!event.getCause().equals(TeleportCause.NETHER_PORTAL)) { return; }

	Location cornerLocation = PortalUtils.findCornerBlock(event.getFrom()).orElse(null);
	if (cornerLocation == null) { debug("Couldnt find cornerLoc for loc: " + Utility.toString(event.getFrom())); return; }

	Portal portal = this.module.storage.getPortal(cornerLocation).orElse(null);
	if (portal == null) { debug("Couldnt find portal for cornerLoc: " + Utility.toString(cornerLocation)); return; }

	CraftoPlayer player = CraftoPlayer.getPlayer(event.getPlayer()).orElse(null);

	if (!event.getPlayer().hasPermission("craftoplugin.portal.always-teleport")) {
		if (player != null && player.getPlaytime().toMinutes() < this.minPlaytime.toMinutes()) {
			debug(event.getPlayer().getName() + " failed to teleport because he doesn't have permission!");
			CraftoMessenger.sendFailure(event.getPlayer(), "Du kannst erst ab " + this.minPlaytime.toMinutes() + " Minuten Spielzeit das Portal nutzen!");
			event.setCancelled(true);
			return;
		}
	}

	event.useTravelAgent(false);
	event.setTo(portal.getDestination());

	debug("Teleported " + event.getPlayer().getName() + " to dest of portal '" + portal.getName() + "'");
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:27,代码来源:PortalListener.java

示例6: onPlayerPortalEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerPortalEnter(final PlayerPortalEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerPortalEnter");

    final Location from = event.getFrom();
    final ChunkCoord coord = new ChunkCoord(from.getChunk());
    final Altar altar = this.plugin.getAltars().get(coord);
    if (altar != null) {
        this.plugin.debug("It's an Altar portal, cancel the event");
        final Location teleportLocation = altar.getCenterLocation().clone().toBukkitLocation().add(2.5, 1, 0.5);
        teleportLocation.setPitch(6f);
        teleportLocation.setYaw(90f);
        event.getPlayer().teleport(teleportLocation);
        event.setCancelled(true);
    }

    this.plugin.exiting(this.getClass(), "onPlayerPortalEnter");
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:19,代码来源:PlayerListener.java

示例7: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
/**
 * Patch player teleporting through portals to be INSIDE the world border
 *
 * @param event Event
 */
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event)
{
    if (!this.game.getPlugin().getServer().getAllowNether() || this.game.getSurvivalGameLoop().isNetherClosed())
    {
        event.setCancelled(true);
        return;
    }
    TravelAgent travelAgent = event.getPortalTravelAgent();
    Location destination = travelAgent.findPortal(event.getTo());

    if (destination != null)
    {
        if (!SafePortalsUtils.isInsideBorder(destination))
        {
            event.useTravelAgent(false);
            boolean success = travelAgent.createPortal(event.getTo());

            if (success)
            {
                event.setTo(travelAgent.findPortal(event.getTo()));

                if (!SafePortalsUtils.isSafeSpot(event.getTo()))
                {
                    Location safeTo = SafePortalsUtils.searchSafeSpot(event.getTo());
                    if (safeTo != null)
                    {
                        event.setTo(safeTo);
                    }
                }
            }
        }
    }
    else
    {
        event.useTravelAgent(true);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:44,代码来源:SecurityListener.java

示例8: 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

示例9: onPlayerPortalEvent

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerPortalEvent(PlayerPortalEvent event) {
	if(event.getCause().equals(TeleportCause.END_PORTAL)) {
		event.setCancelled(true);
		CivMessage.sendErrorNoRepeat(event.getPlayer(), "The End portal is disabled on this server.");
		return;
	}
	
	if (event.getCause().equals(TeleportCause.NETHER_PORTAL)) {
		event.setCancelled(true);
		CivMessage.sendErrorNoRepeat(event.getPlayer(), "The Nether is disabled on this server.");
		return;
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:15,代码来源:PlayerListener.java

示例10: onPlayerUsePortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onPlayerUsePortal(final PlayerPortalEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerUsePortal", "player=" + event.getPlayer().getName() + ";from=" + NLocation.toString(event.getFrom()) + ";to=" + NLocation.toString(event.getTo()));

    final GeneralWorld world = this.plugin.getWorlds().get(event.getFrom().getWorld().getName());
    if (GeneralWorld.WorldType.isStock(world)) {
        return;
    }

    if (world.getType() == WorldType.ADDITIONAL) {
        final AdditionalWorld additionalWorld = (AdditionalWorld)world;
        if (event.getCause() == TeleportCause.NETHER_PORTAL && !additionalWorld.hasNether()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (nether)");
            return;
        } else if (event.getCause() == TeleportCause.END_PORTAL && !additionalWorld.hasEnd()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (end)");
            return;
        }
    }

    final PortalEventResult result = this.handlePortalEvent(event.getFrom(), event.getCause(), event.getPortalTravelAgent());
    if (result == null) {
        return;
    }
    if (result.destination != null) {
        event.setTo(result.destination);
    }
    if (result.useTravelAgent) {
        event.useTravelAgent(true);
    }
    if (result.cancelEvent) {
        event.setCancelled(true);
    }

    this.plugin.exiting(this.getClass(), "onPlayerUsePortal");
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:39,代码来源:NListener.java

示例11: onTeleport

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onTeleport(PlayerPortalEvent e) {
    if (GameStatus.isState(gameStatus))
        e.setCancelled(!canUsePortals);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:6,代码来源:MinigameLogic.java

示例12: onPortalEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPortalEnter(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    Location to = event.getTo();
    World toWorld = to.getWorld();
    if (toWorld == null)
        return; // safe-guard if the End or Nether is disabled

    if (toWorld.getEnvironment() == World.Environment.THE_END) {
        Player player = event.getPlayer();

        // Prevent entering the end if it's closed.
        if (false /* TODO:plugin.getEndManager().isOpened() */) {
            message(player, ChatColor.RED + "The End is currently closed.");
            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is Spawn Tagged.
        PlayerTimer timer = plugin.getTimerManager().getCombatTimer();
        long remaining;
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is PVP Protected.
        timer = plugin.getTimerManager().getInvincibilityTimer();
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        event.useTravelAgent(false);
        event.setTo(toWorld.getSpawnLocation().add(0.5, 0, 0.5));
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:47,代码来源:PortalListener.java

示例13: on

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void on(PlayerPortalEvent event) {
    if (freezer.isCurrentlyFrozen(event.getPlayer().getUniqueId())) {
        event.setCancelled(true);
    }
}
 
开发者ID:Eluinhost,项目名称:FancyFreeze,代码行数:7,代码来源:PortalListener.java

示例14: 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

示例15: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
   public void onPlayerPortal(PlayerPortalEvent event) {
// If the nether is disabled then quit immediately
if (!Settings.createNether) {
    return;
}
Location currentLocation = event.getFrom().clone();
String currentWorld = currentLocation.getWorld().getName();
if (!currentWorld.equalsIgnoreCase(Settings.worldName) && !currentWorld.equalsIgnoreCase(Settings.worldName + "_nether")
	&& !currentWorld.equalsIgnoreCase(Settings.worldName + "_the_end")) {
    return;
}

// Determine what portal it is
switch (event.getCause()) {
case END_PORTAL:
    if (Settings.createEnd) {
	// Same action for all worlds except the end itself
	if (!event.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) {
	    if (ASkyGrid.getEndWorld() != null) {
		// The end exists
		event.setCancelled(true);
		// Convert current location to end world location
		Location end_place = event.getPlayer().getLocation().toVector().toLocation(ASkyGrid.getEndWorld());
		// Set the height to the top of the end grid
		end_place.setY(Settings.gridHeight);
		if (GridManager.isSafeLocation(end_place)) {
		    event.getPlayer().teleport(end_place);
		    return;
		} else {
		    end_place = plugin.getGrid().bigScan(end_place, 10);
		    if (end_place != null) {
			event.getPlayer().teleport(end_place);
		    } else {
			// Try the spawn
			end_place = ASkyGrid.getEndWorld().getSpawnLocation();
			if (GridManager.isSafeLocation(end_place)) {
			    event.getPlayer().teleport(end_place);
			    return;
			} else {
			    event.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).warpserrorNotSafe);
			}
		    }
		    return;
		}
	    }
	} else {
	    // Returning from the end - just go home
	    event.setCancelled(true);
	    plugin.getGrid().homeTeleport(event.getPlayer());
	}
    }
    break;
case NETHER_PORTAL:
    // Get the home world of this player
    if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
	// Going to Nether
	event.setTo(event.getFrom().toVector().toLocation(ASkyGrid.getNetherWorld()));
	event.useTravelAgent(true); 
    } else {
	// Returning
	event.setTo(event.getFrom().toVector().toLocation(ASkyGrid.getGridWorld()));
	event.useTravelAgent(true); 
    }
    break;
default:
    break;
}
   }
 
开发者ID:tastybento,项目名称:askygrid,代码行数:70,代码来源:NetherPortals.java


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