diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java b/Plan/common/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java index e5bbc3741..147772014 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/time/WorldTimes.java @@ -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 getCurrentWorld() { + return Optional.ofNullable(currentWorld); } public void add(WorldTimes toAdd) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java index a10cdc6a3..70ca37829 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java @@ -63,6 +63,9 @@ public class ConfigNode { } public Optional 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 + "'"); } /** diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/WorldAliasSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/WorldAliasSettings.java index 794b42b59..8c9678c3e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/WorldAliasSettings.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/WorldAliasSettings.java @@ -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 playtimePerAlias = getPlaytimePerAlias(worldTimes);