diff options
Diffstat (limited to 'src/main/java/de/torui/coflsky/configuration')
-rw-r--r-- | src/main/java/de/torui/coflsky/configuration/Configuration.java | 29 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/configuration/LocalConfig.java | 33 |
2 files changed, 51 insertions, 11 deletions
diff --git a/src/main/java/de/torui/coflsky/configuration/Configuration.java b/src/main/java/de/torui/coflsky/configuration/Configuration.java index bdd6186..1ef040f 100644 --- a/src/main/java/de/torui/coflsky/configuration/Configuration.java +++ b/src/main/java/de/torui/coflsky/configuration/Configuration.java @@ -1,5 +1,10 @@ package de.torui.coflsky.configuration; +import de.torui.coflsky.CoflSky; +import de.torui.coflsky.EventRegistry; + +import java.util.regex.Pattern; + public class Configuration { public Configuration() { @@ -15,19 +20,21 @@ public class Configuration { public static void setInstance(Configuration config) { instance = config; + CoflSky.config.autoStart = instance.autoStart; + EventRegistry.chatpattern = Pattern.compile(instance.chatRegex, Pattern.CASE_INSENSITIVE);; } - public String ChatRegex; - public boolean CollectChat; - public boolean CollectInventory; - public boolean CollectTab; - public boolean CollectScoreboard; - public boolean AllowProxy; - public boolean CollectInvClick; - public boolean CollectChatClicks; - public boolean CollectLobbyChanges; - public boolean CollectEntities; - + public String chatRegex; + public boolean collectChat; + public boolean collectInventory; + public boolean collectTab; + public boolean collectScoreboard; + public boolean allowProxy; + public boolean collectInvClick; + public boolean collectChatClicks; + public boolean collectLobbyChanges; + public boolean collectEntities; + public boolean autoStart; @Description("Wherever or not to send item descriptions for extending to the server") public boolean ExtendDescriptions; diff --git a/src/main/java/de/torui/coflsky/configuration/LocalConfig.java b/src/main/java/de/torui/coflsky/configuration/LocalConfig.java new file mode 100644 index 0000000..28909c4 --- /dev/null +++ b/src/main/java/de/torui/coflsky/configuration/LocalConfig.java @@ -0,0 +1,33 @@ +package de.torui.coflsky.configuration; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class LocalConfig { + public boolean autoStart; + public LocalConfig(boolean autoStart) { + this.autoStart = autoStart; + } + public static void saveConfig(File file, LocalConfig Config) { + Gson gson = new Gson(); + try { + if (!file.isFile()) { + file.createNewFile(); + } + Files.write(Paths.get(file.getAbsolutePath()), + gson.toJson(Config).getBytes(StandardCharsets.UTF_8)); + }catch (IOException e){ + e.printStackTrace(); + } + } + + public static LocalConfig createDefaultConfig() { + return new LocalConfig(false); + } +} |