mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-15 23:25:32 +01:00
Fix some issues with the previous commit
This commit is contained in:
parent
d7dd8931a5
commit
d77d90c658
@ -53,6 +53,11 @@ public class BlueMapConfigManager implements BlueMapConfiguration {
|
|||||||
public static final String MAPS_CONFIG_FOLDER_NAME = "maps";
|
public static final String MAPS_CONFIG_FOLDER_NAME = "maps";
|
||||||
public static final String STORAGES_CONFIG_FOLDER_NAME = "storages";
|
public static final String STORAGES_CONFIG_FOLDER_NAME = "storages";
|
||||||
|
|
||||||
|
public static final String MAP_STORAGE_CONFIG_NAME = MAPS_CONFIG_FOLDER_NAME + "/map";
|
||||||
|
|
||||||
|
public static final String FILE_STORAGE_CONFIG_NAME = STORAGES_CONFIG_FOLDER_NAME + "/file";
|
||||||
|
public static final String SQL_STORAGE_CONFIG_NAME = STORAGES_CONFIG_FOLDER_NAME + "/sql";
|
||||||
|
|
||||||
private final ConfigManager configManager;
|
private final ConfigManager configManager;
|
||||||
|
|
||||||
private final CoreConfig coreConfig;
|
private final CoreConfig coreConfig;
|
||||||
@ -220,19 +225,19 @@ private Map<String, MapConfig> loadMapConfigs(Collection<ServerWorld> autoConfig
|
|||||||
if (autoConfigWorlds.isEmpty()) {
|
if (autoConfigWorlds.isEmpty()) {
|
||||||
Path worldFolder = Path.of("world");
|
Path worldFolder = Path.of("world");
|
||||||
Files.writeString(
|
Files.writeString(
|
||||||
mapConfigFolder.resolve("overworld.conf"),
|
configManager.resolveConfigFile(MAPS_CONFIG_FOLDER_NAME + "/overworld"),
|
||||||
createOverworldMapTemplate("Overworld", worldFolder,
|
createOverworldMapTemplate("Overworld", worldFolder,
|
||||||
DataPack.DIMENSION_OVERWORLD, 0).build(),
|
DataPack.DIMENSION_OVERWORLD, 0).build(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
||||||
);
|
);
|
||||||
Files.writeString(
|
Files.writeString(
|
||||||
mapConfigFolder.resolve("nether.conf"),
|
configManager.resolveConfigFile(MAPS_CONFIG_FOLDER_NAME + "/nether"),
|
||||||
createNetherMapTemplate("Nether", worldFolder,
|
createNetherMapTemplate("Nether", worldFolder,
|
||||||
DataPack.DIMENSION_THE_NETHER, 0).build(),
|
DataPack.DIMENSION_THE_NETHER, 0).build(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
||||||
);
|
);
|
||||||
Files.writeString(
|
Files.writeString(
|
||||||
mapConfigFolder.resolve("end.conf"),
|
configManager.resolveConfigFile(MAPS_CONFIG_FOLDER_NAME + "/end"),
|
||||||
createEndMapTemplate("End", worldFolder,
|
createEndMapTemplate("End", worldFolder,
|
||||||
DataPack.DIMENSION_THE_END, 0).build(),
|
DataPack.DIMENSION_THE_END, 0).build(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
||||||
@ -264,7 +269,7 @@ private Map<String, MapConfig> loadMapConfigs(Collection<ServerWorld> autoConfig
|
|||||||
uniqueId = id + "_" + (++i);
|
uniqueId = id + "_" + (++i);
|
||||||
mapIds.add(uniqueId);
|
mapIds.add(uniqueId);
|
||||||
|
|
||||||
Path configFile = mapConfigFolder.resolve(uniqueId + ".conf");
|
Path configFile = configManager.resolveConfigFile(MAPS_CONFIG_FOLDER_NAME + "/" + uniqueId);
|
||||||
String name = worldFolder.getFileName() + " (" + dimensionName + ")";
|
String name = worldFolder.getFileName() + " (" + dimensionName + ")";
|
||||||
if (i > 1) name = name + " (" + i + ")";
|
if (i > 1) name = name + " (" + i + ")";
|
||||||
|
|
||||||
@ -322,15 +327,15 @@ private Map<String, StorageConfig> loadStorageConfigs(Path defaultWebroot) throw
|
|||||||
try {
|
try {
|
||||||
FileHelper.createDirectories(storageConfigFolder);
|
FileHelper.createDirectories(storageConfigFolder);
|
||||||
Files.writeString(
|
Files.writeString(
|
||||||
storageConfigFolder.resolve("file.conf"),
|
configManager.resolveConfigFile(FILE_STORAGE_CONFIG_NAME),
|
||||||
configManager.loadConfigTemplate("/de/bluecolored/bluemap/config/storages/file.conf")
|
configManager.loadConfigTemplate(FILE_STORAGE_CONFIG_NAME)
|
||||||
.setVariable("root", formatPath(defaultWebroot.resolve("maps")))
|
.setVariable("root", formatPath(defaultWebroot.resolve("maps")))
|
||||||
.build(),
|
.build(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
||||||
);
|
);
|
||||||
Files.writeString(
|
Files.writeString(
|
||||||
storageConfigFolder.resolve("sql.conf"),
|
configManager.resolveConfigFile(SQL_STORAGE_CONFIG_NAME),
|
||||||
configManager.loadConfigTemplate("/de/bluecolored/bluemap/config/storages/sql.conf").build(),
|
configManager.loadConfigTemplate(SQL_STORAGE_CONFIG_NAME).build(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING
|
||||||
);
|
);
|
||||||
} catch (IOException | NullPointerException ex) {
|
} catch (IOException | NullPointerException ex) {
|
||||||
@ -367,7 +372,7 @@ private String sanitiseMapId(String id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConfigTemplate createOverworldMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
private ConfigTemplate createOverworldMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
||||||
return configManager.loadConfigTemplate("/de/bluecolored/bluemap/config/maps/map.conf")
|
return configManager.loadConfigTemplate(MAP_STORAGE_CONFIG_NAME)
|
||||||
.setVariable("name", name)
|
.setVariable("name", name)
|
||||||
.setVariable("sorting", "" + index)
|
.setVariable("sorting", "" + index)
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
@ -381,7 +386,7 @@ private ConfigTemplate createOverworldMapTemplate(String name, Path worldFolder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConfigTemplate createNetherMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
private ConfigTemplate createNetherMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
||||||
return configManager.loadConfigTemplate("/de/bluecolored/bluemap/config/maps/map.conf")
|
return configManager.loadConfigTemplate(MAP_STORAGE_CONFIG_NAME)
|
||||||
.setVariable("name", name)
|
.setVariable("name", name)
|
||||||
.setVariable("sorting", "" + (100 + index))
|
.setVariable("sorting", "" + (100 + index))
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
@ -395,7 +400,7 @@ private ConfigTemplate createNetherMapTemplate(String name, Path worldFolder, Ke
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConfigTemplate createEndMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
private ConfigTemplate createEndMapTemplate(String name, Path worldFolder, Key dimension, int index) throws IOException {
|
||||||
return configManager.loadConfigTemplate("/de/bluecolored/bluemap/config/maps/map.conf")
|
return configManager.loadConfigTemplate(MAP_STORAGE_CONFIG_NAME)
|
||||||
.setVariable("name", name)
|
.setVariable("name", name)
|
||||||
.setVariable("sorting", "" + (200 + index))
|
.setVariable("sorting", "" + (200 + index))
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
|
@ -92,7 +92,7 @@ private HttpResponse generateResponse(HttpRequest request) throws IOException {
|
|||||||
|
|
||||||
// default to index.html
|
// default to index.html
|
||||||
if (!Files.exists(filePath) || Files.isDirectory(filePath)){
|
if (!Files.exists(filePath) || Files.isDirectory(filePath)){
|
||||||
filePath = filePath.resolve("/index.html");
|
filePath = filePath.resolve("index.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Files.exists(filePath) || Files.isDirectory(filePath)){
|
if (!Files.exists(filePath) || Files.isDirectory(filePath)){
|
||||||
|
Loading…
Reference in New Issue
Block a user