java.lang.Object
tk.airshipcraft.commonlib.db.model.User

public class User extends Object

Represents a player on the Minecraft server.It holds attributes specific to the player's interaction within the server.

Users are stored in a database table with the following schema:

     CREATE TABLE IF NOT EXISTS users (
     id UUID PRIMARY KEY,
     username VARCHAR(255) NOT NULL,
     join_date TIMESTAMP NOT NULL,
     last_join TIMESTAMP NOT NULL,
     last_seen TIMESTAMP NOT NULL,
     total_playtime BIGINT NOT NULL,
     total_deaths INT NOT NULL,
     total_kills INT NOT NULL,
     total_blocks_broken INT NOT NULL,
     fish_caught INT NOT NULL
     );
     CREATE INDEX IF NOT EXISTS username_index ON users (username);
     CREATE INDEX IF NOT EXISTS join_date_index ON users (join_date);
     CREATE INDEX IF NOT EXISTS last_join_index ON users (last_join);
     CREATE INDEX IF NOT EXISTS last_seen_index ON users (last_seen);
     CREATE INDEX IF NOT EXISTS total_playtime_index ON users (total_playtime);
     CREATE INDEX IF NOT EXISTS total_deaths_index ON users (total_deaths);
     CREATE INDEX IF NOT EXISTS total_kills_index ON users (total_kills);
     CREATE INDEX IF NOT EXISTS total_blocks_broken_index ON users (total_blocks_broken);
     CREATE INDEX IF NOT EXISTS fish_caught_index ON users (fish_caught);
     CREATE INDEX IF NOT EXISTS username_join_date_index ON users (username, join_date);
     CREATE INDEX IF NOT EXISTS username_last_join_index ON users (username, last_join);
     CREATE INDEX IF NOT EXISTS username_last_seen_index ON users (username, last_seen);
     CREATE INDEX IF NOT EXISTS username_total_playtime_index ON users (username, total_playtime);
     CREATE INDEX IF NOT EXISTS username_total_deaths_index ON users (username, total_deaths);
     CREATE INDEX IF NOT EXISTS username_total_kills_index ON users (username, total_kills);
     CREATE INDEX IF NOT EXISTS username_total_blocks_broken_index ON users (username, total_blocks_broken);
     CREATE INDEX IF NOT EXISTS username_fish_caught_index ON users (username, fish_caught);
 
Since:
2023-12-27
Version:
1.0.0
Author:
notzune
  • Constructor Details

    • User

      public User()
      Default constructor.
      See Also:
    • User

      public User(UUID id, String username, Timestamp joinDate, Timestamp lastJoin, Timestamp lastSeen, long totalPlaytime, int totalDeaths, int totalKills, int totalBlocksBroken, int fishCaught)
      Constructs a new User with specified details.
      Parameters:
      id - The unique identifier for the user.
      username - The username of the user.
      joinDate - The date when the user first joined the server.
      lastJoin - The last time the user joined the server.
      lastSeen - The last time the user was seen on the server.
      totalPlaytime - The total playtime of the user in milliseconds.
      totalDeaths - The total number of times the user has died.
      totalKills - The total number of kills by the user.
      totalBlocksBroken - The total number of blocks broken by the user.
      fishCaught - The total number of fish caught by the user.
  • Method Details

    • getId

      public UUID getId()
      Returns the user's unique identifier.
      Returns:
      The UUID of the user.
      See Also:
    • setId

      public void setId(UUID id)
      Sets the user's unique identifier.
      Parameters:
      id - The UUID to be set for the user.
      See Also:
    • getUsername

      public String getUsername()
      Returns the user's username.
      Returns:
      The username of the user.
      See Also:
    • setUsername

      public void setUsername(String username)
      Sets the user's username.
      Parameters:
      username - The username to be set for the user.
      See Also:
    • getJoinDate

      public Timestamp getJoinDate()
      Returns the date when the user joined the server.
      Returns:
      The join date of the user.
      See Also:
    • setJoinDate

      public void setJoinDate(Timestamp joinDate)
      Sets the date when the user joined the server.
      Parameters:
      joinDate - The join date to be set for the user.
      See Also:
    • getLastJoin

      public Timestamp getLastJoin()
      Returns the last time the user joined the server.
      Returns:
      The last join time of the user.
      See Also:
    • setLastJoin

      public void setLastJoin(Timestamp lastJoin)
      Sets the last time the user joined the server.
      Parameters:
      lastJoin - The last join time to be set for the user.
      See Also:
    • getLastSeen

      public Timestamp getLastSeen()
      Returns the last time the user was seen on the server.
      Returns:
      The last seen time of the user.
      See Also:
    • setLastSeen

      public void setLastSeen(Timestamp lastSeen)
      Sets the last time the user was seen on the server.
      Parameters:
      lastSeen - The last seen time to be set for the user.
      See Also:
    • getTotalPlaytime

      public long getTotalPlaytime()
      Returns the total playtime of the user in milliseconds.
      Returns:
      playtime in milliseconds. (long)
      See Also:
    • setTotalPlaytime

      public void setTotalPlaytime(long totalPlaytime)
      Sets the total playtime of the user in milliseconds.
      Parameters:
      totalPlaytime - playtime in milliseconds. (long)
      See Also:
    • getTotalDeaths

      public int getTotalDeaths()
      Returns the total number of deaths by the user.
      Returns:
      total number of deaths (int)
      See Also:
    • setTotalDeaths

      public void setTotalDeaths(int totalDeaths)
      Sets the total number of deaths by the user.
      Parameters:
      totalDeaths - total number of deaths (int)
      See Also:
    • getTotalKills

      public int getTotalKills()
      Returns the total number of kills by the user.
      Returns:
      totalKills total number of kills
      See Also:
    • setTotalKills

      public void setTotalKills(int totalKills)
      Sets the total number of kills by the user.
      Parameters:
      totalKills - total number of kills
      See Also:
    • getTotalBlocksBroken

      public int getTotalBlocksBroken()
      Returns the total number of blocks broken by the user.
      Returns:
      total number of blocks broken
      See Also:
    • setTotalBlocksBroken

      public void setTotalBlocksBroken(int totalBlocksBroken)
      Sets the total number of blocks broken by the user.
      Parameters:
      totalBlocksBroken - total number of blocks broken (int)
      See Also:
    • getFishCaught

      public int getFishCaught()
      Returns the total number of fish caught by the user.
      Returns:
      fish caught
      See Also:
    • setFishCaught

      public void setFishCaught(int fishCaught)
      Sets the total number of fish caught by the user.
      Parameters:
      fishCaught - fish caught (int)
      See Also:
    • toString

      public String toString()
      Returns a string representation of the User object.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the User object.
    • equals

      public boolean equals(Object obj)
      Compares the User object with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare with.
      Returns:
      true if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code of the User object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code of the User object.