aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
blob: 5fc06cdd5e47d5343b0e407ee5b2b3f4dc292be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
 * Roughly Enough Items by Danielshe.
 * Licensed under the MIT License.
 */

package me.shedaniel.rei.impl;

import me.shedaniel.rei.api.ConfigObject;
import me.shedaniel.rei.gui.config.*;
import me.zeroeightsix.fiber.exception.FiberException;
import me.zeroeightsix.fiber.tree.ConfigNode;
import me.zeroeightsix.fiber.tree.ConfigValue;
import me.zeroeightsix.fiber.tree.Node;

public class ConfigObjectImpl implements ConfigObject {
    
    public ConfigNode configNode = new ConfigNode();
    
    private Node general = configNode.fork("!general");
    private Node appearance = configNode.fork("appearance");
    private Node modules = configNode.fork("modules");
    private Node technical = configNode.fork("technical");
    
    private ConfigValue<Boolean> cheating = ConfigValue.builder(Boolean.class)
            .withParent(general)
            .withDefaultValue(false)
            .withComment("Declares whether cheating mode is on.")
            .withName("cheating")
            .build();
    
    private ConfigValue<ItemListOrderingConfig> itemListOrdering = ConfigValue.builder(ItemListOrderingConfig.class)
            .withParent(appearance)
            .withDefaultValue(ItemListOrderingConfig.REGISTRY_ASCENDING)
            .withComment("The ordering of the items on the item panel.")
            .withName("itemListOrdering")
            .build();
    
    private ConfigValue<Boolean> darkTheme = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares the appearance of REI windows.")
            .withName("darkTheme")
            .build();
    
    private ConfigValue<RecipeScreenType> recipeScreenType = ConfigValue.builder(RecipeScreenType.class)
            .withParent(appearance)
            .withDefaultValue(RecipeScreenType.UNSET)
            .withComment("The ordering of the items on the item panel.")
            .withName("recipeScreenType")
            .build();
    
    private ConfigValue<Boolean> loadDefaultPlugin = ConfigValue.builder(Boolean.class)
            .withParent(technical)
            .withDefaultValue(true)
            .withComment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing")
            .withName("loadDefaultPlugin")
            .build();
    
    private ConfigValue<SearchFieldLocation> sideSearchField = ConfigValue.builder(SearchFieldLocation.class)
            .withParent(appearance)
            .withDefaultValue(SearchFieldLocation.CENTER)
            .withComment("Declares the position of the search field.")
            .withName("searchFieldLocation")
            .build();
    
    private ConfigValue<Boolean> mirrorItemPanel = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares the position of the item list panel.")
            .withName("mirrorItemPanel")
            .build();
    
    private ConfigValue<Boolean> enableCraftableOnlyButton = ConfigValue.builder(Boolean.class)
            .withParent(modules)
            .withDefaultValue(true)
            .withComment("Declares whether the craftable filter button is enabled.")
            .withName("enableCraftableOnlyButton")
            .build();
    
    private ConfigValue<String> gamemodeCommand = ConfigValue.builder(String.class)
            .withParent(technical)
            .withDefaultValue("/gamemode {gamemode}")
            .withComment("Declares the command used to change gamemode.")
            .withName("gamemodeCommand")
            .build();
    
    private ConfigValue<String> giveCommand = ConfigValue.builder(String.class)
            .withParent(technical)
            .withDefaultValue("/give {player_name} {item_identifier}{nbt} {count}")
            .withComment("Declares the command used in servers to cheat items.")
            .withName("giveCommand")
            .build();
    
    private ConfigValue<String> weatherCommand = ConfigValue.builder(String.class)
            .withParent(technical)
            .withDefaultValue("/weather {weather}")
            .withComment("Declares the command used to change weather.")
            .withName("weatherCommand")
            .build();
    
    private ConfigValue<Integer> maxRecipePerPage = ConfigValue.builder(Integer.class)
            .withParent(appearance)
            .withDefaultValue(3)
            .withComment("Declares the maximum amount of recipes displayed in a page if possible.")
            .withName("maxRecipePerPage")
            .constraints()
            .minNumerical(2)
            .maxNumerical(99)
            .finish()
            .build();
    
    private ConfigValue<Boolean> showUtilsButtons = ConfigValue.builder(Boolean.class)
            .withParent(modules)
            .withDefaultValue(false)
            .withComment("Declares whether the utils buttons are shown.")
            .withName("showUtilsButtons")
            .build();
    
    private ConfigValue<Boolean> disableRecipeBook = ConfigValue.builder(Boolean.class)
            .withParent(modules)
            .withDefaultValue(false)
            .withComment("Declares whether REI should remove the recipe book.")
            .withName("disableRecipeBook")
            .build();
    
    private ConfigValue<Boolean> clickableRecipeArrows = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(true)
            .withName("clickableRecipeArrows")
            .build();
    
    private ConfigValue<ItemCheatingMode> itemCheatingMode = ConfigValue.builder(ItemCheatingMode.class)
            .withParent(appearance)
            .withDefaultValue(ItemCheatingMode.REI_LIKE)
            .withName("itemCheatingMode")
            .build();
    
    private ConfigValue<Boolean> lightGrayRecipeBorder = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares the appearance of recipe's border.")
            .withName("lightGrayRecipeBorder")
            .build();
    
    private ConfigValue<Boolean> appendModNames = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares whether REI should append mod names to item stacks.")
            .withName("appendModNames")
            .build();
    
    private ConfigValue<Boolean> villagerScreenPermanentScrollBar = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares how the scrollbar in villager screen act.")
            .withName("villagerScreenPermanentScrollBar")
            .build();
    
    private ConfigValue<Boolean> registerRecipesInAnotherThread = ConfigValue.builder(Boolean.class)
            .withParent(technical)
            .withDefaultValue(true)
            .withName("registerRecipesInAnotherThread")
            .build();
    
    private ConfigValue<Boolean> scrollingEntryListWidget = ConfigValue.builder(Boolean.class)
            .withParent(appearance)
            .withDefaultValue(false)
            .withComment("Declares whether if entry list widget is scrolled.")
            .withName("scrollingEntryListWidget")
            .build();
    
    //    private ConfigValue<RelativePoint> choosePageDialogPoint = ConfigValue.builder(RelativePoint.class)
    //            .withParent(technical)
    //            .withDefaultValue(new RelativePoint(.5, .5))
    //            .withName("choosePageDialogPoint")
    //            .build();
    
    public ConfigObjectImpl() throws FiberException {
    
    }
    
    @Override
    public ConfigNode getConfigNode() {
        return configNode;
    }
    
    @Override
    public boolean isCheating() {
        return cheating.getValue();
    }
    
    @Override
    public void setCheating(boolean cheating) {
        this.cheating.setValue(cheating);
    }
    
    @Override
    public ItemListOrdering getItemListOrdering() {
        return itemListOrdering.getValue().getOrdering();
    }
    
    @Override
    public boolean isItemListAscending() {
        return itemListOrdering.getValue().isAscending();
    }
    
    @Override
    public boolean isUsingDarkTheme() {
        return darkTheme.getValue().booleanValue();
    }
    
    @Override
    public boolean isEntryListWidgetScrolled() {
        return scrollingEntryListWidget.getValue().booleanValue();
    }
    
    @Override
    public boolean shouldAppendModNames() {
        return appendModNames.getValue().booleanValue();
    }
    
    @Override
    public RecipeScreenType getRecipeScreenType() {
        return recipeScreenType.getValue();
    }
    
    @Override
    public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
        this.recipeScreenType.setValue(recipeScreenType);
    }
    
    @Override
    public boolean isLoadingDefaultPlugin() {
        return loadDefaultPlugin.getValue().booleanValue();
    }
    
    @Override
    public SearchFieldLocation getSearchFieldLocation() {
        return sideSearchField.getValue();
    }