mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-11 19:02:16 +01:00
parent
8f639f7f41
commit
91bbb00968
@ -19,6 +19,7 @@ package com.djrapitops.plan.data.time;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Class that tracks the time spent in each World based on GMTimes.
|
||||
@ -171,8 +172,8 @@ public class WorldTimes {
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public String getCurrentWorld() {
|
||||
return currentWorld;
|
||||
public Optional<String> getCurrentWorld() {
|
||||
return Optional.ofNullable(currentWorld);
|
||||
}
|
||||
|
||||
public void add(WorldTimes toAdd) {
|
||||
|
@ -63,6 +63,9 @@ public class ConfigNode {
|
||||
}
|
||||
|
||||
public Optional<ConfigNode> getNode(String path) {
|
||||
if (path == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String[] parts = splitPathInTwo(path);
|
||||
String key = parts[0];
|
||||
String leftover = parts[1];
|
||||
@ -88,7 +91,7 @@ public class ConfigNode {
|
||||
|
||||
public ConfigNode addNode(String path) {
|
||||
ConfigNode newParent = this;
|
||||
if (!path.isEmpty()) {
|
||||
if (path != null && !path.isEmpty()) {
|
||||
String[] parts = splitPathInTwo(path);
|
||||
String key = parts[0];
|
||||
String leftover = parts[1];
|
||||
@ -105,7 +108,7 @@ public class ConfigNode {
|
||||
// Otherwise continue recursively.
|
||||
return leftover.isEmpty() ? child : child.addNode(leftover);
|
||||
}
|
||||
throw new IllegalArgumentException("Can not add a node with empty path");
|
||||
throw new IllegalArgumentException("Can not add a node with path '" + path + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,8 +157,9 @@ public class WorldAliasSettings {
|
||||
}
|
||||
WorldTimes worldTimes = session.getValue(SessionKeys.WORLD_TIMES).orElse(new WorldTimes());
|
||||
if (!session.supports(SessionKeys.END)) {
|
||||
String currentWorld = worldTimes.getCurrentWorld();
|
||||
return "Current: " + (aliases.contains(currentWorld) ? aliases.getString(currentWorld) : currentWorld);
|
||||
return worldTimes.getCurrentWorld()
|
||||
.map(currentWorld -> "Current: " + (aliases.contains(currentWorld) ? aliases.getString(currentWorld) : currentWorld))
|
||||
.orElse("Current: Unavailable");
|
||||
}
|
||||
|
||||
Map<String, Long> playtimePerAlias = getPlaytimePerAlias(worldTimes);
|
||||
|
Loading…
Reference in New Issue
Block a user