From f75681144085e729b4e9972908c1fc859670bb4b Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Thu, 19 Aug 2021 21:58:40 -0600 Subject: added h and f mods for timecheck.formattime --- .../brysonsteck/Resurrection/ParseSettings.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/net/brysonsteck/Resurrection/ParseSettings.java') diff --git a/src/net/brysonsteck/Resurrection/ParseSettings.java b/src/net/brysonsteck/Resurrection/ParseSettings.java index bd476e7..8682bd2 100644 --- a/src/net/brysonsteck/Resurrection/ParseSettings.java +++ b/src/net/brysonsteck/Resurrection/ParseSettings.java @@ -3,15 +3,12 @@ package net.brysonsteck.Resurrection; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; +import java.io.*; import java.util.Hashtable; import java.util.Locale; public class ParseSettings { Hashtable settings = new Hashtable<>(); - // String failedSetting; boolean settingsComplete; @@ -20,8 +17,19 @@ public class ParseSettings { public ParseSettings() { try { + File settingsFile = new File("data/settings.resurrection"); + if (!settingsFile.exists()) { + // create default settings file + FileWriter writer = new FileWriter(settingsFile); + writer.write("# This is the default settings file. All lines starting with a '#' are treated as comments and will be ignored.\n" + + "# 'resurrection_time' is the amount of time in milliseconds Resurrection will force the player to wait. Default value is 8640000 milliseconds (24 hours).\n" + + "resurrection_time=86400000\n" + + "# 'debug' enables debug messages in the console and players' chat as the plugin runs. The only valid values are 'true' and 'false'. Default value is false.\n" + + "debug=false"); + writer.close(); + } String rawData = ""; - BufferedReader reader = new BufferedReader(new FileReader("plugins/settings.resurrection")); + BufferedReader reader = new BufferedReader(new FileReader("data/settings.resurrection")); String line; String[] setting; while (true) { @@ -39,12 +47,12 @@ public class ParseSettings { if (!settingsComplete) { System.out.println("[Resurrection] The setting \"" + failedSetting + "\" is not present in the settings file.\n" + "[Resurrection] Please double check the settings file to make sure the setting exists and a valid corresponding value is set.\n" + - "[Resurrection] Example: \"resurrection_time=8640000\"\n" + + "[Resurrection] Example: \"resurrection_time=86400000\"\n" + "[Resurrection] Example: \"debug=false\""); } else if (!valuesComplete) { System.out.println("[Resurrection] The setting \"" + failedSetting + "\" contains an invalid or empty value.\n" + "[Resurrection] Please double check the settings file to make sure that a valid value is set for this setting.\n" + - "[Resurrection] Example: \"resurrection_time=8640000\"\n" + + "[Resurrection] Example: \"resurrection_time=86400000\"\n" + "[Resurrection] Example: \"debug=false\""); } System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file is not complete, the plugin will now stop."); -- cgit v1.2.3