本文整理匯總了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;
}
示例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;
}
}
示例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();
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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());
}
}
}
示例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());
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
}
}
示例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));
}
}
}
示例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;
}
示例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() + "'");
}