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