当前位置: 首页>>代码示例>>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;未经允许,请勿转载。