mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Fix null and empty world name checking
This commit is contained in:
parent
b7d067123c
commit
30e8b93786
@ -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 Option.of(worldName).map(name -> {
|
||||
if (name.isEmpty()) {
|
||||
return NameStatus.EMPTY;
|
||||
}
|
||||
if (BLACKLIST_NAMES.contains(name)) {
|
||||
return NameStatus.BLACKLISTED;
|
||||
}
|
||||
if (worldName == null || !WORLD_NAME_PATTERN.matcher(worldName).matches()) {
|
||||
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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user