protected GlowMapView(World world, short id) { this.world = world; this.id = id; centerX = world.getSpawnLocation().getBlockX(); centerZ = world.getSpawnLocation().getBlockZ(); scale = Scale.FAR; addRenderer(new GlowMapRenderer(this)); }
@Override public BlockVector3 getSpawnPosition() { return BukkitAdapter.asBlockVector(getWorld().getSpawnLocation()); }
/** * Read the location from a PlayerReader for entity initialization. * * <p>Will fall back to a reasonable default rather than returning null. * * @param session The player's session. * @param reader The PlayerReader to get the location from. * @return The location to spawn the player. */ private static Location initLocation(GlowSession session, PlayerReader reader) { if (reader.hasPlayedBefore()) { Location loc = reader.getLocation(); if (loc != null) { return loc; } } return findSafeSpawnLocation(session.getServer().getWorlds().get(0).getSpawnLocation()); }
/** * Teleport this entity to the spawn point of the main world. This is used to teleport out of * the End. * * @return {@code true} if the teleport was successful. */ protected boolean teleportToSpawn() { Location target = server.getWorlds().get(0).getSpawnLocation(); EntityPortalEvent event = EventFactory.getInstance() .callEvent(new EntityPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); teleport(target); return true; }
@Override protected boolean teleportToSpawn() { Location target = getBedSpawnLocation(); if (target == null) { target = server.getWorlds().get(0).getSpawnLocation(); } PlayerPortalEvent event = EventFactory.getInstance() .callEvent(new PlayerPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); spawnAt(target); teleported = true; awardAchievement(Achievement.THE_END, false); return true; }
/** * Teleport this entity to the End. If no End world is loaded this does nothing. * * @return {@code true} if the teleport was successful. */ protected boolean teleportToEnd() { if (!server.getAllowEnd()) { return false; } Location target = null; for (World world : server.getWorlds()) { if (world.getEnvironment() == Environment.THE_END) { target = world.getSpawnLocation(); break; } } if (target == null) { return false; } EntityPortalEvent event = EventFactory.getInstance() .callEvent(new EntityPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); teleport(target); return true; }
@Override protected boolean teleportToEnd() { if (!server.getAllowEnd()) { return false; } Location target = null; for (World world : server.getWorlds()) { if (world.getEnvironment() == Environment.THE_END) { target = world.getSpawnLocation(); break; } } if (target == null) { return false; } PlayerPortalEvent event = EventFactory.getInstance() .callEvent(new PlayerPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); spawnAt(target); teleported = true; awardAchievement(Achievement.END_PORTAL, false); return true; }
@Override public DynmapLocation getSpawnLocation() { if(world != null) { Location sloc = world.getSpawnLocation(); spawnloc.x = sloc.getBlockX(); spawnloc.y = sloc.getBlockY(); spawnloc.z = sloc.getBlockZ(); spawnloc.world = normalizeWorldName(sloc.getWorld().getName()); } return spawnloc; } /* Get world time */
@Override public MCLocation getSpawnLocation() { return new BukkitMCLocation(w.getSpawnLocation()); }
/** * @return the old location */ public Location getOldLocation() { if (oldLocation.getWorld() == null) { return Bukkit.getWorlds().get(0).getSpawnLocation(); } return oldLocation; }
public EntityMock(ServerMock server, UUID uuid) { this.server = server; this.uuid = uuid; if (Bukkit.getWorlds().size() > 0) location = Bukkit.getWorlds().get(0).getSpawnLocation(); else location = new Location(null, 0, 0, 0); }
@Override public void run() { // A villager is born World world = Bukkit.getWorld("world"); world.spawnEntity(world.getSpawnLocation(), EntityType.VILLAGER); } },
public void sendToWorld(Player player) { try { player.teleport(getWorld().getSpawnLocation()); } catch (Exception ex) { player.sendMessage(ex.getMessage()); } }
private Location getMostAccurateRespawnLocation(World w) { MultiverseWorld mvw = this.worldManager.getMVWorld(w.getName()); if (mvw != null) { return mvw.getSpawnLocation(); } return w.getSpawnLocation(); }
private static Location getAcurateSpawnLocation(Entity e, MultiverseWorld world) { if (world != null) { return world.getSpawnLocation(); } else { // add 0.5 to x and z to center people // (spawn location is stored as int meaning that you would spawn in the corner of a block) return e.getWorld().getSpawnLocation().add(.5, 0, .5); } }
public Location getLocation() { Location loc = world.getSpawnLocation(); loc.setPitch(getPitch()); loc.setYaw(getYaw()); return loc; }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerLogin(PlayerLoginEvent event) { final Player player = event.getPlayer(); // Validate position if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD) { player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn } }
private void spawnAccurately(Player player) { MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName()); Location spawnLocation; if (world != null) { spawnLocation = world.getSpawnLocation(); } else { spawnLocation = player.getWorld().getSpawnLocation(); } this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false); } }
@Test public void getEntities_OnePlayerInWorld_ListContainsOnlyPlayer() { World world = server.addSimpleWorld("world"); server.addSimpleWorld("otherWorld"); Player player = server.addPlayer(); player.teleport(world.getSpawnLocation()); List<Entity> entities = world.getEntities(); assertNotNull(entities); assertEquals(1, entities.size()); assertSame(player, entities.get(0)); }
@Test public void getEntities_OnePlayerInDifferentWorld_EmptyList() { World world = server.addSimpleWorld("world"); World otherWorld = server.addSimpleWorld("otherWorld"); Player player = server.addPlayer(); player.teleport(otherWorld.getSpawnLocation()); List<Entity> entities = world.getEntities(); assertNotNull(entities); assertEquals(0, entities.size()); }