From d4f4e9f5d1fc397e518bd03695a9c83a2907370e Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 23 Jun 2012 21:31:57 -0500 Subject: [PATCH] Add check for existing config file. Addresses BUKKIT-1851 By: Wesley Wolfe --- paper-api/src/main/java/org/bukkit/plugin/Plugin.java | 1 + .../src/main/java/org/bukkit/plugin/java/JavaPlugin.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java index 05a2c696eb..6b75c3e7a6 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java @@ -58,6 +58,7 @@ public interface Plugin extends CommandExecutor { /** * Saves the raw contents of the default config.yml file to the location retrievable by {@link #getConfig()}. * If there is no default config.yml embedded in the plugin, an empty config.yml file is saved. + * This should fail silently if the config.yml already exists. */ public void saveDefaultConfig(); diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index b7ecc18111..cdc6e75175 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -133,7 +133,9 @@ public abstract class JavaPlugin extends PluginBase { } public void saveDefaultConfig() { - saveResource("config.yml", false); + if (!new File(getDataFolder(), "config.yml").exists()) { + saveResource("config.yml", false); + } } public void saveResource(String resourcePath, boolean replace) {