Class RegionRate

java.lang.Object
me.tayebyassine.homestead.models.RegionRate

public final class RegionRate extends Object
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

    Constructors
    Constructor
    Description
    RegionRate(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 Type
    Method
    Description
    @Nullable org.bukkit.OfflinePlayer
    Get the rating player as an offline player.
    @NotNull UUID
    Get the rating player's UUID.
    @NotNull String
    Get the rating player's name safely.
    int
    Get the rating value.
    long
    Get the rating timestamp.
    @Nullable Region
    Get the parent region from the cache.
    long
    Get the region ID.
    @NotNull String
    Get the parent region's name safely.
    long
    Get the unique snowflake ID.
    void
    setPlayer(@NotNull org.bukkit.OfflinePlayer player)
    Set the rating player.
    void
    setPlayerId(@NotNull UUID playerId)
    Set the rating player's UUID.
    void
    setRate(int rate)
    Set the rating value.
    void
    setRatedAt(long ratedAt)
    Set the rating timestamp.
    void
    setRegionId(long regionId)
    Set the region ID.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RegionRate

      public RegionRate(long regionId, org.bukkit.OfflinePlayer player, int rate)
      Create a rating from a Bukkit player.
      Parameters:
      regionId - the region ID
      player - the rating player
      rate - the rating value
    • RegionRate

      public RegionRate(long regionId, UUID playerId, int rate, long ratedAt)
      Create a rating with a generated snowflake ID.
      Parameters:
      regionId - the region ID
      playerId - the player UUID
      rate - the rating value
      ratedAt - the rating timestamp
    • RegionRate

      public RegionRate(long id, long regionId, UUID playerId, int rate, long ratedAt)
      Create a rating from pre-existing data (deserialization).
      Parameters:
      id - the snowflake ID
      regionId - the region ID
      playerId - the player UUID
      rate - the rating value
      ratedAt - 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

      @Nullable public @Nullable Region getRegion()
      Get the parent region from the cache.
      Returns:
      the region, or null if not found
    • getRegionName

      @NotNull public @NotNull String getRegionName()
      Get the parent region's name safely. Returns "?" if not found.
      Returns:
      the region name
    • getPlayerId

      @NotNull public @NotNull UUID getPlayerId()
      Get the rating player's UUID.
      Returns:
      the player UUID
    • setPlayerId

      public void setPlayerId(@NotNull @NotNull UUID playerId)
      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 null if not found
    • setPlayer

      public void setPlayer(@NotNull @NotNull org.bukkit.OfflinePlayer player)
      Set the rating player.
      Parameters:
      player - the new player
    • getPlayerName

      @NotNull public @NotNull String 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