Change some WorldTimes methods

This commit is contained in:
Fuzzlemann 2017-08-21 18:33:54 +02:00
parent 9ccee9a9d6
commit b0a4d67782

View File

@ -61,9 +61,11 @@ public class WorldTimes {
} }
currentGMTimes.changeState(currentGamemode, changeTime); currentGMTimes.changeState(currentGamemode, changeTime);
} }
for (GMTimes gmTimes : worldTimes.values()) { for (GMTimes gmTimes : worldTimes.values()) {
gmTimes.setLastStateChange(changeTime); gmTimes.setLastStateChange(changeTime);
} }
currentWorld = worldName; currentWorld = worldName;
currentGamemode = gameMode; currentGamemode = gameMode;
} }
@ -76,10 +78,7 @@ public class WorldTimes {
*/ */
public long getWorldPlaytime(String world) { public long getWorldPlaytime(String world) {
GMTimes gmTimes = worldTimes.get(world); GMTimes gmTimes = worldTimes.get(world);
if (gmTimes != null) { return gmTimes != null ? gmTimes.getTotal() : 0;
return gmTimes.getTotal();
}
return 0;
} }
public long getTotal() { public long getTotal() {
@ -99,11 +98,7 @@ public class WorldTimes {
* @return GMTimes object with play times of each GameMode. * @return GMTimes object with play times of each GameMode.
*/ */
public GMTimes getGMTimes(String world) { public GMTimes getGMTimes(String world) {
GMTimes gmTimes = worldTimes.get(world); return worldTimes.getOrDefault(world, new GMTimes());
if (gmTimes != null) {
return gmTimes;
}
return new GMTimes();
} }
@Override @Override