-
Notifications
You must be signed in to change notification settings - Fork 12
Dbo
alexstaeding edited this page Feb 26, 2020
·
1 revision
In our SimplePvp example, we need to store user data (like kills and deaths) somehow. The first step is to define the template for a single item in our database. We will call it Member
(to avoid confusion with Player
and User
). We know we want to store kills and deaths, so we start out with this:
public interface Member {
int getKills();
void setKills(int kills);
int getDeaths();
void setDeaths(int deaths);
}
However, a Member
also needs to store a reference to its user. This can be done by adding:
UUID getUserUUID();
void setUserUUID(UUID userUUID);
Every dbo (database object) needs some unique id. Fortunately, there is an interface with that property called ObjectWithId
. It has a type parameter for the id (because we want to target multiple databases with different id types). This is the final result for the Member
interface:
public interface Member<TKey> extends ObjectWithId<TKey> {
UUID getUserUUID();
void setUserUUID(UUID userUUID);
int getKills();
void setKills(int kills);
int getDeaths();
void setDeaths(int deaths);
}