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


Java PlayerPortalEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerPortalEvent的典型用法代碼示例。如果您正苦於以下問題:Java PlayerPortalEvent類的具體用法?Java PlayerPortalEvent怎麽用?Java PlayerPortalEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (!this.worldConfig.getBoolean("special-travel-agent", true)) {
        return;
    }

    Location destination = event.getTo();

    if (destination == null) {
        return;
    }

    World targetWorld = destination.getWorld();

    if (targetWorld.getName() != this.nmsWorld.worldData.getName()) {
        return;
    }

    if (this.worldConfig.getBoolean("enabled", false)) {
        event.setPortalTravelAgent(this.portalTravelAgent);
    }
}
 
開發者ID:OtakuMegane,項目名稱:TallNether,代碼行數:23,代碼來源:LoadHell.java

示例2: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    if (event.getTo() != null) {
        World toWorld = event.getTo().getWorld();
        if (toWorld != null && toWorld.getEnvironment() == World.Environment.THE_END) {
            event.useTravelAgent(false);
            event.setTo(toWorld.getSpawnLocation());
            return;
        }
    }

    World fromWorld = event.getFrom().getWorld();
    if (fromWorld != null && fromWorld.getEnvironment() == World.Environment.THE_END) {
        event.useTravelAgent(false);
        event.setTo(endExit);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:PortalListener.java

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

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

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

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

示例7: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(final PlayerPortalEvent event) {
    Bukkit.getScheduler().scheduleSyncDelayedTask(BridgePlugin.getInstance(), new Runnable() {
        @Override
        public void run() {
            final ClaimedResidence res = Residence.getResidenceManager().getByLoc(event.getPlayer().getLocation());
            ServerWorldUtil.sendResidenceInfo(event.getPlayer(), res);
            // Send Title

            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                ServerWorldUtil.sendAdditionalWorldInfo(player, player.getWorld().getName(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
                TitleUtil.sendDisplayName(player, event.getPlayer().getName(), ChatColor.stripColor(event.getPlayer().getDisplayName()) + "\n" + TitleUtil.getCustomTitle(event.getPlayer()));
                TitleUtil.sendDisplayName(event.getPlayer(), player.getName(), ChatColor.stripColor(player.getDisplayName()) + "\n" + TitleUtil.getCustomTitle(player));
            }
        }
    }, 20L);
    EconUtil.sendCurrencyAmount(event.getPlayer(), EconUtil.economy.getBalance(event.getPlayer().getName()));
}
 
開發者ID:AlmuraDev,項目名稱:AlmuraForgeBridge,代碼行數:19,代碼來源:PlayerListener.java

示例8: onPortalEvent

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
/**
 * When a portal event happends
 *
 * @param entityPortalEvent the portal event
 */
@EventHandler
public void onPortalEvent(PlayerPortalEvent entityPortalEvent)
{
    //if we're enabled
    if(isEnabled()) {

        //create a travel agent for the portal
        TravelAgent ta = entityPortalEvent.getPortalTravelAgent();
        //if they're in the nether
        if(entityPortalEvent.getPlayer().getWorld().getEnvironment() == World.Environment.NETHER) {
            //set data from the nether
            ta.setCanCreatePortal(config.getBoolean("PortalRanges.from_nether.allowed"));
            ta.setCreationRadius(config.getInt("PortalRanges.from_nether.creation_radius"));
            ta.setSearchRadius(config.getInt("PortalRanges.from_nether.search_radius"));
        } else {
            //set the data to the nether
            ta.setCanCreatePortal(config.getBoolean("PortalRanges.to_nether.allowed"));
            ta.setCreationRadius(config.getInt("PortalRanges.to_nether.creation_radius"));
            ta.setSearchRadius(config.getInt("PortalRanges.to_nether.search_radius"));
        }
    }
}
 
開發者ID:Eluinhost,項目名稱:ultrahardcore,代碼行數:28,代碼來源:PortalsFeature.java

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

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

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

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

示例13: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onPlayerPortal(PlayerPortalEvent event)
{
  if (event.getCause() == TeleportCause.END_PORTAL) {
    if (event.getTo().getWorld().getEnvironment() == Environment.THE_END) {
      event.setTo(event.getTo().getWorld().getSpawnLocation().clone().add(0.5D, 0.0D, 0.5D));
    } else if (event.getFrom().getWorld().getEnvironment() == Environment.THE_END) {
      event.setTo(this.endExitLocation);
    }
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:12,代碼來源:EndListener.java

示例14: get

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@Override
protected Location[] get(Event event) {
    if (event instanceof PlayerPortalEvent) {
        return new Location[]{createPortal(targetLoc.getSingle(event), radius.getSingle(event).intValue(), ((PlayerPortalEvent) event).getPortalTravelAgent())};
    } else if (event instanceof EntityPortalEvent) {
        return new Location[]{createPortal(targetLoc.getSingle(event), radius.getSingle(event).intValue(), ((EntityPortalEvent) event).getPortalTravelAgent())};
    }
    throw new IllegalArgumentException("The event " + event + " should be a PlayerPortalEvent or EntityPortalEvent");

}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:11,代碼來源:ExprNewPortal.java

示例15: init

import org.bukkit.event.player.PlayerPortalEvent; //導入依賴的package包/類
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerPortalEvent.class, EntityPortalEvent.class)) {
        Skript.error("'new nether portal' can only be used in an 'on teleport' event!");
        return false;
    }
    radius = (Expression<Number>) expressions[0];
    targetLoc = (Expression<Location>) expressions[1];
    return false;
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:11,代碼來源:ExprNewPortal.java


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