Plan/Plan/src/main/java/com/djrapitops/plan/data/store/containers/PlayerContainer.java

33 lines
1.0 KiB
Java

package com.djrapitops.plan.data.store.containers;
import com.djrapitops.plan.data.store.mutators.ActivityIndex;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
import java.util.HashMap;
import java.util.Map;
/**
* DataContainer about a Player.
* <p>
* Use {@code getValue(PlayerKeys.REGISTERED).isPresent()} to determine if Plan has data about the player.
*
* @author Rsl1122
* @see com.djrapitops.plan.data.store.keys.PlayerKeys For Key objects.
*/
public class PlayerContainer extends DataContainer {
private Map<Long, ActivityIndex> activityIndexCache;
public PlayerContainer() {
activityIndexCache = new HashMap<>();
}
public ActivityIndex getActivityIndex(long date, int minuteThreshold, int loginThreshold) {
return activityIndexCache.computeIfAbsent(date, time -> new ActivityIndex(this, time, minuteThreshold, loginThreshold));
}
public boolean playedBetween(long after, long before) {
return SessionsMutator.forContainer(this).playedBetween(after, before);
}
}