remove some extra stuff into the computeIfAbsent

This commit is contained in:
IThundxr 2024-10-15 17:01:54 -04:00
parent 5d2c8f281c
commit 666b491df2
Failed to generate hash of commit

View file

@ -82,15 +82,18 @@ public class ServerSchematicLoader {
(filePath, attributes) -> filePath.toString().endsWith(".nbt"))) {
for (Path path : filePaths.toList()) {
try (InputStream stream = new FileInputStream(path.toFile())) {
String[] pathSplit = path.toString()
.replace("schematics/uploaded/", "")
.replace(".nbt", "")
.split("/");
String playerName = pathSplit[0];
String schematicName = pathSplit[1];
String schematicMd5Hex = DigestUtils.md5Hex(stream);
sumToSchematic.computeIfAbsent(schematicMd5Hex, k -> new SchematicFile(playerName, schematicName));
sumToSchematic.computeIfAbsent(schematicMd5Hex, k -> {
String[] pathSplit = path.toString()
.replace("schematics/uploaded/", "")
.replace(".nbt", "")
.split("/");
String playerName = pathSplit[0];
String schematicName = pathSplit[1];
return new SchematicFile(playerName, schematicName);
});
}
}
} catch (IOException ignored) {}