|
6 | 6 | import java.util.Collections;
|
7 | 7 | import java.util.EnumSet;
|
8 | 8 | import java.util.HashSet;
|
| 9 | +import java.util.LinkedList; |
| 10 | +import java.util.List; |
9 | 11 | import java.util.Locale;
|
10 | 12 | import java.util.Set;
|
11 | 13 |
|
@@ -40,6 +42,8 @@ public class Config {
|
40 | 42 | private static LocalizedConfiguration itemBlacklistConfig;
|
41 | 43 | @Nullable
|
42 | 44 | private static LocalizedConfiguration searchColorsConfig;
|
| 45 | + @Nullable |
| 46 | + private static LocalizedConfiguration bookmarksConfig; |
43 | 47 |
|
44 | 48 | // advanced
|
45 | 49 | private static boolean debugModeEnabled = false;
|
@@ -73,7 +77,11 @@ public class Config {
|
73 | 77 |
|
74 | 78 | // item blacklist
|
75 | 79 | private static final Set<String> itemBlacklist = new HashSet<String>();
|
76 |
| - private static final String[] defaultItemBlacklist = new String[]{}; |
| 80 | + private static final String[] defaultItemBlacklist = new String[] {}; |
| 81 | + |
| 82 | + // bookmarks |
| 83 | + private static final String[] defaultBookmarks = new String[] {}; |
| 84 | + private static String[] bookmarks; |
77 | 85 |
|
78 | 86 | private Config() {
|
79 | 87 |
|
@@ -226,6 +234,8 @@ public static void preInit(FMLPreInitializationEvent event) {
|
226 | 234 | final File itemBlacklistConfigFile = new File(jeiConfigurationDir, "itemBlacklist.cfg");
|
227 | 235 | final File searchColorsConfigFile = new File(jeiConfigurationDir, "searchColors.cfg");
|
228 | 236 | final File worldConfigFile = new File(jeiConfigurationDir, "worldSettings.cfg");
|
| 237 | + final File bookmarksConfigFile = new File(jeiConfigurationDir, "bookmarks.cfg"); |
| 238 | + |
229 | 239 | worldConfig = new Configuration(worldConfigFile, "0.1.0");
|
230 | 240 |
|
231 | 241 | {
|
@@ -257,10 +267,12 @@ public static void preInit(FMLPreInitializationEvent event) {
|
257 | 267 | config = new LocalizedConfiguration(configKeyPrefix, configFile, "0.2.0");
|
258 | 268 | itemBlacklistConfig = new LocalizedConfiguration(configKeyPrefix, itemBlacklistConfigFile, "0.1.0");
|
259 | 269 | searchColorsConfig = new LocalizedConfiguration(configKeyPrefix, searchColorsConfigFile, "0.1.0");
|
| 270 | + bookmarksConfig = new LocalizedConfiguration(configKeyPrefix, bookmarksConfigFile, "0.1.0"); |
260 | 271 |
|
261 | 272 | syncConfig();
|
262 | 273 | syncItemBlacklistConfig();
|
263 | 274 | syncSearchColorsConfig();
|
| 275 | + syncBookmarksConfig(); |
264 | 276 | }
|
265 | 277 |
|
266 | 278 | public static boolean syncAllConfig() {
|
@@ -315,7 +327,7 @@ private static boolean syncConfig() {
|
315 | 327 | searchCategory.remove("prefixRequiredForCreativeTabSearch");
|
316 | 328 | searchCategory.remove("prefixRequiredForColorSearch");
|
317 | 329 |
|
318 |
| - SearchMode[] searchModes = SearchMode.values(); |
| 330 | + SearchMode[] searchModes = SearchMode.values(); |
319 | 331 | modNameSearchMode = config.getEnum("modNameSearchMode", CATEGORY_SEARCH, defaultModNameSearchMode, searchModes);
|
320 | 332 | tooltipSearchMode = config.getEnum("tooltipSearchMode", CATEGORY_SEARCH, defaultTooltipSearchMode, searchModes);
|
321 | 333 | oreDictSearchMode = config.getEnum("oreDictSearchMode", CATEGORY_SEARCH, defaultOreDictSearchMode, searchModes);
|
@@ -402,6 +414,42 @@ private static boolean syncItemBlacklistConfig() {
|
402 | 414 | return configChanged;
|
403 | 415 | }
|
404 | 416 |
|
| 417 | + private static boolean syncBookmarksConfig() { |
| 418 | + if (bookmarksConfig == null) { |
| 419 | + return false; |
| 420 | + } |
| 421 | + |
| 422 | + bookmarksConfig.addCategory(CATEGORY_ADVANCED); |
| 423 | + |
| 424 | + bookmarks = bookmarksConfig.getStringList("bookmarks", CATEGORY_ADVANCED, defaultBookmarks); |
| 425 | + |
| 426 | + final boolean configChanged = bookmarksConfig.hasChanged(); |
| 427 | + if (configChanged) { |
| 428 | + bookmarksConfig.save(); |
| 429 | + } |
| 430 | + return configChanged; |
| 431 | + } |
| 432 | + |
| 433 | + public static boolean updateBookmarks(String[] bookmarkIds) { |
| 434 | + bookmarks = bookmarkIds; |
| 435 | + if (bookmarksConfig == null) { |
| 436 | + return false; |
| 437 | + } |
| 438 | + Property property = bookmarksConfig.get(CATEGORY_ADVANCED, "bookmarks", defaultBookmarks); |
| 439 | + |
| 440 | + property.set(bookmarks); |
| 441 | + |
| 442 | + boolean changed = bookmarksConfig.hasChanged(); |
| 443 | + if (changed) { |
| 444 | + bookmarksConfig.save(); |
| 445 | + } |
| 446 | + return changed; |
| 447 | + } |
| 448 | + |
| 449 | + public static String[] getBookmarks() { |
| 450 | + return bookmarks; |
| 451 | + } |
| 452 | + |
405 | 453 | public static boolean syncWorldConfig() {
|
406 | 454 | if (worldConfig == null) {
|
407 | 455 | return false;
|
|
0 commit comments