Class User
java.lang.Object
tk.airshipcraft.commonlib.db.model.User
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares the User object with another object.int
Returns the total number of fish caught by the user.getId()
Returns the user's unique identifier.Returns the date when the user joined the server.Returns the last time the user joined the server.Returns the last time the user was seen on the server.int
Returns the total number of blocks broken by the user.int
Returns the total number of deaths by the user.int
Returns the total number of kills by the user.long
Returns the total playtime of the user in milliseconds.Returns the user's username.int
hashCode()
Returns the hash code of the User object.void
setFishCaught
(int fishCaught) Sets the total number of fish caught by the user.void
Sets the user's unique identifier.void
setJoinDate
(Timestamp joinDate) Sets the date when the user joined the server.void
setLastJoin
(Timestamp lastJoin) Sets the last time the user joined the server.void
setLastSeen
(Timestamp lastSeen) Sets the last time the user was seen on the server.void
setTotalBlocksBroken
(int totalBlocksBroken) Sets the total number of blocks broken by the user.void
setTotalDeaths
(int totalDeaths) Sets the total number of deaths by the user.void
setTotalKills
(int totalKills) Sets the total number of kills by the user.void
setTotalPlaytime
(long totalPlaytime) Sets the total playtime of the user in milliseconds.void
setUsername
(String username) Sets the user's username.toString()
Returns a string representation of the User object.
-
Constructor Details
-
User
public User()Default constructor. -
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
Returns the user's unique identifier.- Returns:
- The UUID of the user.
- See Also:
-
setId
Sets the user's unique identifier.- Parameters:
id
- The UUID to be set for the user.- See Also:
-
getUsername
Returns the user's username.- Returns:
- The username of the user.
- See Also:
-
setUsername
Sets the user's username.- Parameters:
username
- The username to be set for the user.- See Also:
-
getJoinDate
Returns the date when the user joined the server.- Returns:
- The join date of the user.
- See Also:
-
setJoinDate
Sets the date when the user joined the server.- Parameters:
joinDate
- The join date to be set for the user.- See Also:
-
getLastJoin
Returns the last time the user joined the server.- Returns:
- The last join time of the user.
- See Also:
-
setLastJoin
Sets the last time the user joined the server.- Parameters:
lastJoin
- The last join time to be set for the user.- See Also:
-
getLastSeen
Returns the last time the user was seen on the server.- Returns:
- The last seen time of the user.
- See Also:
-
setLastSeen
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
Returns a string representation of the User object. -
equals
Compares the User object with another object. -
hashCode
public int hashCode()Returns the hash code of the User object.
-