From 031fdf2efd6c477d4d1b5bdb80db44989d9e99cd Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 13 Jun 2024 20:31:45 +0200 Subject: [PATCH] fix: ensure config-legacy.yml is created before accessed (#2752) * fix: ensure config-legacy.yml is created before accessed * Stop error attempting to load FAWE config if it doesn't exist --- .../java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 8 ++++---- .../com/fastasyncworldedit/core/configuration/Config.java | 3 +++ .../core/configuration/file/YamlConfiguration.java | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index b4556409c..faac1c955 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -137,6 +137,10 @@ public class WorldEditPlugin extends JavaPlugin { //noinspection ResultOfMethodCallIgnored getDataFolder().mkdirs(); + //FAWE start - Migrate from config-legacy to worldedit-config + migrateLegacyConfig(); + //FAWE end + //FAWE start - Modify WorldEdit config name config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this); // Load config before we say we've loaded platforms as it is used in listeners of the event @@ -151,10 +155,6 @@ public class WorldEditPlugin extends JavaPlugin { platform = new BukkitServerInterface(this, getServer()); worldEdit.getPlatformManager().register(platform); - //FAWE start - Migrate from config-legacy to worldedit-config - migrateLegacyConfig(); - //FAWE end - //FAWE start - Setup permission attachments permissionAttachmentManager = new BukkitPermissionAttachmentManager(this); //FAWE end diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java index e5185e6d8..d230ab05b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java @@ -100,6 +100,9 @@ public class Config { } public boolean load(File file) { + if (!file.exists()) { + return false; + } existingMigrateNodes = new ArrayList<>(); YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); for (String key : yml.getKeys(true)) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java index 1e2d5b0c4..f900451b5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java @@ -68,6 +68,7 @@ public class YamlConfiguration extends FileConfiguration { LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex); } catch (final IOException e) { e.printStackTrace(); + ex.printStackTrace(); } }