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


Java PlayerPortalEvent.getCause方法代码示例

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


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

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

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

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

示例4: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event) {
	ExilePearl pearl = pearlApi.getPearl(event.getPlayer().getUniqueId());
	if(pearl != null && pearl.getPearlType() == PearlType.PRISON && event.getCause() == TeleportCause.END_PORTAL) {
		event.setTo(pearlApi.getPearlConfig().getPrisonWorld().getSpawnLocation());
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:8,代码来源:PlayerListener.java

示例5: onPlayerUsePortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onPlayerUsePortal(final PlayerPortalEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerUsePortal", "player=" + event.getPlayer().getName() + ";from=" + NLocation.toString(event.getFrom()) + ";to=" + NLocation.toString(event.getTo()));

    final GeneralWorld world = this.plugin.getWorlds().get(event.getFrom().getWorld().getName());
    if (GeneralWorld.WorldType.isStock(world)) {
        return;
    }

    if (world.getType() == WorldType.ADDITIONAL) {
        final AdditionalWorld additionalWorld = (AdditionalWorld)world;
        if (event.getCause() == TeleportCause.NETHER_PORTAL && !additionalWorld.hasNether()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (nether)");
            return;
        } else if (event.getCause() == TeleportCause.END_PORTAL && !additionalWorld.hasEnd()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (end)");
            return;
        }
    }

    final PortalEventResult result = this.handlePortalEvent(event.getFrom(), event.getCause(), event.getPortalTravelAgent());
    if (result == null) {
        return;
    }
    if (result.destination != null) {
        event.setTo(result.destination);
    }
    if (result.useTravelAgent) {
        event.useTravelAgent(true);
    }
    if (result.cancelEvent) {
        event.setCancelled(true);
    }

    this.plugin.exiting(this.getClass(), "onPlayerUsePortal");
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:39,代码来源:NListener.java

示例6: onPortalEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPortalEnter(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    Location to = event.getTo();
    World toWorld = to.getWorld();
    if (toWorld == null)
        return; // safe-guard if the End or Nether is disabled

    if (toWorld.getEnvironment() == World.Environment.THE_END) {
        Player player = event.getPlayer();

        // Prevent entering the end if it's closed.
        if (false /* TODO:plugin.getEndManager().isOpened() */) {
            message(player, ChatColor.RED + "The End is currently closed.");
            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is Spawn Tagged.
        PlayerTimer timer = plugin.getTimerManager().getCombatTimer();
        long remaining;
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is PVP Protected.
        timer = plugin.getTimerManager().getInvincibilityTimer();
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        event.useTravelAgent(false);
        event.setTo(toWorld.getSpawnLocation().add(0.5, 0, 0.5));
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:47,代码来源:PortalListener.java

示例7: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
   public void onPlayerPortal(PlayerPortalEvent event) {
// If the nether is disabled then quit immediately
if (!Settings.createNether) {
    return;
}
Location currentLocation = event.getFrom().clone();
String currentWorld = currentLocation.getWorld().getName();
if (!currentWorld.equalsIgnoreCase(Settings.worldName) && !currentWorld.equalsIgnoreCase(Settings.worldName + "_nether")
	&& !currentWorld.equalsIgnoreCase(Settings.worldName + "_the_end")) {
    return;
}

// Determine what portal it is
switch (event.getCause()) {
case END_PORTAL:
    if (Settings.createEnd) {
	// Same action for all worlds except the end itself
	if (!event.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) {
	    if (ASkyGrid.getEndWorld() != null) {
		// The end exists
		event.setCancelled(true);
		// Convert current location to end world location
		Location end_place = event.getPlayer().getLocation().toVector().toLocation(ASkyGrid.getEndWorld());
		// Set the height to the top of the end grid
		end_place.setY(Settings.gridHeight);
		if (GridManager.isSafeLocation(end_place)) {
		    event.getPlayer().teleport(end_place);
		    return;
		} else {
		    end_place = plugin.getGrid().bigScan(end_place, 10);
		    if (end_place != null) {
			event.getPlayer().teleport(end_place);
		    } else {
			// Try the spawn
			end_place = ASkyGrid.getEndWorld().getSpawnLocation();
			if (GridManager.isSafeLocation(end_place)) {
			    event.getPlayer().teleport(end_place);
			    return;
			} else {
			    event.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).warpserrorNotSafe);
			}
		    }
		    return;
		}
	    }
	} else {
	    // Returning from the end - just go home
	    event.setCancelled(true);
	    plugin.getGrid().homeTeleport(event.getPlayer());
	}
    }
    break;
case NETHER_PORTAL:
    // Get the home world of this player
    if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
	// Going to Nether
	event.setTo(event.getFrom().toVector().toLocation(ASkyGrid.getNetherWorld()));
	event.useTravelAgent(true); 
    } else {
	// Returning
	event.setTo(event.getFrom().toVector().toLocation(ASkyGrid.getGridWorld()));
	event.useTravelAgent(true); 
    }
    break;
default:
    break;
}
   }
 
开发者ID:tastybento,项目名称:askygrid,代码行数:70,代码来源:NetherPortals.java


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