當前位置: 首頁>>代碼示例>>Java>>正文


Java TeleportCause.ENDER_PEARL屬性代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL屬性的典型用法代碼示例。如果您正苦於以下問題:Java TeleportCause.ENDER_PEARL屬性的具體用法?Java TeleportCause.ENDER_PEARL怎麽用?Java TeleportCause.ENDER_PEARL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.event.player.PlayerTeleportEvent.TeleportCause的用法示例。


在下文中一共展示了TeleportCause.ENDER_PEARL屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerTeleport

@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,代碼行數:17,代碼來源:FlagDef_NoEnderPearl.java

示例2: onPlayerTeleport

@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,代碼行數:18,代碼來源:CTFListener.java

示例3: callCoarsePlayerMove

/**
 * Fire a CoarsePlayerMoveEvent that wraps the given event, only if it crosses
 * a block boundary, or the PoseFlags change.
 * @param event         The movement event to potentially wrap
 * @return True if the original event was not cancelled, and a coarse event was fired,
 *         and that coarse event was cancelled. In this case, the wrapped event won't
 *         actually be cancelled, but callers should treat it like it is.
 */
private boolean callCoarsePlayerMove(final PlayerMoveEvent event) {
    // Don't fire coarse events for teleports that are not "in-game"
    // e.g. /jumpto command
    if(event instanceof PlayerTeleportEvent) {
        PlayerTeleportEvent teleportEvent = (PlayerTeleportEvent) event;
        if(teleportEvent.getCause() != TeleportCause.ENDER_PEARL &&
           teleportEvent.getCause() != TeleportCause.UNKNOWN) {
            return false;
        }
    }

    // If the movement does not cross a block boundary, and no PoseFlags changed, we don't care about it
    final EntityLocation from = event.getEntityFrom();
    final EntityLocation to = event.getEntityTo();
    if(from.position().coarseEquals(to.position()) && from.poseFlags().equals(to.poseFlags())) {
        return false;
    }

    // Remember whether the original event was already cancelled
    boolean wasCancelled = event.isCancelled();

    CoarsePlayerMoveEvent generalEvent = new CoarsePlayerMoveEvent(event, event.getPlayer(), from, to);
    this.eventBus.callEvent(generalEvent);

    if(!wasCancelled && generalEvent.isCancelled()) {
        // When a coarse event is cancelled, we have our own logic for resetting the
        // player's position, so we un-cancel the event and instead modify its
        // to location to put the player where we want them.
        resetPosition(event);
        return true;
    } else {
        return false;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:42,代碼來源:PlayerMovementListener.java

示例4: onPlayerTeleport

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerTeleport(PlayerTeleportEvent e) {
	final Player player = e.getPlayer();
    if (this.getRemainingServerFrozenMillis() > 0L || this.getRemainingPlayerFrozenMillis(player.getUniqueId()) > 0L) {
    	if(e.getCause() == TeleportCause.ENDER_PEARL) {
    		player.sendMessage(ChatColor.RED + "You may not pearl while frozen!");
    		e.setCancelled(true);
    	}
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:10,代碼來源:FreezeCommand.java

示例5: onPlayerTeleport

/**
 * On player teleport.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {

	Location loc = event.getTo();
	Player player = event.getPlayer();
	PlayerConfEntry entry = playerConf.get(player);
	IDummyLand land;

	// BugFix Citizens plugin
	if (entry == null) {
		return;
	}

	if (!entry.hasTpCancel()) {
		updatePosInfo(event, entry, loc, false);
	} else {
		entry.setTpCancel(false);
	}

	land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(player.getLocation());

	// TP With ender pearl
	if (!playerConf.get(event.getPlayer()).isAdminMod()
			&& event.getCause() == TeleportCause.ENDER_PEARL
			&& !checkPermission(land, player,
					PermissionList.ENDERPEARL_TP.getPermissionType())) {
		messagePermission(player);
		event.setCancelled(true);
	}
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:36,代碼來源:PlayerListener.java

示例6: onPlayerTeleport

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
        getBackend().logTeleport(event.getPlayer());
    }

    AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
 
開發者ID:Obsidian-Realm,項目名稱:AntiCheat-COMPAT,代碼行數:8,代碼來源:PlayerListener.java

示例7: onPlayerTeleport

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
	if (event.getCause() == TeleportCause.ENDER_PEARL) {
		if (event.getTo().getY() >= PEARL_MAX_HEIGHT) {
			if (GIVE_BACK_PEARL) {
				event.getPlayer().getInventory().addItem(new ItemStack(Material.ENDER_PEARL, 1));
			}
			event.setCancelled(true);
		}
	}
}
 
開發者ID:UltrahardcoreStats,項目名稱:PVPManagerOld,代碼行數:11,代碼來源:EnderPearlListener.java

示例8: checkLaneMovement

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void checkLaneMovement(final CoarsePlayerMoveEvent event) {
    MatchPlayer player = this.match.getPlayer(event.getPlayer());
    if(player == null ||
       !player.canInteract() ||
       !(player.getParty() instanceof Team) ||
       player.getBukkit().getGameMode() == GameMode.CREATIVE ||
       event.getTo().getY() <= 0) return;

    Region laneRegion = this.lanes.get(player.getParty());
    if(laneRegion == null) return;

    boolean containsFrom = laneRegion.contains(event.getBlockFrom().toVector());
    boolean containsTo = laneRegion.contains(event.getBlockTo().toVector());

    // prevent ender pearling to the other lane
    if(!containsTo && event.getCause() instanceof PlayerTeleportEvent) {
        if(((PlayerTeleportEvent) event.getCause()).getCause() == TeleportCause.ENDER_PEARL) {
            event.setCancelled(true, new TranslatableComponent("match.lane.enderPearl.disabled"));
            return;
        }
    }

    if(this.voidPlayers.contains(player.getPlayerId())) {
        event.getPlayer().setFallDistance(0);
        // they have been marked as "out of lane"
        if(containsTo && !containsFrom) {
            // prevent the player from re-entering the lane
            event.setCancelled(true, new TranslatableComponent("match.lane.reEntry.disabled"));
        } else {
            // if they are going to land on something, teleport them underneith it
            Block under = event.getTo().clone().add(new Vector(0, -1, 0)).getBlock();
            if(under != null && under.getType() != Material.AIR) {
                // teleport them to the lowest block
                Vector safe = getSafeLocationUnder(under);
                EntityLocation safeLocation = event.getPlayer().getEntityLocation();
                safeLocation.setPosition(safe);
                event.setTo(safeLocation);
            }
        }
    } else {
        if(!containsFrom && !containsTo) {
            // they are outside of the lane
            if(isIllegallyOutsideLane(laneRegion, event.getTo())) {
                this.voidPlayers.add(player.getPlayerId());
                event.getPlayer().sendMessage(ChatColor.RED + PGMTranslations.t("match.lane.exit", player));
            }
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:50,代碼來源:LaneMatchModule.java

示例9: onPlayerTeleport

@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
	Player player = event.getPlayer();
	PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
	
	//FEATURE: prevent players from using ender pearls to gain access to secured claims
	if(event.getCause() == TeleportCause.ENDER_PEARL && GriefPrevention.instance.config_claims_enderPearlsRequireAccessTrust)
	{
		Claim toClaim = this.dataStore.getClaimAt(player.getLocation(), false, playerData.lastClaim);
		if(toClaim != null)
		{
			playerData.lastClaim = toClaim;
			String noAccessReason = toClaim.allowAccess(player);
			if(noAccessReason != null)
			{
				GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason);
				event.setCancelled(true);
			}
		}
	}
	
	//FEATURE: prevent teleport abuse to win sieges
	
	//these rules only apply to siege worlds only
	if(!GriefPrevention.instance.config_siege_enabledWorlds.contains(player.getWorld())) return;
	
	Location source = event.getFrom();
	Claim sourceClaim = this.dataStore.getClaimAt(source, false, playerData.lastClaim);
	if(sourceClaim != null && sourceClaim.siegeData != null)
	{
		GriefPrevention.sendMessage(player, TextMode.Err, Messages.SiegeNoTeleport);
		event.setCancelled(true);
		return;
	}
	
	Location destination = event.getTo();
	Claim destinationClaim = this.dataStore.getClaimAt(destination, false, null);
	if(destinationClaim != null && destinationClaim.siegeData != null)
	{
		GriefPrevention.sendMessage(player, TextMode.Err, Messages.BesiegedNoTeleport);
		event.setCancelled(true);
		return;
	}
}
 
開發者ID:john01dav,項目名稱:GriefPreventionPlus,代碼行數:45,代碼來源:PlayerEventHandler.java


注:本文中的org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。