本文整理汇总了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);
}
}
示例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!"));
}
}
}
示例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);
}
}
}
示例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());
}
}
示例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");
}
示例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));
}
}
示例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;
}
}