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


Java PlayerTeleportEvent.setCancelled方法代码示例

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


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

示例1: onPearlClip

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
        Location to = event.getTo();
        if (blockedPearlTypes.contains(to.getBlock().getType())) {
            Player player = event.getPlayer();
            player.sendMessage(ChatColor.YELLOW + "You have been detected trying to pearl glitch, your pearl has been refunded and cooldown wiped.");
            plugin.getTimerManager().getEnderPearlTimer().refund(player);

            event.setCancelled(true);
            return;
        }

        to.setX(to.getBlockX() + 0.5);
        to.setZ(to.getBlockZ() + 0.5);
        event.setTo(to);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:PearlGlitchListener.java

示例2: onPearlClip

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
	if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
		Location to = event.getTo();
		if (blockedPearlTypes.contains(to.getBlock().getType())) {
			Player player = event.getPlayer();
			player.sendMessage(ChatColor.RED + "You cannot pearl there.");
			removeCooldown(player);
			event.setCancelled(true);

			return;
		}
		to.setX(to.getBlockX() + 0.5D);
		to.setZ(to.getBlockZ() + 0.5D);
		event.setTo(to);

	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:19,代码来源:EnderpearlListener.java

示例3: on

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.MONITOR)
public void on(PlayerTeleportEvent event) {
    if (!config.isPatchesForceAllowTeleportation()) {
        return;
    }

    Storage storage = Storage.get(event.getPlayer());
    Object value = storage.get("teleportedTo");

    if (value == null) {
        return;
    }

    storage.remove("teleportedTo");
    event.setTo((Location) value);
    event.setCancelled(false);
}
 
开发者ID:RealizedMC,项目名称:Duels,代码行数:18,代码来源:Teleport.java

示例4: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.ENDER_PEARL) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
    
    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:18,代码来源:FlagDef_NoEnderPearl.java

示例5: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.CHORUS_FRUIT) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
    
    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:18,代码来源:FlagDef_NoChorusFruit.java

示例6: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@Override
public void onPlayerTeleport(PlayerTeleportEvent event, BPPlayer bpPlayer)
{
	TeleportCause cause = event.getCause();
	
	if(cause == TeleportCause.ENDER_PEARL)
	{
		CTFGame game = getGame();
		FlagManager flm = game.getFlagManager();
		
		if(flm.isHoldingFlag(bpPlayer))
		{
			Player player = bpPlayer.getPlayer();
			event.setCancelled(true);
			player.sendMessage(MessageType.OTHER_WARNPEARL.getTranslation().getValue());
		}
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:19,代码来源:CTFListener.java

示例7: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onTeleport(final PlayerTeleportEvent e) {
	final Player p = e.getPlayer();
	if (e.getCause().equals(TeleportCause.SPECTATE)
			&& !(p.hasPermission("essentials.tp"))){ 
		e.setCancelled(true);
		p.sendMessage(ChatColor.RED + "You do not have permission to /tp");
	}
	
	if (!e.getFrom().getWorld().equals(e.getTo().getWorld())) {
		MultiverseCore mv = (MultiverseCore) Bukkit.getServer()
				.getPluginManager().getPlugin("Multiverse-Core");
		MVWorldManager wm = mv.getMVWorldManager();
		MultiverseWorld toWorld = wm.getMVWorld(e.getTo().getWorld()
				.getName());
		MultiverseWorld fromWorld = wm.getMVWorld(e.getFrom().getWorld()
				.getName());
		if (toWorld != fromWorld
				&& !p.getGameMode().equals(toWorld.getGameMode())) {
			p.setGameMode(toWorld.getGameMode());
		}
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:24,代码来源:TeleportListener.java

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    // make sure they moved through space
    if (event.getFrom().getX() != event.getTo().getX()
            || event.getFrom().getY() != event.getTo().getY()
            || event.getFrom().getZ() != event.getTo().getZ()) {
        // begin the hunt for the challenger
        Optional<Challenger> challenger = CommonCore.getChallenger(event.getPlayer().getUniqueId());
        // check whether the player is in a round for this minigame
        if (challenger.isPresent() && !((CommonChallenger) challenger.get()).isLeaving()) {
            Boundary bound = challenger.get().getRound().getArena().getBoundary();
            // check whether the player is teleporting out of the arena boundary
            if (!bound.contains(LocationHelper.convertLocation(event.getTo()))) {
                if (challenger.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
                    challenger.get().removeFromRound();
                } else {
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:caseif,项目名称:Steel,代码行数:23,代码来源:PlayerWorldListener.java

示例9: 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();
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:26,代码来源:CanaryPlayerListener.java

示例10: onPlayerChangedWorld

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChangedWorld(PlayerTeleportEvent event){
	World from = event.getFrom().getWorld();
	World to = event.getTo().getWorld();
	
	if(!from.getUID().equals(to.getUID())){
		Player player = event.getPlayer();
		
		if(player.hasPermission("spigotplus.multiworld.leave." + from.getName())){
			if(player.hasPermission("spigotplus.multiworld.enter." + to.getName())){
				// We don't set the event to be "uncanceled" to avoid interfering with
				// the work of other plugins, as we don't care what happens to the event
				// provided that by our books it is allowed.
				return;
			} else {
				player.sendMessage(ChatColor.RED + "You are not permitted to enter this world.");
			}
		} else {
			player.sendMessage(ChatColor.RED + "You are not permitted to leave this world.");
		}
		//event.setTo(event.getFrom());
		event.setCancelled(true);
	}
}
 
开发者ID:robotman3000,项目名称:Spigot-Plus,代码行数:25,代码来源:WorldManager.java

示例11: 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);    		
       	}
   	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPMine19.java

示例12: 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);
            }
        }
    }

}
 
开发者ID:jonthesquirrel,项目名称:SpectateTP,代码行数:17,代码来源:SpectateTP.java

示例13: 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);
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:PlayerEvents.java

示例14: PlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void PlayerTeleport(final PlayerTeleportEvent event)
{
	final Player player = event.getPlayer();
	if (plugin.isLoggedIn(player))
	{
		final LoginPlayerData playerdata = plugin.getPlayerData(player);
		if (playerdata != null)
			playerdata.notifyAction();
		return;
	}
	if (playerListener.getMovementBlocker(player) == null)
		return;
	switch (event.getCause())
	{
		case PLUGIN:
			playerListener.setMovementBlocker(player, event.getTo());
		case UNKNOWN:
			return;
		default:
			event.setCancelled(true);
			plugin.sendAuthReminderMessage(event.getPlayer());
	}
}
 
开发者ID:ST-DDT,项目名称:CrazyLogin,代码行数:25,代码来源:DynamicPlayerListener.java

示例15: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
/**
 * Prevent teleporting outside the map
 */
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
    if(event.getCause() == PlayerTeleportEvent.TeleportCause.PLUGIN) {
        double fromY = event.getFrom().getY();
        double toY = event.getTo().getY();

        if((fromY >= 0.0D && fromY < 255.0D) && (toY < 0.0D || toY >= 255.0D)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:InternalMatchModule.java


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