mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Removed unnecessary use of getValue inside Session
This commit is contained in:
parent
0294dc4ec8
commit
1456d78bd4
@ -10,7 +10,7 @@ import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@ -19,7 +19,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class GeoInfo implements DateHolder {
|
||||
public class GeoInfo implements DateHolder, Serializable {
|
||||
|
||||
private final String ip;
|
||||
private final String geolocation;
|
||||
@ -27,7 +27,7 @@ public class GeoInfo implements DateHolder {
|
||||
private final long date;
|
||||
|
||||
public GeoInfo(InetAddress address, String geolocation, long lastUsed)
|
||||
throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
this(FormatUtils.formatIP(address), geolocation, lastUsed, new SHA256Hash(address.getHostAddress()).create());
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -11,7 +12,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerKill implements DateHolder {
|
||||
public class PlayerKill implements DateHolder, Serializable {
|
||||
|
||||
private final UUID victim;
|
||||
private final long date;
|
||||
|
@ -107,8 +107,6 @@ public class Session extends DataContainer implements DateHolder {
|
||||
*/
|
||||
public void endSession(long endOfSession) {
|
||||
putRawData(SessionKeys.END, endOfSession);
|
||||
WorldTimes worldTimes = getValue(SessionKeys.WORLD_TIMES)
|
||||
.orElseThrow(() -> new IllegalStateException("World times have not been defined"));
|
||||
worldTimes.updateState(endOfSession);
|
||||
}
|
||||
|
||||
@ -120,14 +118,10 @@ public class Session extends DataContainer 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);
|
||||
}
|
||||
|
||||
|
@ -2,25 +2,20 @@ package com.djrapitops.plan.data.time;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Abstract class for keeping track of time spent in each state.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class TimeKeeper {
|
||||
/**
|
||||
* Keeps time of states.
|
||||
*/
|
||||
public abstract class TimeKeeper implements Serializable {
|
||||
|
||||
protected Map<String, Long> times;
|
||||
/**
|
||||
* Last State seen in
|
||||
*/
|
||||
protected String state;
|
||||
/**
|
||||
* Relates to Playtime Milliseconds.
|
||||
*/
|
||||
protected long lastStateChange;
|
||||
|
||||
public TimeKeeper(Map<String, Long> times, String lastState, long lastStateChange) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.data.time;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -10,7 +11,7 @@ import java.util.Objects;
|
||||
* @author Rsl1122
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public class WorldTimes {
|
||||
public class WorldTimes implements Serializable {
|
||||
|
||||
private final Map<String, GMTimes> worldTimes;
|
||||
private String currentWorld;
|
||||
|
Loading…
Reference in New Issue
Block a user