diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java index e8801baf..184ee035 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.Set; import java.util.regex.Pattern; +import io.vavr.control.Option; import org.bukkit.Bukkit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,13 +46,18 @@ public class WorldNameChecker { */ @NotNull public NameStatus checkName(@Nullable String worldName) { - if (BLACKLIST_NAMES.contains(worldName)) { - return NameStatus.BLACKLISTED; - } - if (worldName == null || !WORLD_NAME_PATTERN.matcher(worldName).matches()) { - return NameStatus.INVALID_CHARS; - } - return NameStatus.VALID; + return Option.of(worldName).map(name -> { + if (name.isEmpty()) { + return NameStatus.EMPTY; + } + if (BLACKLIST_NAMES.contains(name)) { + return NameStatus.BLACKLISTED; + } + if (!WORLD_NAME_PATTERN.matcher(name).matches()) { + return NameStatus.INVALID_CHARS; + } + return NameStatus.VALID; + }).getOrElse(NameStatus.EMPTY); } /** @@ -142,6 +148,11 @@ public class WorldNameChecker { */ INVALID_CHARS, + /** + * Name string that is null or length 0. + */ + EMPTY, + /** * Name not valid as it is deemed blacklisted. */