Package org.spongepowered.api.util
Class RespawnLocation
- java.lang.Object
-
- org.spongepowered.api.util.RespawnLocation
-
- All Implemented Interfaces:
DataSerializable
public final class RespawnLocation extends java.lang.Object implements DataSerializable
Represents a position for a player to respawn in in a particular world. Instances can be obtained usingKeys.RESPAWN_LOCATIONS
or by using thebuilder()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RespawnLocation.Builder
A helper class to buildRespawnLocation
s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<ServerLocation>
asLocation()
Gets this spawn position as aServerLocation
object, if the world is available.static RespawnLocation.Builder
builder()
Creates a newRespawnLocation.Builder
to build aRespawnLocation
.int
contentVersion()
Gets the content version of thisDataSerializable
.boolean
equals(java.lang.Object o)
int
hashCode()
boolean
isForced()
Gets whether the spawn position is forced in the given world, if available.Vector3d
position()
Gets the position within the world of this spawn point.DataContainer
toContainer()
Serializes this object into a comprehensibleDataContainer
.java.lang.String
toString()
ResourceKey
worldKey()
Gets thekey
of the world.
-
-
-
Method Detail
-
builder
public static RespawnLocation.Builder builder()
Creates a newRespawnLocation.Builder
to build aRespawnLocation
.- Returns:
- A new builder
-
worldKey
public ResourceKey worldKey()
Gets thekey
of the world.- Returns:
- The key
-
position
public Vector3d position()
Gets the position within the world of this spawn point.- Returns:
- The spawn position
-
isForced
public boolean isForced()
Gets whether the spawn position is forced in the given world, if available. A forced position will spawn the player there even if a bed is missing or obstructed.- Returns:
- Whether the position is forced in the world
-
asLocation
public java.util.Optional<ServerLocation> asLocation()
Gets this spawn position as aServerLocation
object, if the world is available.- Returns:
- The position object, if available.
-
contentVersion
public int contentVersion()
Description copied from interface:DataSerializable
Gets the content version of thisDataSerializable
. The version may differ between instances of plugins and implementations such that theDataView
fromDataSerializable.toContainer()
may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand withDataContentUpdater
as it is required when there exists anyDataView
of thisDataSerializable
with an "older" version.- Specified by:
contentVersion
in interfaceDataSerializable
- Returns:
- The version of the content being serialized
-
toContainer
public DataContainer toContainer()
Description copied from interface:DataSerializable
Serializes this object into a comprehensibleDataContainer
.- Specified by:
toContainer
in interfaceDataSerializable
- Returns:
- A newly created DataContainer
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-