/** * Creates a new {@link RespawnLocation} from this builder. * * @return The new respawn location */ public RespawnLocation build() { checkNotNull(this.world, "World id cannot be null!"); checkNotNull(this.position, "Position cannot be null!"); return new RespawnLocation(this); } }
@Override public DataContainer toContainer() { return DataContainer.createNew() .set(Queries.CONTENT_VERSION, getContentVersion()) .set(Queries.POSITION_X, getPosition().getX()) .set(Queries.POSITION_Y, getPosition().getY()) .set(Queries.POSITION_Z, getPosition().getZ()) .set(Queries.FORCED_SPAWN, isForced()) .set(Queries.WORLD_ID, getWorldUniqueId().toString()); }
@Override public Builder from(RespawnLocation value) { checkNotNull(value, "RespawnLocation cannot be null!"); this.world = value.getWorldUniqueId(); this.position = value.getPosition(); this.forced = value.isForced(); return this; }
/** * Gets this spawn position as a {@link Location} object, if the world is * available. * * @return The position object, if available. */ public Optional<Location<World>> asLocation() { Optional<World> world = Sponge.getServer().getWorld(getWorldUniqueId()); if (!world.isPresent()) { return Optional.empty(); } return Optional.of(new Location<>(world.get(), getPosition())); }
public RespawnLocationView(RespawnLocation value) { super(value); loc = value.asLocation().orElse(null); } }
@Override public Builder from(RespawnLocation value) { checkNotNull(value, "RespawnLocation cannot be null!"); this.world = value.getWorldUniqueId(); this.position = value.getPosition(); this.forced = value.isForced(); return this; }
/** * Gets this spawn position as a {@link Location} object, if the world is * available. * * @return The position object, if available. */ public Optional<Location<World>> asLocation() { Optional<World> world = Sponge.getServer().getWorld(getWorldUniqueId()); if (!world.isPresent()) { return Optional.empty(); } return Optional.of(new Location<>(world.get(), getPosition())); }
@Override public DataContainer toContainer() { return new MemoryDataContainer() .set(Queries.CONTENT_VERSION, getContentVersion()) .set(Queries.POSITION_X, getPosition().getX()) .set(Queries.POSITION_Y, getPosition().getY()) .set(Queries.POSITION_Z, getPosition().getZ()) .set(Queries.FORCED_SPAWN, isForced()) .set(Queries.WORLD_ID, getWorldUniqueId().toString()); }
@Override protected Optional<RespawnLocation> buildContent(DataView container) throws InvalidDataException { final String worldString = container.getString(Queries.WORLD_ID).get(); final UUID worldId = UUID.fromString(worldString); final double xPos = container.getDouble(Queries.POSITION_X).get(); final double yPos = container.getDouble(Queries.POSITION_Y).get(); final double zPos = container.getDouble(Queries.POSITION_Z).get(); final Vector3d position = new Vector3d(xPos, yPos, zPos); final boolean forcedSpawn = container.getBoolean(Queries.FORCED_SPAWN).orElse(false); final Builder builder = new Builder(); builder.world = worldId; builder.position = position; builder.forced = forcedSpawn; return Optional.of(new RespawnLocation(builder)); }
public RespawnLocation build() { checkNotNull(this.world, "World id cannot be null!"); checkNotNull(this.position, "Position cannot be null!"); return new RespawnLocation(this); } }
@Override protected Optional<RespawnLocation> buildContent(DataView container) throws InvalidDataException { final String worldString = container.getString(Queries.WORLD_ID).get(); final UUID worldId = UUID.fromString(worldString); final double xPos = container.getDouble(Queries.POSITION_X).get(); final double yPos = container.getDouble(Queries.POSITION_Y).get(); final double zPos = container.getDouble(Queries.POSITION_Z).get(); final Vector3d position = new Vector3d(xPos, yPos, zPos); final boolean forcedSpawn = container.getBoolean(Queries.FORCED_SPAWN).orElse(false); final Builder builder = new Builder(); builder.world = worldId; builder.position = position; builder.forced = forcedSpawn; return Optional.of(new RespawnLocation(builder)); }