Class RegionRate
java.lang.Object
me.tayebyassine.homestead.models.RegionRate
Represents a rating given by a player to a region.
Each player may rate a region once; subsequent ratings overwrite the previous one.
-
Constructor Summary
ConstructorsConstructorDescriptionRegionRate(long id, long regionId, UUID playerId, int rate, long ratedAt) Create a rating from pre-existing data (deserialization).RegionRate(long regionId, UUID playerId, int rate, long ratedAt) Create a rating with a generated snowflake ID.RegionRate(long regionId, org.bukkit.OfflinePlayer player, int rate) Create a rating from a Bukkit player. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.OfflinePlayerGet the rating player as an offline player.@NotNull UUIDGet the rating player's UUID.@NotNull StringGet the rating player's name safely.intgetRate()Get the rating value.longGet the rating timestamp.@Nullable RegionGet the parent region from the cache.longGet the region ID.@NotNull StringGet the parent region's name safely.longGet the unique snowflake ID.voidsetPlayer(@NotNull org.bukkit.OfflinePlayer player) Set the rating player.voidsetPlayerId(@NotNull UUID playerId) Set the rating player's UUID.voidsetRate(int rate) Set the rating value.voidsetRatedAt(long ratedAt) Set the rating timestamp.voidsetRegionId(long regionId) Set the region ID.
-
Constructor Details
-
RegionRate
public RegionRate(long regionId, org.bukkit.OfflinePlayer player, int rate) Create a rating from a Bukkit player.- Parameters:
regionId- the region IDplayer- the rating playerrate- the rating value
-
RegionRate
Create a rating with a generated snowflake ID.- Parameters:
regionId- the region IDplayerId- the player UUIDrate- the rating valueratedAt- the rating timestamp
-
RegionRate
Create a rating from pre-existing data (deserialization).- Parameters:
id- the snowflake IDregionId- the region IDplayerId- the player UUIDrate- the rating valueratedAt- the rating timestamp
-
-
Method Details
-
getUniqueId
public long getUniqueId()Get the unique snowflake ID.- Returns:
- the rating ID
-
getRegionId
public long getRegionId()Get the region ID.- Returns:
- the region ID
-
setRegionId
public void setRegionId(long regionId) Set the region ID.- Parameters:
regionId- the new region ID
-
getRegion
Get the parent region from the cache.- Returns:
- the region, or
nullif not found
-
getRegionName
Get the parent region's name safely. Returns"?"if not found.- Returns:
- the region name
-
getPlayerId
-
setPlayerId
Set the rating player's UUID.- Parameters:
playerId- the new player UUID
-
getPlayer
@Nullable public @Nullable org.bukkit.OfflinePlayer getPlayer()Get the rating player as an offline player.- Returns:
- the player, or
nullif not found
-
setPlayer
public void setPlayer(@NotNull @NotNull org.bukkit.OfflinePlayer player) Set the rating player.- Parameters:
player- the new player
-
getPlayerName
Get the rating player's name safely. Returns"?"if not found.- Returns:
- the player's name
-
getRate
public int getRate()Get the rating value.- Returns:
- the rating
-
setRate
public void setRate(int rate) Set the rating value.- Parameters:
rate- the new rating
-
getRatedAt
public long getRatedAt()Get the rating timestamp.- Returns:
- the epoch-millis timestamp
-
setRatedAt
public void setRatedAt(long ratedAt) Set the rating timestamp.- Parameters:
ratedAt- the new timestamp
-