diff --git a/README.md b/README.md index 167339e..06642e6 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,9 @@ Standard-Config: # The prefix is written in front of every message that is sent to the chat by the plugin. prefix: '§2§lT+- §8» ' +# If disabled, the plugin will log every fetched data to the console +reduced_console_messages: true + # If this option is enabled, the plugin will copy a datapack with the name 'world-height-datapack.zip' to the world directory, which expands the world to the maximum possibly with a datapack 2032. height_datapack: false diff --git a/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java b/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java index 02c7c51..573905d 100644 --- a/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java +++ b/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java @@ -11,6 +11,7 @@ import de.btegermany.terraplusminus.utils.ConfigurationHelper; import de.btegermany.terraplusminus.utils.FileBuilder; import de.btegermany.terraplusminus.utils.PlayerHashMapManagement; +import net.buildtheearth.terraminusminus.TerraConfig; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.EventHandler; @@ -76,6 +77,12 @@ public void onEnable() { } // -------------------------- + if (Terraplusminus.config.getBoolean("reduced_console_messages")) { + TerraConfig.reducedConsoleMessages = true; // Disables console log of fetching data + } else { + TerraConfig.reducedConsoleMessages = false; + } + // Registering commands getCommand("tpll").setExecutor(new TpllCommand()); getCommand("where").setExecutor(new WhereCommand()); @@ -227,6 +234,14 @@ private void updateConfig() { " - current_world/server # do not change! e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l.\n" + " - another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032\n\n"); } + if (configVersion == 1.3) { + this.config.set("config_version", 1.4); + this.saveConfig(); + FileBuilder.addLineAfter("prefix:", + "\n# If disabled, the plugin will log every fetched data to the console\n" + + "reduced_console_messages: true"); + + } } } \ No newline at end of file diff --git a/src/main/java/de/btegermany/terraplusminus/utils/FileBuilder.java b/src/main/java/de/btegermany/terraplusminus/utils/FileBuilder.java index e4c1fbd..a649d0d 100644 --- a/src/main/java/de/btegermany/terraplusminus/utils/FileBuilder.java +++ b/src/main/java/de/btegermany/terraplusminus/utils/FileBuilder.java @@ -169,6 +169,32 @@ public static void addLineAbove(String path, String comment) { } } + public static void addLineAfter(String path, String line) { + try { + File inputFile = new File(plugin.getDataFolder() + File.separator + "config.yml"); + File tempFile = new File(plugin.getDataFolder() + File.separator + "temp.yml"); + + BufferedReader reader = new BufferedReader(new FileReader(inputFile)); + BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); + + String currentLine; + + while ((currentLine = reader.readLine()) != null) { + writer.write(currentLine + "\n"); + if (currentLine.contains(path)) { + writer.write(line + "\n"); + } + } + + writer.close(); + reader.close(); + inputFile.delete(); + tempFile.renameTo(inputFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + public static void editPathValue(String path, String value) { try { File inputFile = new File(plugin.getDataFolder() + File.separator + "config.yml"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 68879c1..47b5aa5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,6 +1,9 @@ # The prefix is written in front of every message that is sent to the chat by the plugin. prefix: '§2§lT+- §8» ' +# If disabled, the plugin will log every fetched data to the console +reduced_console_messages: true + # If this option is enabled, the plugin will copy a datapack with the name 'world-height-datapack.zip' to the world directory, which expands the world to the maximum possibly with a datapack 2032. height_datapack: false @@ -57,4 +60,4 @@ path_material: MOSS_BLOCK # ----------------------------------------------------- # NOTE: Do not change -config_version: 1.3 +config_version: 1.4