@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);
}
}
java类org.bukkit.event.player.PlayerPortalEvent的实例源码
PortalListener.java 文件源码
项目:HCFCore
阅读 24
收藏 0
点赞 0
评论 0
PortalListener.java 文件源码
项目:HCFCore
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
}
EventListener.java 文件源码
项目:CutePortals
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
LoadHell.java 文件源码
项目:TallNether
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
KitLoading.java 文件源码
项目:AnnihilationPro
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
RPPlayerListener.java 文件源码
项目:RedProtect
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
}
ExploitEvents.java 文件源码
项目:uSkyBlock
阅读 37
收藏 0
点赞 0
评论 0
@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!"));
}
}
}
PlayerListener.java 文件源码
项目:AlmuraForgeBridge
阅读 29
收藏 0
点赞 0
评论 0
@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()));
}
PortalsFeature.java 文件源码
项目:ultrahardcore
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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"));
}
}
}
PortalListener.java 文件源码
项目:CraftoPlugin
阅读 29
收藏 0
点赞 0
评论 0
@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() + "'");
}
PlayerListener.java 文件源码
项目:NPlugins
阅读 30
收藏 0
点赞 0
评论 0
@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");
}
PlayerFixPortalSoundEvent.java 文件源码
项目:xEssentials-deprecated-bukkit
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
SecurityListener.java 文件源码
项目:SurvivalAPI
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
EndListener.java 文件源码
项目:HCFCore
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
}
}
EndListener.java 文件源码
项目:HCFCore
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
}
}
ExprNewPortal.java 文件源码
项目:MundoSK
阅读 28
收藏 0
点赞 0
评论 0
@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");
}
ExprNewPortal.java 文件源码
项目:MundoSK
阅读 27
收藏 0
点赞 0
评论 0
@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;
}
FollowListener.java 文件源码
项目:Parties
阅读 19
收藏 0
点赞 0
评论 0
@EventHandler
public void onEntityPortalEvent(PlayerPortalEvent event) {
if (!event.isCancelled()) {
ThePlayer tp = plugin.getPlayerHandler().getPlayer(event.getPlayer().getUniqueId());
if (tp.getPortalTimeout() != -1)
event.setCancelled(true);
}
}
EvtRegionBorder.java 文件源码
项目:Skript
阅读 25
收藏 0
点赞 0
评论 0
private final static void register() {
if (registered)
return;
Bukkit.getPluginManager().registerEvent(PlayerMoveEvent.class, new Listener() {}, SkriptConfig.defaultEventPriority.value(), ee, Skript.getInstance(), true);
Bukkit.getPluginManager().registerEvent(PlayerTeleportEvent.class, new Listener() {}, SkriptConfig.defaultEventPriority.value(), ee, Skript.getInstance(), true);
Bukkit.getPluginManager().registerEvent(PlayerPortalEvent.class, new Listener() {}, SkriptConfig.defaultEventPriority.value(), ee, Skript.getInstance(), true);
registered = true;
}
PlayerListener.java 文件源码
项目:ExilePearl
阅读 26
收藏 0
点赞 0
评论 0
@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());
}
}
PortalListener.java 文件源码
项目:Peacecraft
阅读 26
收藏 0
点赞 0
评论 0
@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());
}
WorldListener.java 文件源码
项目:Peacecraft
阅读 37
收藏 0
点赞 0
评论 0
@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());
}
PlayerListener.java 文件源码
项目:civcraft
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerPortalEvent(PlayerPortalEvent event) {
if(event.getCause().equals(TeleportCause.END_PORTAL)) {
event.setCancelled(true);
CivMessage.sendErrorNoRepeat(event.getPlayer(), "The End portal is disabled on this server.");
return;
}
if (event.getCause().equals(TeleportCause.NETHER_PORTAL)) {
event.setCancelled(true);
CivMessage.sendErrorNoRepeat(event.getPlayer(), "The Nether is disabled on this server.");
return;
}
}
PlayerListener.java 文件源码
项目:Annihilation
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerPortal(PlayerPortalEvent e) {
final Player player = e.getPlayer();
player.setHealth(0D);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
Util.showClassSelector(player, "Select Class");
}
}, 4l);
}