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


Java PlayerPortalEvent.setTo方法代码示例

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


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

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

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

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

示例6: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) {
    EntityPortalEvent e = new EntityPortalEvent(event.getPlayer(), event.getFrom(), event.getTo(), event.getPortalTravelAgent());
    this.onEntityPortal(e);
    event.setFrom(e.getFrom());
    event.setTo(e.getTo());
    event.setPortalTravelAgent(e.getPortalTravelAgent());
    event.useTravelAgent(e.useTravelAgent());
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:10,代码来源:PortalListener.java

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

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

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

示例10: onEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onEnter(PlayerPortalEvent e) {
	if(e.isCancelled()) {
		return;
	}

	e.setCancelled(true);

	Block block = getPortalNearby(e.getPlayer().getLocation().getBlock());
	if(!(block instanceof Block)) {
		return;
	}
	for(Portal portal : pl.getConfiguration().getPortalConfig().getPortals().values()) {
		if(portal.getInnerBlocks().contains(block)) {
			if(pl.getConfiguration().getPortalConfig().getCooldown() > 0) {
				if(time.containsKey(e.getPlayer().getName())) {
					if(time.get(e.getPlayer().getName()) < System.currentTimeMillis()) {
						time.remove(e.getPlayer().getName());
					} else {
						e.setCancelled(true);
						Long millis = (time.get(e.getPlayer().getName())-System.currentTimeMillis());
						String msg = String.format("%d:%s", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
						sendMessage(e.getPlayer(), ChatColor.GRAY + "cooldown please wait: " + ChatColor.GREEN + msg + ChatColor.GRAY + " minutes");
						return;
					}
				} else {
					Date date = new Date(System.currentTimeMillis());
					date.setSeconds(date.getSeconds()+pl.getConfiguration().getPortalConfig().getCooldown());
					time.put(e.getPlayer().getName(), date.getTime());
				}
			}
			e.useTravelAgent(false);
			if(portal.isLinked()) {
				Portal linked = portal.getLinkedPortal();
				if(!(linked instanceof Portal)) {
					e.setCancelled(true);
					return;
				}
				//e.setTo(linked.getInnerBlocks()[(linked.getInnerBlocks().length-1)].getLocation());
				
				e.setTo(linked.getExitLocation());
				e.setCancelled(false);
			} else {
				e.setCancelled(true);
			}
			break;
		}
	}
	e.setCancelled(false);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:52,代码来源:PortalEvent.java


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