Rest of PlayerContainer, mutators

This commit is contained in:
Rsl1122 2018-06-05 11:24:07 +03:00
parent efb1e33673
commit 7805c2e372
10 changed files with 403 additions and 42 deletions

View File

@ -9,6 +9,7 @@ import com.djrapitops.plan.data.container.Action;
import com.djrapitops.plan.data.container.GeoInfo;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.utilities.comparators.ActionComparator;
@ -123,7 +124,7 @@ public class PlayerProfile {
// Calculating Getters
public ActivityIndex getActivityIndex(long date) {
return activityIndexCache.computeIfAbsent(date, dateValue -> new ActivityIndex(this, dateValue));
return activityIndexCache.computeIfAbsent(date, dateValue -> new ActivityIndex(new PlayerContainer(), dateValue));
}
/**

View File

@ -1,20 +1,25 @@
package com.djrapitops.plan.data.calculation;
import com.djrapitops.plan.data.PlayerProfile;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.utilities.Verify;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ActivityIndex {
private final double value;
public ActivityIndex(PlayerProfile player, long date) {
value = calculate(player, date);
public ActivityIndex(DataContainer container, long date) {
Verify.isTrue(container.supports(PlayerKeys.SESSIONS),
() -> new IllegalArgumentException("Given container does not support sessions."));
value = calculate(container, date);
}
public static String[] getGroups() {
@ -29,7 +34,7 @@ public class ActivityIndex {
return value <= 0 ? 1 : value;
}
private double calculate(PlayerProfile player, long date) {
private double calculate(DataContainer container, long date) {
long week = TimeAmount.WEEK.ms();
long weekAgo = date - week;
long twoWeeksAgo = date - 2L * week;
@ -38,24 +43,25 @@ public class ActivityIndex {
long activePlayThreshold = loadSetting(Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms());
int activeLoginThreshold = loadSetting(Settings.ACTIVE_LOGIN_THRESHOLD.getNumber());
List<Session> sessionsWeek = player.getSessions(weekAgo, date).collect(Collectors.toList());
List<Session> sessionsWeek2 = player.getSessions(twoWeeksAgo, weekAgo).collect(Collectors.toList());
List<Session> sessionsWeek3 = player.getSessions(threeWeeksAgo, twoWeeksAgo).collect(Collectors.toList());
List<Session> sessions = container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>());
SessionsMutator weekOne = new SessionsMutator(sessions).filterSessionsBetween(weekAgo, date);
SessionsMutator weekTwo = new SessionsMutator(sessions).filterSessionsBetween(twoWeeksAgo, weekAgo);
SessionsMutator weekThree = new SessionsMutator(sessions).filterSessionsBetween(threeWeeksAgo, twoWeeksAgo);
// Playtime per week multipliers, max out to avoid too high values.
double max = 4.0;
long playtimeWeek = PlayerProfile.getActivePlaytime(sessionsWeek.stream());
long playtimeWeek = weekOne.toActivePlaytime();
double weekPlay = (playtimeWeek * 1.0 / activePlayThreshold);
if (weekPlay > max) {
weekPlay = max;
}
long playtimeWeek2 = PlayerProfile.getActivePlaytime(sessionsWeek2.stream());
long playtimeWeek2 = weekTwo.toActivePlaytime();
double week2Play = (playtimeWeek2 * 1.0 / activePlayThreshold);
if (week2Play > max) {
week2Play = max;
}
long playtimeWeek3 = PlayerProfile.getActivePlaytime(sessionsWeek3.stream());
long playtimeWeek3 = weekThree.toActivePlaytime();
double week3Play = (playtimeWeek3 * 1.0 / activePlayThreshold);
if (week3Play > max) {
week3Play = max;
@ -79,9 +85,9 @@ public class ActivityIndex {
double playAvg = (weekPlay + week2Play + week3Play) / 3.0;
double weekLogin = sessionsWeek.size() >= activeLoginThreshold ? 1.0 : 0.5;
double week2Login = sessionsWeek2.size() >= activeLoginThreshold ? 1.0 : 0.5;
double week3Login = sessionsWeek3.size() >= activeLoginThreshold ? 1.0 : 0.5;
double weekLogin = weekOne.count() >= activeLoginThreshold ? 1.0 : 0.5;
double week2Login = weekTwo.count() >= activeLoginThreshold ? 1.0 : 0.5;
double week3Login = weekThree.count() >= activeLoginThreshold ? 1.0 : 0.5;
double loginMultiplier = 1.0;
double loginTotal = weekLogin + week2Login + week3Login;

View File

@ -25,11 +25,11 @@ public class DataContainer extends HashMap<Key, Supplier> {
* @param <T> Type of the object
*/
public <T> void putRawData(Key<T> key, T obj) {
put(key, () -> obj);
super.put(key, () -> obj);
}
public <T> void putSupplier(Key<T> key, Supplier<T> supplier) {
put(key, new CachingSupplier<>(supplier));
super.put(key, new CachingSupplier<>(supplier));
}
/**
@ -74,4 +74,18 @@ public class DataContainer extends HashMap<Key, Supplier> {
}
return (T) supplier.get();
}
/**
* Normal put method.
*
* @param key Key.
* @param value Supplier
* @return the previous value.
* @deprecated Use putSupplier instead for type safety.
*/
@Override
@Deprecated
public Supplier put(Key key, Supplier value) {
return super.put(key, value);
}
}

View File

@ -0,0 +1,12 @@
package com.djrapitops.plan.data.store.containers;
import java.util.HashMap;
import java.util.UUID;
/**
* Container for data
*
* @author Rsl1122
*/
public class PerServerData extends HashMap<UUID, DataContainer> {
}

View File

@ -1,10 +1,13 @@
package com.djrapitops.plan.data.store.keys;
import com.djrapitops.plan.data.container.GeoInfo;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.Type;
import com.djrapitops.plan.data.store.objects.DateMap;
import com.djrapitops.plan.data.store.containers.PerServerData;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.data.time.WorldTimes;
import java.util.List;
import java.util.UUID;
@ -23,5 +26,20 @@ public class PlayerKeys {
public static final Key<Long> REGISTERED = new Key<>(Long.class, "registered");
public static final Key<Integer> KICK_COUNT = new Key<>(Integer.class, "kick_count");
public static final Key<DateMap<GeoInfo>> GEO_INFO = new Key<>(new Type<DateMap<GeoInfo>>() {}, "geo_info");
public static final Key<List<GeoInfo>> GEO_INFO = new Key<>(new Type<List<GeoInfo>>() {}, "geo_info");
public static final Key<Session> ACTIVE_SESSION = new Key<Session>(Session.class, "active_session");
public static final Key<List<Session>> SESSIONS = new Key<>(new Type<List<Session>>() {}, "sessions");
public static final Key<WorldTimes> WORLD_TIMES = new Key<>(WorldTimes.class, "world_times");
public static final Key<List<PlayerKill>> PLAYER_KILLS = new Key<>(new Type<List<PlayerKill>>() {}, "player_kills");
public static final Key<Integer> PLAYER_KILL_COUNT = new Key<>(Integer.class, "player_kill_count");
public static final Key<Integer> MOB_KILL_COUNT = new Key<>(Integer.class, "mob_kill_count");
public static final Key<Integer> DEATH_COUNT = new Key<>(Integer.class, "death_count");
public static final Key<PerServerData> PER_SERVER = new Key<>(PerServerData.class, "per_server_data");
public static final Key<Long> LAST_SEEN = new Key<>(Long.class, "last_seen");
public static final Key<Boolean> BANNED = new Key<>(Boolean.class, "banned");
public static final Key<Boolean> OPERATOR = new Key<>(Boolean.class, "operator");
}

View File

@ -0,0 +1,93 @@
package com.djrapitops.plan.data.store.mutators;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.PerServerData;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.time.WorldTimes;
import java.util.*;
import java.util.stream.Collectors;
/**
* Mutator for PerServerData object.
*
* @author Rsl1122
*/
public class PerServerDataMutator {
private final PerServerData data;
public PerServerDataMutator(PerServerData data) {
this.data = data;
}
public List<Session> flatMapSessions() {
return data.values().stream()
.map(container -> container.getUnsafe(PlayerKeys.SESSIONS))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
public WorldTimes flatMapWorldTimes() {
WorldTimes total = new WorldTimes(new HashMap<>());
for (DataContainer container : data.values()) {
WorldTimes worldTimes = container.getUnsafe(PlayerKeys.WORLD_TIMES);
total.add(worldTimes);
}
return total;
}
public Map<UUID, WorldTimes> worldTimesPerServer() {
Map<UUID, WorldTimes> timesMap = new HashMap<>();
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
timesMap.put(entry.getKey(), entry.getValue().getUnsafe(PlayerKeys.WORLD_TIMES));
}
return timesMap;
}
public UUID favoriteServer() {
long max = 0;
UUID maxServer = null;
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
long total = entry.getValue().getValue(PlayerKeys.WORLD_TIMES)
.orElse(new WorldTimes(new HashMap<>()))
.getTotal();
if (total > max) {
max = total;
maxServer = entry.getKey();
}
}
return maxServer;
}
public Map<UUID, List<Session>> sessionsPerServer() {
Map<UUID, List<Session>> sessionMap = new HashMap<>();
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
sessionMap.put(entry.getKey(), entry.getValue().getUnsafe(PlayerKeys.SESSIONS));
}
return sessionMap;
}
public boolean isBanned() {
for (DataContainer container : data.values()) {
if (container.getUnsafe(PlayerKeys.BANNED)) {
return true;
}
}
return false;
}
public boolean isOperator() {
for (DataContainer container : data.values()) {
if (container.getUnsafe(PlayerKeys.OPERATOR)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,117 @@
package com.djrapitops.plan.data.store.mutators;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.time.WorldTimes;
import java.util.*;
import java.util.stream.Collectors;
/**
* Mutator for a list of Sessions.
* <p>
* Can be used to get properties of a large number of sessions easily.
*
* @author Rsl1122
*/
public class SessionsMutator {
private List<Session> sessions;
public SessionsMutator(List<Session> sessions) {
this.sessions = sessions;
}
public SessionsMutator filterSessionsBetween(long after, long before) {
sessions = sessions.stream()
.filter(session -> session.getSessionEnd() < after && session.getSessionStart() > before)
.collect(Collectors.toList());
return this;
}
public WorldTimes toTotalWorldTimes() {
WorldTimes total = new WorldTimes(new HashMap<>());
for (Session session : sessions) {
WorldTimes worldTimes = session.getWorldTimes();
total.add(worldTimes);
}
return total;
}
public List<PlayerKill> toPlayerKillList() {
return sessions.stream()
.map(Session::getPlayerKills)
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
public int toMobKillCount() {
return sessions.stream()
.mapToInt(Session::getMobKills)
.sum();
}
public int toDeathCount() {
return sessions.stream()
.mapToInt(Session::getDeaths)
.sum();
}
public long toPlaytime() {
return sessions.stream()
.mapToLong(Session::getLength)
.sum();
}
public long toAfkTime() {
return sessions.stream()
.mapToLong(Session::getAfkLength)
.sum();
}
public long toActivePlaytime() {
return sessions.stream()
.mapToLong(Session::getActiveLength)
.sum();
}
public long toLastSeen() {
return sessions.stream()
.mapToLong(session -> Math.max(session.getSessionStart(), session.getSessionEnd()))
.max().orElse(-1);
}
public long toLongestSessionLength() {
OptionalLong longestSession = sessions.stream().mapToLong(Session::getLength).max();
if (longestSession.isPresent()) {
return longestSession.getAsLong();
}
return -1;
}
public long toAverageSessionLength() {
OptionalDouble average = sessions.stream().map(Session::getLength)
.mapToLong(i -> i)
.average();
if (average.isPresent()) {
return (long) average.getAsDouble();
}
return 0L;
}
public long toMedianSessionLength() {
List<Long> sessionLengths = sessions.stream().map(Session::getLength)
.sorted()
.collect(Collectors.toList());
if (sessionLengths.isEmpty()) {
return 0;
}
return sessionLengths.get(sessionLengths.size() / 2);
}
public int count() {
return sessions.size();
}
}

View File

@ -4,8 +4,13 @@ import com.djrapitops.plan.data.PlayerProfile;
import com.djrapitops.plan.data.ServerProfile;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.data.container.*;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.PerServerData;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.mutators.PerServerDataMutator;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
import com.djrapitops.plan.system.info.server.Server;
@ -128,11 +133,83 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
container.putRawData(PlayerKeys.UUID, uuid);
container.putAll(usersTable.getUserInformation(uuid));
container.put(PlayerKeys.GEO_INFO, () -> GeoInfo.intoDateMap(geoInfoTable.getGeoInfo(uuid)));
container.put(PlayerKeys.NICKNAMES, () -> nicknamesTable.getNicknameInformation(uuid));
container.putSupplier(PlayerKeys.GEO_INFO, () -> geoInfoTable.getGeoInfo(uuid));
container.putSupplier(PlayerKeys.NICKNAMES, () -> nicknamesTable.getNicknameInformation(uuid));
container.putSupplier(PlayerKeys.PER_SERVER, () -> getPerServerData(uuid));
container.putSupplier(PlayerKeys.BANNED,
() -> new PerServerDataMutator(container.getUnsafe(PlayerKeys.PER_SERVER)).isBanned());
container.putSupplier(PlayerKeys.OPERATOR,
() -> new PerServerDataMutator(container.getUnsafe(PlayerKeys.PER_SERVER)).isOperator());
container.putSupplier(PlayerKeys.SESSIONS, () -> {
List<Session> sessions = new PerServerDataMutator(container.getUnsafe(PlayerKeys.PER_SERVER)).flatMapSessions();
container.getValue(PlayerKeys.ACTIVE_SESSION).ifPresent(sessions::add);
return sessions;
}
);
container.putSupplier(PlayerKeys.WORLD_TIMES, () ->
{
WorldTimes worldTimes = new PerServerDataMutator(container.getUnsafe(PlayerKeys.PER_SERVER)).flatMapWorldTimes();
container.getValue(PlayerKeys.ACTIVE_SESSION).ifPresent(session -> worldTimes.add(session.getWorldTimes()));
return worldTimes;
});
container.putSupplier(PlayerKeys.LAST_SEEN, () ->
new SessionsMutator(container.getUnsafe(PlayerKeys.SESSIONS)).toLastSeen());
container.putSupplier(PlayerKeys.PLAYER_KILLS, () ->
new SessionsMutator(container.getUnsafe(PlayerKeys.SESSIONS)).toPlayerKillList());
container.putSupplier(PlayerKeys.PLAYER_KILL_COUNT, () ->
container.getUnsafe(PlayerKeys.PLAYER_KILLS).size());
container.putSupplier(PlayerKeys.MOB_KILL_COUNT, () ->
new SessionsMutator(container.getUnsafe(PlayerKeys.SESSIONS)).toMobKillCount());
container.putSupplier(PlayerKeys.DEATH_COUNT, () ->
new SessionsMutator(container.getUnsafe(PlayerKeys.SESSIONS)).toDeathCount());
return container;
}
private PerServerData getPerServerData(UUID uuid) {
PerServerData perServerData = new PerServerData();
Map<UUID, UserInfo> allUserInfo = userInfoTable.getAllUserInfo(uuid);
for (Map.Entry<UUID, UserInfo> entry : allUserInfo.entrySet()) {
UUID serverUUID = entry.getKey();
UserInfo info = entry.getValue();
DataContainer perServer = perServerData.getOrDefault(serverUUID, new DataContainer());
perServer.putRawData(PlayerKeys.REGISTERED, info.getRegistered());
perServer.putRawData(PlayerKeys.BANNED, info.isBanned());
perServer.putRawData(PlayerKeys.OPERATOR, info.isOpped());
perServerData.put(serverUUID, perServer);
}
Map<UUID, List<Session>> sessions = sessionsTable.getSessions(uuid);
for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) {
UUID serverUUID = entry.getKey();
List<Session> serverSessions = entry.getValue();
DataContainer perServer = perServerData.getOrDefault(serverUUID, new DataContainer());
perServer.putRawData(PlayerKeys.SESSIONS, serverSessions);
perServer.putSupplier(PlayerKeys.WORLD_TIMES, () ->
new SessionsMutator(perServer.getUnsafe(PlayerKeys.SESSIONS)).toTotalWorldTimes());
perServer.putSupplier(PlayerKeys.PLAYER_KILLS, () ->
new SessionsMutator(perServer.getUnsafe(PlayerKeys.SESSIONS)).toPlayerKillList());
perServer.putSupplier(PlayerKeys.PLAYER_KILL_COUNT, () ->
perServer.getUnsafe(PlayerKeys.PLAYER_KILLS).size());
perServer.putSupplier(PlayerKeys.MOB_KILL_COUNT, () ->
new SessionsMutator(perServer.getUnsafe(PlayerKeys.SESSIONS)).toMobKillCount());
perServer.putSupplier(PlayerKeys.DEATH_COUNT, () ->
new SessionsMutator(perServer.getUnsafe(PlayerKeys.SESSIONS)).toDeathCount());
perServerData.put(serverUUID, perServer);
}
return perServerData;
}
@Override
public Set<UUID> getSavedUUIDs() {
return usersTable.getSavedUUIDs();

View File

@ -1,14 +1,15 @@
package com.djrapitops.plan.data;
package com.djrapitops.plan.data.calculation;
import com.djrapitops.plan.data.PlayerProfile;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.TimeAmount;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import utilities.mocks.SystemMockUtil;
import java.util.ArrayList;
@ -17,9 +18,12 @@ import java.util.List;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(MockitoJUnitRunner.Silent.class)
public class PlayerProfileTest {
/**
* Test for ActivityIndex.
*
* @author Rsl1122
*/
public class ActivityIndexTest {
@ClassRule
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
@ -30,7 +34,7 @@ public class PlayerProfileTest {
@Test
public void testMaxActivityIndex() {
PlayerProfile p = new PlayerProfile(null, null, 0L);
PlayerContainer container = new PlayerContainer();
List<Session> sessions = new ArrayList<>();
long date = System.currentTimeMillis();
@ -47,14 +51,14 @@ public class PlayerProfileTest {
sessions.add(new Session(0, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
sessions.add(new Session(0, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 4L, 0, 0, 0));
}
p.setSessions(null, sessions);
container.putRawData(PlayerKeys.SESSIONS, sessions);
assertEquals(5.0, p.getActivityIndex(date).getValue());
assertEquals(5.0, new ActivityIndex(container, date).getValue());
}
@Test
public void testMaxActivityIndex2() {
PlayerProfile p = new PlayerProfile(null, null, 0L);
PlayerContainer container = new PlayerContainer();
List<Session> sessions = new ArrayList<>();
long date = System.currentTimeMillis();
@ -71,14 +75,14 @@ public class PlayerProfileTest {
sessions.add(new Session(0, twoWeeksAgo, twoWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
sessions.add(new Session(0, threeWeeksAgo, threeWeeksAgo + requiredPlaytime * 3L, 0, 0, 0));
}
p.setSessions(null, sessions);
container.putRawData(PlayerKeys.SESSIONS, sessions);
assertEquals(5.0, p.getActivityIndex(date).getValue());
assertEquals(5.0, new ActivityIndex(container, date).getValue());
}
@Test
public void testActivityIndexOne() {
PlayerProfile p = new PlayerProfile(null, null, 0L);
PlayerContainer container = new PlayerContainer();
List<Session> sessions = new ArrayList<>();
long date = System.currentTimeMillis();
@ -95,13 +99,13 @@ public class PlayerProfileTest {
sessions.add(new Session(i * 2, twoWeeksAgo, twoWeeksAgo + requiredPlaytime, 0, 0, 0));
sessions.add(new Session(i * 3, threeWeeksAgo, threeWeeksAgo + requiredPlaytime, 0, 0, 0));
}
p.setSessions(null, sessions);
container.putRawData(PlayerKeys.SESSIONS, sessions);
assertTrue(2.0 <= p.getActivityIndex(date).getValue());
assertTrue(2.0 <= new ActivityIndex(container, date).getValue());
}
@Test(timeout = 500)
public void testMethodTimeout() {
public void testTimeout() {
PlayerProfile p = new PlayerProfile(null, null, 0L);
List<Session> sessions = new ArrayList<>();
long date = 0;
@ -112,5 +116,4 @@ public class PlayerProfileTest {
p.setSessions(null, sessions);
p.getActivityIndex(0);
}
}

View File

@ -13,7 +13,6 @@ import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.data.container.*;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.objects.DateMap;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.data.time.GMTimes;
import com.djrapitops.plan.data.time.WorldTimes;
@ -1047,6 +1046,23 @@ public class SQLiteTest {
assertTrue(container.supports(PlayerKeys.GEO_INFO));
assertTrue(container.supports(PlayerKeys.NICKNAMES));
assertTrue(container.supports(PlayerKeys.PER_SERVER));
assertTrue(container.supports(PlayerKeys.OPERATOR));
assertTrue(container.supports(PlayerKeys.BANNED));
assertTrue(container.supports(PlayerKeys.SESSIONS));
assertTrue(container.supports(PlayerKeys.WORLD_TIMES));
assertTrue(container.supports(PlayerKeys.LAST_SEEN));
assertTrue(container.supports(PlayerKeys.DEATH_COUNT));
assertTrue(container.supports(PlayerKeys.MOB_KILL_COUNT));
assertTrue(container.supports(PlayerKeys.PLAYER_KILLS));
assertTrue(container.supports(PlayerKeys.PLAYER_KILL_COUNT));
assertFalse(container.supports(PlayerKeys.ACTIVE_SESSION));
container.putRawData(PlayerKeys.ACTIVE_SESSION, new Session(System.currentTimeMillis(), "TestWorld", "SURVIVAL"));
assertTrue(container.supports(PlayerKeys.ACTIVE_SESSION));
long end = System.nanoTime();
assertFalse("Took too long: " + ((end - start) / 1000000.0) + "ms", end - start > TimeAmount.SECOND.ns());
@ -1056,12 +1072,16 @@ public class SQLiteTest {
OptionalAssert.equals("Test", container.getValue(PlayerKeys.NAME));
OptionalAssert.equals(1, container.getValue(PlayerKeys.KICK_COUNT));
DateMap<GeoInfo> expectedGeoInfo = GeoInfo.intoDateMap(
Collections.singletonList(new GeoInfo("1.2.3.4", "TestLoc", 223456789, "ZpT4PJ9HbaMfXfa8xSADTn5X1CHSR7nTT0ntv8hKdkw="))
);
List<GeoInfo> expectedGeoInfo =
Collections.singletonList(new GeoInfo("1.2.3.4", "TestLoc", 223456789, "ZpT4PJ9HbaMfXfa8xSADTn5X1CHSR7nTT0ntv8hKdkw="));
OptionalAssert.equals(expectedGeoInfo, container.getValue(PlayerKeys.GEO_INFO));
List<Nickname> expectedNicknames = Collections.singletonList(new Nickname("TestNick", -1, TestConstants.SERVER_UUID));
OptionalAssert.equals(expectedNicknames, container.getValue(PlayerKeys.NICKNAMES));
OptionalAssert.equals(false, container.getValue(PlayerKeys.OPERATOR));
OptionalAssert.equals(false, container.getValue(PlayerKeys.BANNED));
// TODO Test rest
}
}