From 7b1d154ea247c92681491099d112b3d22cab4221 Mon Sep 17 00:00:00 2001 From: CreepyCre Date: Tue, 9 Feb 2021 12:56:51 +0100 Subject: [PATCH] fix SchematicV2Handler, see https://bugs.openjdk.java.net/browse/JDK-8153248 --- .../org/dimdev/dimdoors/pockets/SchematicV2Handler.java | 4 +++- .../dimdoors/pockets/modifier/DimensionalDoorModifier.java | 7 ------- .../org/dimdev/dimdoors/pockets/modifier/RiftManager.java | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/pockets/SchematicV2Handler.java b/src/main/java/org/dimdev/dimdoors/pockets/SchematicV2Handler.java index 93558327..bba38a58 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/SchematicV2Handler.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/SchematicV2Handler.java @@ -86,12 +86,14 @@ public class SchematicV2Handler { return reader.apply(tag); } + // TODO: fix, some weird "/" stuff private void loadJson(Path path, String[] idParts, BiConsumer loader) { if (Files.isDirectory(path)) { try { for (Path directoryPath : Files.newDirectoryStream(path)) { String[] directoryIdParts = Arrays.copyOf(idParts, idParts.length + 1); String fileName = directoryPath.getFileName().toString(); + if (fileName.endsWith("/")) fileName = fileName.substring(0, fileName.length()-1); // https://bugs.openjdk.java.net/browse/JDK-8153248 if (Files.isRegularFile(directoryPath)) fileName = fileName.substring(0, fileName.lastIndexOf('.')); // cut extension directoryIdParts[directoryIdParts.length - 1] = fileName; loadJson(directoryPath, directoryIdParts, loader); @@ -100,7 +102,7 @@ public class SchematicV2Handler { LOGGER.error("could not load pocket data in path " + path.toString() + " due to malformed json.", e); } } else if(Files.isRegularFile(path) && path.getFileName().toString().endsWith(".json")) { - String id = String.join("", idParts); + String id = String.join("/", idParts); try { JsonElement json = GSON.fromJson(String.join("", Files.readAllLines(path)), JsonElement.class); loader.accept(id, JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json)); diff --git a/src/main/java/org/dimdev/dimdoors/pockets/modifier/DimensionalDoorModifier.java b/src/main/java/org/dimdev/dimdoors/pockets/modifier/DimensionalDoorModifier.java index 6bf1b80d..ef6b375d 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/modifier/DimensionalDoorModifier.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/modifier/DimensionalDoorModifier.java @@ -1,9 +1,7 @@ package org.dimdev.dimdoors.pockets.modifier; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.block.Block; @@ -22,18 +20,13 @@ import org.dimdev.dimdoors.block.DimensionalDoorBlock; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes; -import org.dimdev.dimdoors.block.entity.RiftBlockEntity; import org.dimdev.dimdoors.block.entity.RiftData; import org.dimdev.dimdoors.pockets.SchematicV2Handler; -import org.dimdev.dimdoors.rift.registry.LinkProperties; import org.dimdev.dimdoors.rift.targets.IdMarker; -import org.dimdev.dimdoors.rift.targets.PocketEntranceMarker; -import org.dimdev.dimdoors.rift.targets.PocketExitMarker; import org.dimdev.dimdoors.util.PocketGenerationParameters; import org.dimdev.dimdoors.util.TagEquations; import org.dimdev.dimdoors.util.math.Equation; import org.dimdev.dimdoors.util.math.Equation.EquationParseException; -import org.dimdev.dimdoors.world.pocket.Pocket; public class DimensionalDoorModifier implements Modifier { private static final Logger LOGGER = LogManager.getLogger(); diff --git a/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftManager.java b/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftManager.java index 4ca24960..c336256c 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftManager.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftManager.java @@ -59,7 +59,7 @@ public class RiftManager { return maxId + 1; } - public boolean available(int id) { + public boolean available(int id) { // TODO: remove? method is likely redundant return !map.containsKey(id); } }