Removed unnecessary use of getValue inside Session

This commit is contained in:
Rsl1122 2018-08-05 22:02:52 +03:00
parent 0294dc4ec8
commit 1456d78bd4
5 changed files with 12 additions and 21 deletions

View File

@ -10,7 +10,7 @@ import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plan.utilities.SHA256Hash; import com.djrapitops.plan.utilities.SHA256Hash;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import java.io.UnsupportedEncodingException; import java.io.Serializable;
import java.net.InetAddress; import java.net.InetAddress;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -19,7 +19,7 @@ import java.security.NoSuchAlgorithmException;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class GeoInfo implements DateHolder { public class GeoInfo implements DateHolder, Serializable {
private final String ip; private final String ip;
private final String geolocation; private final String geolocation;
@ -27,7 +27,7 @@ public class GeoInfo implements DateHolder {
private final long date; private final long date;
public GeoInfo(InetAddress address, String geolocation, long lastUsed) public GeoInfo(InetAddress address, String geolocation, long lastUsed)
throws UnsupportedEncodingException, NoSuchAlgorithmException { throws NoSuchAlgorithmException {
this(FormatUtils.formatIP(address), geolocation, lastUsed, new SHA256Hash(address.getHostAddress()).create()); this(FormatUtils.formatIP(address), geolocation, lastUsed, new SHA256Hash(address.getHostAddress()).create());
} }

View File

@ -2,6 +2,7 @@ package com.djrapitops.plan.data.container;
import com.djrapitops.plan.data.store.objects.DateHolder; import com.djrapitops.plan.data.store.objects.DateHolder;
import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
@ -11,7 +12,7 @@ import java.util.UUID;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class PlayerKill implements DateHolder { public class PlayerKill implements DateHolder, Serializable {
private final UUID victim; private final UUID victim;
private final long date; private final long date;

View File

@ -107,8 +107,6 @@ public class Session extends DataContainer implements DateHolder {
*/ */
public void endSession(long endOfSession) { public void endSession(long endOfSession) {
putRawData(SessionKeys.END, endOfSession); putRawData(SessionKeys.END, endOfSession);
WorldTimes worldTimes = getValue(SessionKeys.WORLD_TIMES)
.orElseThrow(() -> new IllegalStateException("World times have not been defined"));
worldTimes.updateState(endOfSession); worldTimes.updateState(endOfSession);
} }
@ -120,14 +118,10 @@ public class Session extends DataContainer implements DateHolder {
* @param time Epoch ms of the event. * @param time Epoch ms of the event.
*/ */
public void changeState(String world, String gm, long time) { 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); worldTimes.updateState(world, gm, time);
} }
public void playerKilled(PlayerKill kill) { public void playerKilled(PlayerKill kill) {
List<PlayerKill> playerKills = getValue(SessionKeys.PLAYER_KILLS)
.orElseThrow(() -> new IllegalStateException("Player kills is not defined."));
playerKills.add(kill); playerKills.add(kill);
} }

View File

@ -2,25 +2,20 @@ package com.djrapitops.plan.data.time;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* Abstract class for keeping track of time spent in each state. * Abstract class for keeping track of time spent in each state.
*
* @author Rsl1122
*/ */
public abstract class TimeKeeper { public abstract class TimeKeeper implements Serializable {
/**
* Keeps time of states.
*/
protected Map<String, Long> times; protected Map<String, Long> times;
/**
* Last State seen in
*/
protected String state; protected String state;
/**
* Relates to Playtime Milliseconds.
*/
protected long lastStateChange; protected long lastStateChange;
public TimeKeeper(Map<String, Long> times, String lastState, long lastStateChange) { public TimeKeeper(Map<String, Long> times, String lastState, long lastStateChange) {

View File

@ -1,5 +1,6 @@
package com.djrapitops.plan.data.time; package com.djrapitops.plan.data.time;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -10,7 +11,7 @@ import java.util.Objects;
* @author Rsl1122 * @author Rsl1122
* @since 4.0.0 * @since 4.0.0
*/ */
public class WorldTimes { public class WorldTimes implements Serializable {
private final Map<String, GMTimes> worldTimes; private final Map<String, GMTimes> worldTimes;
private String currentWorld; private String currentWorld;