Turned Session into a DataContainer, deprecated getters

This commit is contained in:
Rsl1122 2018-06-17 10:40:29 +03:00
parent 51d91b63f8
commit 5184f0caf9
14 changed files with 184 additions and 104 deletions

View File

@ -10,6 +10,7 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.Actions;
import com.djrapitops.plan.data.container.Action;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.system.cache.CacheSystem;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.system.cache.SessionCache;
@ -17,6 +18,7 @@ import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plugin.api.utility.log.Log;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
@ -92,8 +94,8 @@ public class ShutdownHook extends Thread {
for (Map.Entry<UUID, Session> entry : activeSessions.entrySet()) {
UUID uuid = entry.getKey();
Session session = entry.getValue();
long sessionEnd = session.getSessionEnd();
if (sessionEnd == -1) {
Optional<Long> end = session.getValue(SessionKeys.END);
if (!end.isPresent()) {
session.endSession(now);
}
if (!db.isOpen()) {

View File

@ -1,78 +1,101 @@
package com.djrapitops.plan.data.container;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.system.info.server.ServerInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/**
* Object for storing various information about a player's play session.
* <p>
* Includes:
* <ul>
* <li>World and GameMode playtimes</li>
* <li>Player and Mob kills</li>
* <li>Deaths</li>
* </ul>
* <p>
* Following data can be derived from Sessions in the database (Between any time span):
* <ul>
* <li>Playtime</li>
* <li>LoginTimes</li>
* </ul>
* DataContainer for information about a player's play session.
*
* @author Rsl1122
* @see SessionKeys for Key objects.
*/
public class Session implements DateHolder {
public class Session extends DataContainer implements DateHolder {
private final long sessionStart;
private Integer sessionID;
private WorldTimes worldTimes;
private long sessionEnd;
private List<PlayerKill> playerKills;
private int mobKills;
private int deaths;
private long afkTime;
/**
* Creates a new session with given start and end of -1.
* Creates a new session.
*
* @param sessionStart Epoch millisecond the session was started.
* @param uuid UUID of the Player.
* @param sessionStart Epoch ms the session started.
* @param world Starting world.
* @param gm Starting GameMode.
*/
public Session(long sessionStart, String world, String gm) {
this.worldTimes = new WorldTimes(world, gm);
this.sessionStart = sessionStart;
this.sessionEnd = -1;
playerKills = new ArrayList<>();
public Session(UUID uuid, long sessionStart, String world, String gm) {
mobKills = 0;
deaths = 0;
afkTime = 0;
putRawData(SessionKeys.UUID, uuid);
putRawData(SessionKeys.START, sessionStart);
putRawData(SessionKeys.WORLD_TIMES, new WorldTimes(world, gm));
putRawData(SessionKeys.PLAYER_KILLS, new ArrayList<>());
putSupplier(SessionKeys.MOB_KILL_COUNT, () -> mobKills);
putSupplier(SessionKeys.DEATH_COUNT, () -> deaths);
putSupplier(SessionKeys.AFK_TIME, () -> afkTime);
putSupplier(SessionKeys.PLAYER_KILL_COUNT, getUnsafe(SessionKeys.PLAYER_KILLS)::size);
putSupplier(SessionKeys.LENGTH, () ->
getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START));
putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME));
putSupplier(SessionKeys.SERVER_UUID, ServerInfo::getServerUUID);
}
public Session(int id, long sessionStart, long sessionEnd, int mobKills, int deaths, long afkTime) {
this.sessionID = id;
this.sessionStart = sessionStart;
this.sessionEnd = sessionEnd;
this.worldTimes = new WorldTimes(new HashMap<>());
this.playerKills = new ArrayList<>();
/**
* Recreates a Session found in the database.
* <p>
* WorldTimes and Player kills need to be set separately.
*
* @param id ID in the database (Used for fetching world times and player kills.
* @param uuid UUID of the Player.
* @param serverUUID UUID of the Server.
* @param sessionStart Epoch ms the session started.
* @param sessionEnd Epoch ms the session ended.
* @param mobKills Mobs killed during the session.
* @param deaths Death count during the session.
* @param afkTime Time spent AFK during the session.
*/
public Session(int id, UUID uuid, UUID serverUUID, long sessionStart, long sessionEnd, int mobKills, int deaths, long afkTime) {
putRawData(SessionKeys.DB_ID, id);
putRawData(SessionKeys.UUID, uuid);
putRawData(SessionKeys.SERVER_UUID, serverUUID);
putRawData(SessionKeys.START, sessionStart);
putRawData(SessionKeys.END, sessionEnd);
putSupplier(SessionKeys.MOB_KILL_COUNT, () -> mobKills);
putSupplier(SessionKeys.DEATH_COUNT, () -> deaths);
putSupplier(SessionKeys.AFK_TIME, () -> afkTime);
this.mobKills = mobKills;
this.deaths = deaths;
this.afkTime = afkTime;
putSupplier(SessionKeys.PLAYER_KILL_COUNT, () -> getUnsafe(SessionKeys.PLAYER_KILLS).size());
putSupplier(SessionKeys.LENGTH, () ->
getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START));
putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME));
}
/**
* Ends the session with given end point.
* <p>
* (Changes the end to the parameter.).
* Updates world times to the latest value.
*
* @param endOfSession Epoch millisecond the session ended.
*/
public void endSession(long endOfSession) {
sessionEnd = endOfSession;
putRawData(SessionKeys.END, endOfSession);
WorldTimes worldTimes = getValue(SessionKeys.WORLD_TIMES)
.orElseThrow(() -> new IllegalStateException("World times have not been defined"));
worldTimes.updateState(endOfSession);
}
@ -84,10 +107,14 @@ public class Session implements DateHolder {
* @param time Epoch ms of the event.
*/
public void changeState(String world, String gm, long time) {
WorldTimes worldTimes = getValue(SessionKeys.WORLD_TIMES)
.orElseThrow(() -> new IllegalStateException("World times is not defined"));
worldTimes.updateState(world, gm, time);
}
public void playerKilled(PlayerKill kill) {
List<PlayerKill> playerKills = getValue(SessionKeys.PLAYER_KILLS)
.orElseThrow(() -> new IllegalStateException("Player kills is not defined."));
playerKills.add(kill);
}
@ -104,16 +131,14 @@ public class Session implements DateHolder {
*
* @return Long in ms.
*/
@Deprecated
public long getLength() {
if (sessionEnd == -1) {
return System.currentTimeMillis() - sessionStart;
}
return sessionEnd - sessionStart;
return getUnsafe(SessionKeys.LENGTH);
}
@Override
public long getDate() {
return getSessionStart();
return getUnsafe(SessionKeys.START);
}
/**
@ -121,8 +146,9 @@ public class Session implements DateHolder {
*
* @return Epoch millisecond the session started.
*/
@Deprecated
public long getSessionStart() {
return sessionStart;
return getUnsafe(SessionKeys.START);
}
/**
@ -130,46 +156,53 @@ public class Session implements DateHolder {
*
* @return Epoch millisecond the session ended.
*/
@Deprecated
public long getSessionEnd() {
return sessionEnd;
return getValue(SessionKeys.END).orElse(-1L);
}
@Deprecated
public WorldTimes getWorldTimes() {
return worldTimes;
return getValue(SessionKeys.WORLD_TIMES).orElse(null);
}
public void setWorldTimes(WorldTimes worldTimes) {
this.worldTimes = worldTimes;
putRawData(SessionKeys.WORLD_TIMES, worldTimes);
}
@Deprecated
public List<PlayerKill> getPlayerKills() {
return playerKills;
return getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>());
}
public void setPlayerKills(List<PlayerKill> playerKills) {
this.playerKills = playerKills;
putRawData(SessionKeys.PLAYER_KILLS, playerKills);
}
@Deprecated
public int getMobKills() {
return mobKills;
}
@Deprecated
public int getDeaths() {
return deaths;
}
public boolean isFetchedFromDB() {
return sessionID != null;
return supports(SessionKeys.DB_ID);
}
public void addAFKTime(long timeAFK) {
afkTime += timeAFK;
}
@Deprecated
public long getAfkLength() {
return afkTime;
}
@Deprecated
public long getActiveLength() {
return getLength() - getAfkLength();
}
@ -180,12 +213,13 @@ public class Session implements DateHolder {
* @return ID if present.
* @throws NullPointerException if Session was not fetched from DB. Check {@code isFetchedFromDB} first.
*/
@Deprecated
public int getSessionID() {
return sessionID != null ? sessionID : -1;
return getValue(SessionKeys.DB_ID).orElseThrow(() -> new NullPointerException("Session not fetched from DB."));
}
public void setSessionID(int sessionID) {
this.sessionID = sessionID;
putRawData(SessionKeys.DB_ID, sessionID);
}
@Override
@ -193,28 +227,17 @@ public class Session implements DateHolder {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Session session = (Session) o;
return sessionStart == session.sessionStart &&
sessionEnd == session.sessionEnd &&
return getUnsafe(SessionKeys.START).equals(session.getUnsafe(SessionKeys.START)) &&
getValue(SessionKeys.END).orElse(-1L).equals(session.getValue(SessionKeys.END).orElse(-1L)) &&
mobKills == session.mobKills &&
deaths == session.deaths &&
Objects.equals(worldTimes, session.worldTimes) &&
Objects.equals(playerKills, session.playerKills);
}
@Override
public int hashCode() {
return Objects.hash(sessionStart, sessionID, worldTimes, sessionEnd, playerKills, mobKills, deaths);
}
@Override
public String toString() {
return "Session{" +
"sessionStart=" + sessionStart + ", " +
"sessionID=" + sessionID + ", " +
"worldTimes=" + worldTimes + ", " +
"sessionEnd=" + sessionEnd + ", " +
"playerKills=" + playerKills + ", " +
"mobKills=" + mobKills + ", " +
"deaths=" + deaths + '}';
Objects.equals(
getValue(SessionKeys.WORLD_TIMES).orElse(null),
session.getValue(SessionKeys.WORLD_TIMES).orElse(null)
) &&
Objects.equals(
getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>()),
session.getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>())
);
}
}

View File

@ -21,6 +21,7 @@ public class CommonKeys {
}
public static final Key<UUID> UUID = new Key<>(UUID.class, "uuid");
public static final Key<UUID> SERVER_UUID = new Key<>(UUID.class, "server_uuid");
public static final Key<String> NAME = new Key<>(String.class, "name");
public static final Key<Long> REGISTERED = new Key<>(Long.class, "registered");

View File

@ -26,7 +26,7 @@ public class ServerKeys {
/* Static variable class */
}
public static final Key<UUID> UUID = CommonKeys.UUID;
public static final Key<UUID> SERVER_UUID = CommonKeys.SERVER_UUID;
public static final Key<String> NAME = CommonKeys.NAME;
public static final Key<List<PlayerContainer>> PLAYERS = new Key<>(new Type<List<PlayerContainer>>() {}, "players");

View File

@ -0,0 +1,37 @@
package com.djrapitops.plan.data.store.keys;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.time.WorldTimes;
import java.util.List;
import java.util.UUID;
/**
* Class holding Key objects for Session (DataContainer).
*
* @author Rsl1122
* @see com.djrapitops.plan.data.container.Session for DataContainer.
*/
public class SessionKeys {
public static final Key<Integer> DB_ID = new Key<>(Integer.class, "db_id");
public static final Key<UUID> UUID = CommonKeys.UUID;
public static final Key<UUID> SERVER_UUID = CommonKeys.SERVER_UUID;
public static final Key<Long> START = new Key<>(Long.class, "start");
public static final Key<Long> END = new Key<>(Long.class, "end");
public static final Key<Long> LENGTH = new Key<>(Long.class, "length");
public static final Key<Long> AFK_TIME = new Key<>(Long.class, "afk_time");
public static final Key<Long> ACTIVE_TIME = new Key<>(Long.class, "active_time");
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
public static final Key<List<PlayerKill>> PLAYER_KILLS = CommonKeys.PLAYER_KILLS;
public static final Key<Integer> PLAYER_KILL_COUNT = CommonKeys.PLAYER_KILL_COUNT;
public static final Key<Integer> MOB_KILL_COUNT = CommonKeys.MOB_KILL_COUNT;
public static final Key<Integer> DEATH_COUNT = CommonKeys.DEATH_COUNT;
private SessionKeys() {
/* Static variable class */
}
}

View File

@ -178,7 +178,7 @@ public class SessionsTable extends UserIDTable {
int deaths = set.getInt(Col.DEATHS.get());
int mobKills = set.getInt(Col.MOB_KILLS.get());
List<Session> sessions = sessionsByServer.getOrDefault(serverUUID, new ArrayList<>());
sessions.add(new Session(id, start, end, mobKills, deaths, timeAFK));
sessions.add(new Session(id, uuid, serverUUID, start, end, mobKills, deaths, timeAFK));
sessionsByServer.put(serverUUID, sessions);
}
return sessionsByServer;
@ -473,7 +473,7 @@ public class SessionsTable extends UserIDTable {
long timeAFK = set.getLong(Col.AFK_TIME.get());
List<Session> sessions = sessionsByUser.getOrDefault(uuid, new ArrayList<>());
sessions.add(new Session(set.getInt(Col.ID.get()), start, end, mobKills, deaths, timeAFK));
sessions.add(new Session(set.getInt(Col.ID.get()), uuid, serverUUID, start, end, mobKills, deaths, timeAFK));
sessionsByUser.put(uuid, sessions);
}
return sessionsByUser;
@ -567,7 +567,7 @@ public class SessionsTable extends UserIDTable {
long timeAFK = set.getLong(Col.AFK_TIME.get());
Session session = new Session(id, start, end, mobKills, deaths, timeAFK);
Session session = new Session(id, uuid, serverUUID, start, end, mobKills, deaths, timeAFK);
sessions.add(session);
sessionsByUser.put(uuid, sessions);
@ -623,7 +623,7 @@ public class SessionsTable extends UserIDTable {
long timeAFK = set.getLong(Col.AFK_TIME.get());
Session session = new Session(id, start, end, mobKills, deaths, timeAFK);
Session session = new Session(id, uuid, serverUUID, start, end, mobKills, deaths, timeAFK);
sessions.add(session);
sessionsByUser.put(uuid, sessions);

View File

@ -96,7 +96,7 @@ public class PlayerOnlineListener implements Listener {
int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline();
SessionCache.getInstance().cacheSession(uuid, new Session(time, world, gm));
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
Processing.submit(
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,

View File

@ -99,7 +99,7 @@ public class SpongePlayerListener {
int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline();
SessionCache.getInstance().cacheSession(uuid, new Session(time, world, gm));
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
Processing.submit(
new RegisterProcessor(uuid, time, time, playerName, playersOnline,

View File

@ -116,7 +116,7 @@ public abstract class Importer {
Benchmark.stop(benchmarkName);
}
private void processUserData() throws DBException {
private void processUserData() {
String benchmarkName = "Processing User Data";
String getDataBenchmarkName = "Getting User Data";
String insertDataIntoCollectionsBenchmarkName = "Insert User Data into Collections";
@ -215,7 +215,7 @@ public abstract class Importer {
int mobKills = userImportData.getMobKills();
int deaths = userImportData.getDeaths();
Session session = new Session(0, 0L, 0L, mobKills, deaths, 0);
Session session = new Session(0, userImportData.getUuid(), ServerInfo.getServerUUID(), 0L, 0L, mobKills, deaths, 0);
session.setPlayerKills(userImportData.getKills());
session.setWorldTimes(new WorldTimes(userImportData.getWorldTimes()));

View File

@ -34,7 +34,20 @@ public class SessionAccordion extends AbstractAccordion {
}
private void addElements() {
if (forPlayer) {
addElementsForPlayer();
} else {
addElementsForServer();
}
// Requires refactoring of Session object to contain information about player and server
}
private void addElementsForServer() {
}
private void addElementsForPlayer() {
}
}

View File

@ -9,10 +9,12 @@ import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import utilities.TestConstants;
import utilities.mocks.SystemMockUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;
@ -25,6 +27,8 @@ import static org.junit.Assert.assertTrue;
public class ActivityIndexTest {
@ClassRule
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
private static final UUID UUID = TestConstants.PLAYER_ONE_UUID;
private static final UUID SERVER_UUID = TestConstants.SERVER_UUID;
@BeforeClass
public static void setUpClass() throws Exception {
@ -46,9 +50,9 @@ public class ActivityIndexTest {
int requiredLogins = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber();
for (int i = 0; i < requiredLogins; i++) {
sessions.add(new Session(0, weekAgo, weekAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, weekAgo, weekAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
}
container.putRawData(PlayerKeys.SESSIONS, sessions);
@ -70,9 +74,9 @@ public class ActivityIndexTest {
int requiredLogins = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber();
for (int i = 0; i < requiredLogins * 2; i++) {
sessions.add(new Session(0, weekAgo, weekAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, weekAgo, weekAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
}
container.putRawData(PlayerKeys.SESSIONS, sessions);
assertTrue(container.supports(PlayerKeys.SESSIONS));
@ -96,9 +100,9 @@ public class ActivityIndexTest {
long requiredPlaytime = Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms() / requiredLogins;
for (int i = 0; i < requiredLogins; i++) {
sessions.add(new Session(i, weekAgo, weekAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i * 2, twoWeeksAgo, twoWeeksAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i * 3, threeWeeksAgo, threeWeeksAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i, UUID, SERVER_UUID, weekAgo, weekAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i * 2, UUID, SERVER_UUID, twoWeeksAgo, twoWeeksAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i * 3, UUID, SERVER_UUID, threeWeeksAgo, threeWeeksAgo + requiredPlaytime, 0, 0, 0));
}
container.putRawData(PlayerKeys.SESSIONS, sessions);
@ -112,7 +116,7 @@ public class ActivityIndexTest {
long date = 0;
for (int i = 0; i < 5000; i++) {
sessions.add(new Session(0, 0, 0, 0, 0, 0));
sessions.add(new Session(0, UUID, SERVER_UUID, 0, 0, 0, 0, 0));
}
container.putRawData(PlayerKeys.SESSIONS, sessions);

View File

@ -32,7 +32,7 @@ public class SessionCacheTest {
@Before
public void setUp() {
sessionCache = new SessionCache(null);
session = new Session(12345L, "World1", "SURVIVAL");
session = new Session(uuid, 12345L, "World1", "SURVIVAL");
sessionCache.cacheSession(uuid, session);
}

View File

@ -362,7 +362,7 @@ public class SQLiteTest {
saveTwoWorlds();
saveUserOne();
saveUserTwo();
Session session = new Session(12345L, "", "");
Session session = new Session(TestConstants.PLAYER_ONE_UUID, 12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
@ -393,7 +393,7 @@ public class SQLiteTest {
saveUserOne();
saveUserTwo();
Session session = new Session(12345L, "", "");
Session session = new Session(TestConstants.PLAYER_ONE_UUID, 12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
@ -558,7 +558,7 @@ public class SQLiteTest {
userInfoTable.registerUserInfo(playerUUID, 223456789L);
saveTwoWorlds();
Session session = new Session(12345L, "", "");
Session session = new Session(TestConstants.PLAYER_ONE_UUID, 12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
@ -627,7 +627,7 @@ public class SQLiteTest {
userInfoTable.registerUserInfo(playerUUID, 223456789L);
saveTwoWorlds(database);
Session session = new Session(12345L, "", "");
Session session = new Session(TestConstants.PLAYER_ONE_UUID, 12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
@ -717,7 +717,7 @@ public class SQLiteTest {
saveUserOne();
saveUserTwo();
Session session = new Session(12345L, "", "");
Session session = new Session(TestConstants.PLAYER_ONE_UUID, 12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
@ -800,7 +800,7 @@ public class SQLiteTest {
WorldTimesTable worldTimesTable = db.getWorldTimesTable();
worldTimesTable.saveWorldTimes(playerUUID, 1, worldTimes);
Session session = new Session(1, 12345L, 23456L, 0, 0, 0);
Session session = new Session(1, playerUUID, TestConstants.SERVER_UUID, 12345L, 23456L, 0, 0, 0);
Map<Integer, Session> sessions = new HashMap<>();
sessions.put(1, session);
worldTimesTable.addWorldTimesToSessions(playerUUID, sessions);
@ -814,7 +814,7 @@ public class SQLiteTest {
WorldTimes worldTimes = createWorldTimes();
System.out.println(worldTimes);
WorldTimesTable worldTimesTable = db.getWorldTimesTable();
Session session = new Session(1, 12345L, 23456L, 0, 0, 0);
Session session = new Session(1, playerUUID, TestConstants.SERVER_UUID, 12345L, 23456L, 0, 0, 0);
session.setWorldTimes(worldTimes);
Map<UUID, Map<UUID, List<Session>>> map = new HashMap<>();
@ -837,7 +837,7 @@ public class SQLiteTest {
saveUserOne();
WorldTimes worldTimes = createWorldTimes();
System.out.println(worldTimes);
Session session = new Session(1, 12345L, 23456L, 0, 0, 0);
Session session = new Session(1, playerUUID, TestConstants.SERVER_UUID, 12345L, 23456L, 0, 0, 0);
session.setWorldTimes(worldTimes);
Map<UUID, Map<UUID, List<Session>>> map = new HashMap<>();
@ -1060,7 +1060,7 @@ public class SQLiteTest {
assertTrue(container.supports(PlayerKeys.PLAYER_KILL_COUNT));
assertFalse(container.supports(PlayerKeys.ACTIVE_SESSION));
container.putRawData(PlayerKeys.ACTIVE_SESSION, new Session(System.currentTimeMillis(), "TestWorld", "SURVIVAL"));
container.putRawData(PlayerKeys.ACTIVE_SESSION, new Session(TestConstants.PLAYER_ONE_UUID, System.currentTimeMillis(), "TestWorld", "SURVIVAL"));
assertTrue(container.supports(PlayerKeys.ACTIVE_SESSION));
long end = System.nanoTime();

View File

@ -48,7 +48,7 @@ public class RandomData {
public static List<Session> randomSessions() {
List<Session> test = new ArrayList<>();
for (int i = 0; i < 20; i++) {
test.add(new Session(1, r.nextLong(), r.nextLong(), 0, 0, 0));
test.add(new Session(1, TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, r.nextLong(), r.nextLong(), 0, 0, 0));
}
return test;
}