|
14 | 14 | import net.fabricmc.api.ClientModInitializer; |
15 | 15 | import net.fabricmc.api.EnvType; |
16 | 16 | import net.fabricmc.api.Environment; |
| 17 | +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; |
17 | 18 | import net.fabricmc.loader.api.FabricLoader; |
18 | 19 | import dev.sygii.tabapi.util.SortList; |
19 | 20 | import net.minecraft.client.MinecraftClient; |
@@ -49,26 +50,33 @@ public void onInitializeClient() { |
49 | 50 | if (isL2hostilityloaded) { |
50 | 51 | TabAPI.registerInventoryTab(new L2Tab(LHTexts.INFO_TAB_TITLE.get(), Items.ZOMBIE_HEAD.getDefaultStack(), 2, DifficultyScreen.class)); |
51 | 52 | }*/ |
52 | | - File file = new File("config/tabapi_tabs.json"); |
53 | | - if (file.exists()) { |
54 | | - config.tabs = readConfig(); |
55 | | - } |
56 | | - saveConfig(config); |
| 53 | + |
| 54 | + //ClientLifecycleEvents.CLIENT_STARTED.register((client) -> { |
| 55 | + File file = new File("config/tabapi_tabs.json"); |
| 56 | + if (file.exists()) { |
| 57 | + config.tabs = readConfig(); |
| 58 | + } |
| 59 | + //}); |
| 60 | + //ClientLifecycleEvents.CLIENT_STOPPING.register((client) -> { |
| 61 | + saveConfig(config); |
| 62 | + ///}); |
57 | 63 | //TabAPI.registerInventoryTab(new TestTab(Text.translatable("container.crafting"), 0, InventoryScreen.class)); |
58 | 64 | } |
59 | 65 |
|
60 | 66 | public static Map<String, Boolean> readConfig() { |
61 | | - GsonBuilder builder = new GsonBuilder(); |
62 | | - Gson gson = builder.create(); |
63 | | - |
64 | | - Type typeObject = new TypeToken<HashMap>() {}.getType(); |
65 | | - BufferedReader bufferedReader = null; |
66 | 67 | try { |
67 | | - bufferedReader = new BufferedReader( |
| 68 | + GsonBuilder builder = new GsonBuilder(); |
| 69 | + Gson gson = builder.create(); |
| 70 | + |
| 71 | + Type typeObject = new TypeToken<HashMap>() { |
| 72 | + }.getType(); |
| 73 | + BufferedReader bufferedReader = new BufferedReader( |
68 | 74 | new FileReader("config/tabapi_tabs.json")); |
69 | 75 | return gson.fromJson(bufferedReader, typeObject); |
70 | | - } catch (FileNotFoundException e) { |
71 | | - throw new RuntimeException(e); |
| 76 | + }catch (FileNotFoundException e) { |
| 77 | + //sus |
| 78 | + saveConfig(config); |
| 79 | + return readConfig(); |
72 | 80 | } |
73 | 81 | } |
74 | 82 |
|
|
0 commit comments