From 3384b6bc1756d14f0dbd592035006c45e284f4ec Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 6 Jan 2020 10:52:42 +0100 Subject: [PATCH] Only load mappings file from dir if manually copied --- .../api/data/MappingDataLoader.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java b/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java index 0963e137e..299cb166e 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java +++ b/common/src/main/java/us/myles/ViaVersion/api/data/MappingDataLoader.java @@ -5,33 +5,25 @@ import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.util.GsonUtil; import java.io.*; -import java.nio.file.Files; import java.util.Map; public class MappingDataLoader { public static JsonObject loadFromDataDir(String name) { File file = new File(Via.getPlatform().getDataFolder(), name); - if (!file.exists()) { - try (InputStream in = getResource(name)) { - Files.copy(in, file.toPath()); - } catch (IOException e) { - Via.getPlatform().getLogger().warning("Error loading " + name + " from the config directory!"); - e.printStackTrace(); - return null; - } - } + if (!file.exists()) return loadData(name); + // Load the file from the platform's directory if present try (FileReader reader = new FileReader(file)) { return GsonUtil.getGson().fromJson(reader, JsonObject.class); - } catch (IOException e) { - e.printStackTrace(); - return null; - } catch (JsonSyntaxException | JsonIOException e) { + } catch (JsonSyntaxException e) { + // Users might mess up the format, so let's catch the syntax error Via.getPlatform().getLogger().warning(name + " is badly formatted!"); e.printStackTrace(); - return null; + } catch (IOException | JsonIOException e) { + e.printStackTrace(); } + return null; } public static JsonObject loadData(String name) {