Skip to content

Commit

Permalink
turned off console log of fetching data by default and added config e…
Browse files Browse the repository at this point in the history
…ntry
  • Loading branch information
Le4nderS committed Nov 20, 2023
1 parent 343442d commit 4d19270
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/de/btegermany/terraplusminus/Terraplusminus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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");

}
}

}
26 changes: 26 additions & 0 deletions src/main/java/de/btegermany/terraplusminus/utils/FileBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -57,4 +60,4 @@ path_material: MOSS_BLOCK
# -----------------------------------------------------

# NOTE: Do not change
config_version: 1.3
config_version: 1.4

0 comments on commit 4d19270

Please sign in to comment.