當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。