Skip to content

Commit 841195f

Browse files
committed
Update what it means for a dir to contain a Minecraft World (again)
1 parent 4e83e8b commit 841195f

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

lib/project_view/configs/views/map.dart

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,27 @@ class _MapConfigViewState extends ConsumerState<MapConfigView> {
143143
),
144144
onChanged: null,
145145
onEditingComplete: () => setState(validateAndSaveOptionsThatCannotBeBlank),
146-
warningValidator: (String? value) {
147-
if (value == null) return null;
148-
if (!Directory(value).existsSync()) {
149-
return "Directory does not exist";
146+
warningValidator: (String? worldPath) {
147+
if (worldPath == null) return null;
148+
149+
if (!Directory(worldPath).existsSync()) return "Directory does not exist";
150+
151+
if (File(p.join(worldPath, "level.dat")).existsSync()) return null;
152+
if (Directory(p.join(worldPath, "region")).existsSync()) return null;
153+
154+
final dimsDir = Directory(p.join(worldPath, "dimensions"));
155+
if (dimsDir.existsSync()) {
156+
for (final FileSystemEntity namespaceFSE in dimsDir.listSync()) {
157+
if (namespaceFSE is! Directory) continue;
158+
for (final FileSystemEntity dimensionFSE in namespaceFSE.listSync()) {
159+
if (Directory(p.join(dimensionFSE.path, "region")).existsSync()) {
160+
return null;
161+
}
162+
}
163+
}
150164
}
151-
if (!Directory(p.join(value, "region")).existsSync()) {
152-
return "Directory does not seem to contain a Minecraft World";
153-
}
154-
return null;
165+
166+
return "Directory does not seem to contain a Minecraft World";
155167
},
156168
),
157169
TextFieldOption.customDescription(

0 commit comments

Comments
 (0)