mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-25 09:41:23 +01:00
Implement getPotentialWorlds
This commit is contained in:
parent
80ff02a92b
commit
fda0e038f5
@ -141,7 +141,7 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
.toList();
|
||||
}
|
||||
case "potential" -> {
|
||||
return Collections.emptyList(); // TODO: Implement getPotentialWorlds
|
||||
return worldManager.getPotentialWorlds();
|
||||
}
|
||||
}
|
||||
Logging.severe("Invalid MVWorld scope: " + scope);
|
||||
|
@ -29,7 +29,9 @@ import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -343,6 +345,16 @@ public class WorldManager {
|
||||
return Result.success(DeleteWorldResult.Success.DELETED);
|
||||
}
|
||||
|
||||
public List<String> getPotentialWorlds() {
|
||||
File[] files = Bukkit.getWorldContainer().listFiles();
|
||||
if (files == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(files).filter(worldNameChecker::isValidWorldFolder)
|
||||
.map(File::getName)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Option<OfflineWorld> getOfflineOnlyWorld(@Nullable String worldName) {
|
||||
return isMVWorld(worldName) ? Option.none() : Option.of(offlineWorldsMap.get(worldName));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user