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


Java TeleportCause类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerTeleportEvent.TeleportCause的典型用法代码示例。如果您正苦于以下问题:Java TeleportCause类的具体用法?Java TeleportCause怎么用?Java TeleportCause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TeleportCause类属于org.bukkit.event.player.PlayerTeleportEvent包,在下文中一共展示了TeleportCause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: teleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftEntity.java

示例2: run

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@Override
public boolean run() {
	Location spawn = SkyWarsReloaded.getCfg().getSpawn();
	if (spawn == null) {
		sender.sendMessage(ChatColor.RED + "YOU MUST SET SPAWN BEFORE YOU CAN CREATE A MAP");
		return true;
	}
	String worldName = args[1].toLowerCase();
	if (!SkyWarsReloaded.getMC().mapExists(worldName.toLowerCase())) {
		World newWorld = SkyWarsReloaded.getWC().createEmptyWorld(worldName);
		if (newWorld == null) {
			sender.sendMessage(new Messaging.MessageFormatter().format("error.map.world.exists"));
			return true;
		}
		SkyWarsReloaded.getMC().addEditMap(worldName);
		sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("maps.created"));
		if (sender instanceof Player) {
			Player player = (Player) sender;
			player.teleport(new Location(newWorld, 0, 21, 0), TeleportCause.PLUGIN);
		}
		return true;
	} else {
		sender.sendMessage(new Messaging.MessageFormatter().format("error.map-exists"));
		return true;
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:27,代码来源:CreateMapCmd.java

示例3: repellExpOrb

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
final void repellExpOrb(final Player player, final ExperienceOrb orb) {
	final Location pLoc = player.getLocation();
	final Location oLoc = orb.getLocation();
	final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
	final double dx = Math.abs(dir.getX());
	final double dz = Math.abs(dir.getZ());
	if ( (dx == 0.0) && (dz == 0.0)){
		// Special case probably never happens
		dir.setX(0.001);
	}
	if ((dx < 3.0) && (dz < 3.0)){
		final Vector nDir = dir.normalize();
		final Vector newV = nDir.clone().multiply(0.3);
		newV.setY(0);
		orb.setVelocity(newV);
		if ((dx < 1.0) && (dz < 1.0)){
			// maybe oLoc
			orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
		} 
		if ((dx < 0.5) && (dz < 0.5)){
			orb.remove();
		} 
	} 
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:25,代码来源:SpectatorListener.java

示例4: spawnVillager

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
	if (!location.getChunk().isLoaded()) {
		location.getChunk().load();
	}
	Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
	villager.setAdult();
	villager.setAgeLock(true);
	villager.setProfession(Profession.FARMER);
	villager.setRemoveWhenFarAway(false);
	villager.setCustomName(type.getColor() + type.getName());
	villager.setCustomNameVisible(true);
	villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
	villager.teleport(location, TeleportCause.PLUGIN);
	villager.setHealth(20.0D);
	return villager;
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:VillagerManager.java

示例5: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.ENDER_PEARL) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
    
    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:18,代码来源:FlagDef_NoEnderPearl.java

示例6: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.CHORUS_FRUIT) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
    
    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:18,代码来源:FlagDef_NoChorusFruit.java

示例7: teleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
    	entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
 
开发者ID:CyberdyneCC,项目名称:ThermosRebased,代码行数:17,代码来源:CraftEntity.java

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@Override
public void onPlayerTeleport(PlayerTeleportEvent event, BPPlayer bpPlayer)
{
	TeleportCause cause = event.getCause();
	
	if(cause == TeleportCause.ENDER_PEARL)
	{
		CTFGame game = getGame();
		FlagManager flm = game.getFlagManager();
		
		if(flm.isHoldingFlag(bpPlayer))
		{
			Player player = bpPlayer.getPlayer();
			event.setCancelled(true);
			player.sendMessage(MessageType.OTHER_WARNPEARL.getTranslation().getValue());
		}
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:19,代码来源:CTFListener.java

示例9: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@EventHandler
public void onTeleport(final PlayerTeleportEvent e) {
	final Player p = e.getPlayer();
	if (e.getCause().equals(TeleportCause.SPECTATE)
			&& !(p.hasPermission("essentials.tp"))){ 
		e.setCancelled(true);
		p.sendMessage(ChatColor.RED + "You do not have permission to /tp");
	}
	
	if (!e.getFrom().getWorld().equals(e.getTo().getWorld())) {
		MultiverseCore mv = (MultiverseCore) Bukkit.getServer()
				.getPluginManager().getPlugin("Multiverse-Core");
		MVWorldManager wm = mv.getMVWorldManager();
		MultiverseWorld toWorld = wm.getMVWorld(e.getTo().getWorld()
				.getName());
		MultiverseWorld fromWorld = wm.getMVWorld(e.getFrom().getWorld()
				.getName());
		if (toWorld != fromWorld
				&& !p.getGameMode().equals(toWorld.getGameMode())) {
			p.setGameMode(toWorld.getGameMode());
		}
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:24,代码来源:TeleportListener.java

示例10: execute

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@Override
protected void execute(Event e) {
	if (teleportcause == null && teleportcausestring == null && location != null) {
		npc.getSingle(e).teleport(location.getSingle(e), TeleportCause.PLUGIN);
	} else if (location != null) {
		if (marker == 1) {
			npc.getSingle(e).teleport(location.getSingle(e), teleportcause.getSingle(e));
		} else {
			TeleportCause t = TeleportCause.valueOf(teleportcausestring.getSingle(e).replace("\"", "").trim().replace(" ", "_").toUpperCase());
			try {
				t = TeleportCause.valueOf(t.toString().replace("\"", "").trim().replace(" ", "_").toUpperCase());
			} catch (IllegalArgumentException error) {
				Skript.error(t.toString() + " Unknown teleortcause type");
				return;
			}
			if (t != null) {
				npc.getSingle(e).teleport(location.getSingle(e), t);
			}
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:22,代码来源:EffNpcTeleport.java

示例11: teleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
public boolean teleport(Location location, TeleportCause cause) {
       if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
           return false;
       }

       // Spigot start
       net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
       if (newWorld != entity.worldObj) {
           entity.teleportTo(location, cause.isPortal());
           return true;
       }
       // Spigot end
       entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
//entity.worldObj.entityJoinedWorld(entity, false); // PaperSpigot - Prevent Server from thinking a player teleporting within the world has joined the world
       // entity.setLocation() throws no event, and so cannot be cancelled
       return true;
   }
 
开发者ID:CyberdyneCC,项目名称:Thermos,代码行数:18,代码来源:CraftEntity.java

示例12: deathListener

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
private void deathListener(Player p, int index){
	RedProtect.get().logger.debug("Added index "+index);
	
	HashMap<Integer, Location> loc1 = new HashMap<>();
	if (!deathLocs.containsKey(p.getName())){
		loc1.put(index, p.getLocation());
		deathLocs.put(p.getName(), loc1);
    } else {
		loc1 = deathLocs.get(p.getName());
		    		
		loc1.put(index, p.getLocation());
		deathLocs.put(p.getName(), loc1);    
		
		if (loc1.size() == 2){
			Location from = deathLocs.get(p.getName()).get(0);
	    	Location to = deathLocs.get(p.getName()).get(1);
	    	deathLocs.remove(p.getName());
	    	PlayerTeleportEvent televent = new PlayerTeleportEvent(p, from, to, TeleportCause.PLUGIN);
	    	Bukkit.getPluginManager().callEvent(televent);
        }
	}    	
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:23,代码来源:RPPlayerListener.java

示例13: damager

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
@EventHandler
public void damager(EntityDamageEvent a) {
	if (eA.mC.cFa && eA.mA.i() > 3 && eA.mA.i() < 7 && a.getEntity() instanceof Player) {
		if (eA.mA.i() != 6 && a.getCause().equals(DamageCause.VOID)) {
			a.getEntity().teleport(a.getEntity().getWorld().getSpawnLocation().add(0.5, 1, 0.5), TeleportCause.PLUGIN);
			a.getEntity().setFallDistance(0f);
		}
		a.setCancelled(true);
		return;
	}
	if (eA.mC.cOa && eA.mA.i() == 7 && a.getEntity() instanceof Player) {
		UHCPlayer b = eA.mB.getPlayer(a.getEntity().getName());
		if (eA.mE.getIngamePlayers().contains(b.uB.getName())) {
			b.dmgStorage(eA.mE.gL, a.getDamage(), eA.mE.gF.source(a));
		}
	}
}
 
开发者ID:Thomaz2Fast,项目名称:Ultra-Hardcore-1.8,代码行数:18,代码来源:EvGame.java

示例14: teleport

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的package包/类
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.passenger != null || entity.dead) {
        return false;
    }

    // If this entity is riding another entity, we must dismount before teleporting.
    entity.mount(null);

    // Spigot start
    if (!location.getWorld().equals(getWorld())) {
      entity.teleportTo(location, cause.equals(TeleportCause.NETHER_PORTAL));
      return true;
    }

    // entity.world = ((CraftWorld) location.getWorld()).getHandle();
    // Spigot end
    entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:21,代码来源:CraftEntity.java

示例15: onPlayerPortal

import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; //导入依赖的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


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