From ee9519d8911464b35203104e96ab74444c3b0907 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 7 Jan 2019 08:53:39 -0800 Subject: [PATCH] tweaks --- .../java/baritone/api/utils/SettingsUtil.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index b6623b98..07b4cd98 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -18,23 +18,23 @@ package baritone.api.utils; import baritone.api.Settings; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import java.awt.*; import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.function.Consumer; import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -42,12 +42,11 @@ import static net.minecraft.client.Minecraft.getMinecraft; public class SettingsUtil { - private static final Path settingsFile = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt"); - private static final Pattern SETTING_PATTERN = Pattern.compile("^(?[^ ]+) +(?[^ ]+)");// 2 words separated by spaces + private static final Path SETTINGS_PATH = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt"); + private static final Pattern SETTING_PATTERN = Pattern.compile("^(?[^ ]+) +(?[^ ]+)"); // 2 words separated by spaces private static final Map, SettingsIO> map; - private static boolean isComment(String line) { return line.startsWith("#") || line.startsWith("//"); } @@ -56,8 +55,9 @@ public class SettingsUtil { try (BufferedReader scan = Files.newBufferedReader(file)) { String line; while ((line = scan.readLine()) != null) { - if (line.isEmpty() || isComment(line)) continue; - + if (line.isEmpty() || isComment(line)) { + continue; + } consumer.accept(line); } } @@ -65,7 +65,7 @@ public class SettingsUtil { public static void readAndApply(Settings settings) { try { - forEachLine(settingsFile, line -> { + forEachLine(SETTINGS_PATH, line -> { Matcher matcher = SETTING_PATTERN.matcher(line); if (!matcher.matches()) { System.out.println("Invalid syntax in setting file: " + line); @@ -88,7 +88,7 @@ public class SettingsUtil { } public static synchronized void save(Settings settings) { - try (BufferedWriter out = Files.newBufferedWriter(settingsFile)) { + try (BufferedWriter out = Files.newBufferedWriter(SETTINGS_PATH)) { for (Settings.Setting setting : settings.allSettings) { if (setting.get() == null) { System.out.println("NULL SETTING?" + setting.getName());