forked from Maxlego08/zMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.java
More file actions
556 lines (484 loc) · 24.9 KB
/
Configuration.java
File metadata and controls
556 lines (484 loc) · 24.9 KB
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
package fr.maxlego08.menu.api.configuration;
import fr.maxlego08.menu.api.configuration.annotation.ConfigOption;
import fr.maxlego08.menu.api.configuration.annotation.ConfigUpdate;
import fr.maxlego08.menu.api.enums.DialogInputType;
import fr.maxlego08.menu.api.enums.PerformanceFilterMode;
import fr.maxlego08.menu.api.utils.OpGrantMethod;
import fr.maxlego08.menu.zcore.logger.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.inventory.ClickType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Configuration {
// Enable debug, allows you to display errors in the console that would normally be hidden.
@ConfigOption(
key = "enableDebug",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable debug"
)
public static boolean enableDebug = false;
// Enable debug time, allows you to display the code execution time in nanosecond, perfect for testing the effectiveness of the plugin.
@ConfigOption(
key = "enableDebugTime",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable debug time"
)
public static boolean enableDebugTime = false;
// Enable an information message, allows you to view messages that tell you about an inventory or that an order has been successfully loaded.
@ConfigOption(
key = "enableInformationMessage",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable information message"
)
public static boolean enableInformationMessage = true;
// Enable save or load file log in console
@ConfigOption(
key = "enableLogStorageFile",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable log storage file"
)
public static boolean enableLogStorageFile = false;
// Skip update check
@ConfigOption(
key = "skipUpdateCheck",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Skip update check"
)
public static boolean skipUpdateCheck = false;
// Enable open message, default value for the command /zm open <inventory name> <player> <display message>
@ConfigOption(
key = "enableOpenMessage",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable open message"
)
public static boolean enableOpenMessage = true;
// Enable mini message format, allows you to activate the mini message format, available from 1.17 onwards, more information here: https://docs.advntr.dev/minimessage/index.html
@ConfigOption(
key = "enableMiniMessageFormat",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable mini message format"
)
public static boolean enableMiniMessageFormat = true;
// Enable player command in chat, Allows you to ensure that when a player executes a command, they execute it from the chat and not from the console. If you have "fake" command, which are not saved in spigot you need to enable this option.
@ConfigOption(
key = "enablePlayerCommandInChat",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable player command in chat"
)
public static boolean enablePlayerCommandInChat = false;
// Allows you to use the FastEvent interface instead of bukkit events. You gain performance. To use FastEvent, please read the documentation.
@ConfigOption(
key = "enableFastEvent",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable FastEvent"
)
public static boolean enableFastEvent = false;
// Seconds save player data: The time in seconds for automatic backup of player data.
@ConfigOption(
key = "secondsSavePlayerData",
type = DialogInputType.NUMBER_RANGE,
label = "Seconds save player data",
startRange = 60,
endRange = 3600,
stepRange = 5
)
public static int secondsSavePlayerData = 600;
// Seconds save player data: The time in seconds for automatic backup of inventories data.
@ConfigOption(
key = "secondsSavePlayerInventories",
type = DialogInputType.NUMBER_RANGE,
label = "Seconds save player inventories",
startRange = 60,
endRange = 3600,
stepRange = 5
)
public static int secondsSavePlayerInventories = 600;
// Default menu name
public static String mainMenu = "example";
// Open main menu when swap item offhand key is press
@ConfigOption(
key = "useSwapItemOffHandKeyToOpenMainMenu",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Use swap item offhand key to open main menu"
)
public static boolean useSwapItemOffHandKeyToOpenMainMenu = false;
// Open main menu when swap item offhand key is press and sneak key
@ConfigOption(
key = "useSwapItemOffHandKeyToOpenMainMenuNeedsShift",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Use swap item offhand key to open main menu needs shift"
)
public static boolean useSwapItemOffHandKeyToOpenMainMenuNeedsShift = false;
// Load specific inventories
public static List<String> specifyPathMenus = new ArrayList<>();
// Generate default configuration
@ConfigOption(
key = "generateDefaultFile",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Generate default file"
)
public static boolean generateDefaultFile = true;
// Does not take double click into account
@ConfigOption(
key = "disableDoubleClickEvent",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Disable double click event"
)
public static boolean disableDoubleClickEvent = true;
// Enable anti dupe
@ConfigOption(
key = "enableAntiDupe",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable anti dupe"
)
public static boolean enableAntiDupe = true;
// Enable anti dupe discord notification
@ConfigOption(
key = "enableAntiDupeDiscordNotification",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable anti dupe discord notification"
)
public static boolean enableAntiDupeDiscordNotification = false;
@ConfigOption(
key = "antiDupeDiscordWebhookUrl",
type = DialogInputType.TEXT,
label = "Anti dupe discord webhook url",
maxLength = 100
)
public static String antiDupeDiscordWebhookUrl = "https://discord.com/api/webhooks/<your discord webhook url>";
@ConfigOption(
key = "antiDupeMessage",
type = DialogInputType.TEXT,
label = "Anti dupe message",
maxLength = 200
)
public static String antiDupeMessage = "**%player%** use %amount% %itemname% which comes from zMenu. Removing it !";
public static List<ClickType> allClicksType = Arrays.asList(ClickType.MIDDLE, ClickType.RIGHT, ClickType.LEFT, ClickType.SHIFT_RIGHT, ClickType.SHIFT_LEFT);
// Enable cache itemstack in memory
@ConfigOption(
key = "enableCacheItemStack",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable cache item stack"
)
public static boolean enableCacheItemStack = true;
@ConfigOption(
key = "enableCooldownClick",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable cooldown click"
)
public static boolean enableCooldownClick = true;
@ConfigOption(
key = "cooldownClickMilliseconds",
type = DialogInputType.NUMBER_RANGE,
label = "Cooldown click milliseconds",
endRange = 1000,
stepRange = 10
)
public static long cooldownClickMilliseconds = 100;
@ConfigOption(
key = "cachePlaceholderAPI",
type = DialogInputType.NUMBER_RANGE,
label = "Cache PlaceholderAPI",
endRange = 300,
stepRange = 5
)
public static long cachePlaceholderAPI = 20;
@ConfigOption(
key = "enableCachePlaceholderAPI",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable cache PlaceholderAPI"
)
public static boolean enableCachePlaceholderAPI = false;
@ConfigOption(
key = "enableDownloadCommand",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable download command"
)
public static boolean enableDownloadCommand = false;
@ConfigOption(
key = "enablePlayerOpenInventoryLogs",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable player open inventory logs"
)
public static boolean enablePlayerOpenInventoryLogs = true;
@ConfigOption(
key = "enablePlayerCommandsAsOPAction",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable player commands as OP action (requires server restart)"
)
public static boolean enablePlayerCommandsAsOPAction = false;
@ConfigOption(
key = "enablePacketEventClickLimiter",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable packet event click limiter"
)
public static boolean enablePacketEventClickLimiter = false;
@ConfigOption(
key = "packetEventClickLimiterMilliseconds",
type = DialogInputType.NUMBER_RANGE,
label = "Packet event click limiter milliseconds",
endRange = 1000,
stepRange = 10
)
public static long packetEventClickLimiterMilliseconds = 50L;
public static OpGrantMethod opGrantMethod = OpGrantMethod.ATTACHMENT;
@ConfigOption(
key = "enableToast",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable toast"
)
public static boolean enableToast = true;
@ConfigOption(
key = "enablePerformanceDebug",
type = DialogInputType.BOOLEAN,
trueText = "<green>Enabled",
falseText = "<red>Disabled",
label = "Enable performance debug"
)
public static boolean enablePerformanceDebug = false;
public static List<String> skipCloseActionsOnInventorySwitch = Arrays.asList("inventory", "inv", "back");
public static PerformanceFilterMode performanceFilterMode = PerformanceFilterMode.DISABLED;
public static List<String> performanceFilterOperations = new ArrayList<>();
public static long performanceThresholdMs = 10;
@ConfigUpdate
public static boolean updated = false;
/**
* static Singleton instance.
*/
private static volatile Configuration instance;
/**
* Private constructor for singleton.
*/
private Configuration() {
}
/**
* Return a singleton instance of Configuration.
*/
public static Configuration getInstance() {
// Double lock for thread safety.
if (instance == null) {
synchronized (Configuration.class) {
if (instance == null) {
instance = new Configuration();
}
}
}
return instance;
}
public void load(@NotNull FileConfiguration fileConfiguration) {
enableDebug = fileConfiguration.getBoolean(ConfigPath.ENABLE_DEBUG.getPath());
enableDebugTime = fileConfiguration.getBoolean(ConfigPath.ENABLE_DEBUG_TIME.getPath());
enableInformationMessage = fileConfiguration.getBoolean(ConfigPath.ENABLE_INFORMATION_MESSAGE.getPath());
enableLogStorageFile = fileConfiguration.getBoolean(ConfigPath.ENABLE_LOG_STORAGE_FILE.getPath());
skipUpdateCheck = fileConfiguration.getBoolean(ConfigPath.SKIP_UPDATE_CHECK.getPath());
enableOpenMessage = fileConfiguration.getBoolean(ConfigPath.ENABLE_OPEN_MESSAGE.getPath());
enableMiniMessageFormat = fileConfiguration.getBoolean(ConfigPath.ENABLE_MINI_MESSAGE_FORMAT.getPath());
enablePlayerCommandInChat = fileConfiguration.getBoolean(ConfigPath.ENABLE_PLAYER_COMMAND_IN_CHAT.getPath());
enableFastEvent = fileConfiguration.getBoolean(ConfigPath.ENABLE_FAST_EVENT.getPath());
secondsSavePlayerData = fileConfiguration.getInt(ConfigPath.SECONDS_SAVE_PLAYER_DATA.getPath());
secondsSavePlayerInventories = fileConfiguration.getInt(ConfigPath.SECONDS_SAVE_PLAYER_INVENTORIES.getPath());
mainMenu = fileConfiguration.getString(ConfigPath.MAIN_MENU.getPath());
useSwapItemOffHandKeyToOpenMainMenu = fileConfiguration.getBoolean(ConfigPath.USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU.getPath());
useSwapItemOffHandKeyToOpenMainMenuNeedsShift = fileConfiguration.getBoolean(ConfigPath.USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU_NEEDS_SHIFT.getPath());
specifyPathMenus = fileConfiguration.getStringList(ConfigPath.SPECIFY_PATH_MENUS.getPath());
generateDefaultFile = fileConfiguration.getBoolean(ConfigPath.GENERATE_DEFAULT_FILE.getPath());
disableDoubleClickEvent = fileConfiguration.getBoolean(ConfigPath.DISABLE_DOUBLE_CLICK_EVENT.getPath());
enableAntiDupe = fileConfiguration.getBoolean(ConfigPath.ENABLE_ANTI_DUPE.getPath());
enableAntiDupeDiscordNotification = fileConfiguration.getBoolean(ConfigPath.ENABLE_ANTI_DUPE_DISCORD_NOTIFICATION.getPath());
antiDupeDiscordWebhookUrl = fileConfiguration.getString(ConfigPath.ANTI_DUPE_DISCORD_WEBHOOK_URL.getPath());
antiDupeMessage = fileConfiguration.getString(ConfigPath.ANTI_DUPE_MESSAGE.getPath());
List<String> clickTypeStrings = fileConfiguration.getStringList(ConfigPath.ALL_CLICKS_TYPE.getPath());
List<ClickType> clickTypes = new ArrayList<>(clickTypeStrings.size());
for (String name : clickTypeStrings) {
try {
clickTypes.add(ClickType.valueOf(name));
} catch (IllegalArgumentException e) {
Bukkit.getLogger().warning("[zMenu] Invalid click type in config: " + name);
}
}
allClicksType = clickTypes;
enableCacheItemStack = fileConfiguration.getBoolean(ConfigPath.ENABLE_CACHE_ITEM_STACK.getPath());
enableCooldownClick = fileConfiguration.getBoolean(ConfigPath.ENABLE_COOLDOWN_CLICK.getPath());
cooldownClickMilliseconds = fileConfiguration.getLong(ConfigPath.COOLDOWN_CLICK_MILLISECONDS.getPath());
cachePlaceholderAPI = fileConfiguration.getLong(ConfigPath.CACHE_PLACEHOLDER_API.getPath());
enableCachePlaceholderAPI = fileConfiguration.getBoolean(ConfigPath.ENABLE_CACHE_PLACEHOLDER_API.getPath());
enableDownloadCommand = fileConfiguration.getBoolean(ConfigPath.ENABLE_DOWNLOAD_COMMAND.getPath());
enablePlayerOpenInventoryLogs = fileConfiguration.getBoolean(ConfigPath.ENABLE_PLAYER_OPEN_INVENTORY_LOGS.getPath());
enablePlayerCommandsAsOPAction = fileConfiguration.getBoolean(ConfigPath.ENABLE_PLAYER_COMMANDS_AS_OP_ACTION.getPath());
try {
opGrantMethod = OpGrantMethod.valueOf(fileConfiguration.getString(ConfigPath.OP_GRANT_METHOD.getPath(), OpGrantMethod.ATTACHMENT.name()).toUpperCase());
} catch (IllegalArgumentException e) {
Logger.info("Invalid op grant method in config, defaulting to ATTACHMENT.");
opGrantMethod = OpGrantMethod.ATTACHMENT;
}
enableToast = fileConfiguration.getBoolean(ConfigPath.ENABLE_TOAST.getPath(), true);
enablePacketEventClickLimiter = fileConfiguration.getBoolean(ConfigPath.ENABLE_PACKET_EVENT_CLICK_LIMITER.getPath());
packetEventClickLimiterMilliseconds = fileConfiguration.getLong(ConfigPath.PACKET_EVENT_CLICK_LIMITER_MILLISECONDS.getPath(), 50L);
enablePerformanceDebug = fileConfiguration.getBoolean(ConfigPath.ENABLE_PERFORMANCE_DEBUG.getPath(), false);
performanceThresholdMs = fileConfiguration.getLong(ConfigPath.PERFORMANCE_DEBUG_THRESHOLD_MS.getPath(), 10L);
performanceFilterOperations = fileConfiguration.getStringList(ConfigPath.PERFORMANCE_DEBUG_FILTER_OPERATIONS.getPath());
skipCloseActionsOnInventorySwitch = fileConfiguration.getStringList(ConfigPath.SKIP_CLOSE_ACTIONS_ON_INVENTORY_SWITCH.getPath());
try {
performanceFilterMode = PerformanceFilterMode.valueOf(fileConfiguration.getString(ConfigPath.PERFORMANCE_DEBUG_FILTER_MODE.getPath(), PerformanceFilterMode.DISABLED.name()).toUpperCase());
} catch (IllegalArgumentException e) {
Logger.info("Invalid performance filter mode in config, defaulting to DISABLED.");
performanceFilterMode = PerformanceFilterMode.DISABLED;
}
}
public void save(@NotNull FileConfiguration fileConfiguration,@NotNull File file) {
if (!updated) {
return;
}
fileConfiguration.set(ConfigPath.ENABLE_DEBUG.getPath(), enableDebug);
fileConfiguration.set(ConfigPath.ENABLE_DEBUG_TIME.getPath(), enableDebugTime);
fileConfiguration.set(ConfigPath.ENABLE_INFORMATION_MESSAGE.getPath(), enableInformationMessage);
fileConfiguration.set(ConfigPath.ENABLE_LOG_STORAGE_FILE.getPath(), enableLogStorageFile);
fileConfiguration.set(ConfigPath.SKIP_UPDATE_CHECK.getPath(), skipUpdateCheck);
fileConfiguration.set(ConfigPath.ENABLE_OPEN_MESSAGE.getPath(), enableOpenMessage);
fileConfiguration.set(ConfigPath.ENABLE_MINI_MESSAGE_FORMAT.getPath(), enableMiniMessageFormat);
fileConfiguration.set(ConfigPath.ENABLE_PLAYER_COMMAND_IN_CHAT.getPath(), enablePlayerCommandInChat);
fileConfiguration.set(ConfigPath.ENABLE_FAST_EVENT.getPath(), enableFastEvent);
fileConfiguration.set(ConfigPath.SECONDS_SAVE_PLAYER_DATA.getPath(), secondsSavePlayerData);
fileConfiguration.set(ConfigPath.SECONDS_SAVE_PLAYER_INVENTORIES.getPath(), secondsSavePlayerInventories);
fileConfiguration.set(ConfigPath.MAIN_MENU.getPath(), mainMenu);
fileConfiguration.set(ConfigPath.USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU.getPath(), useSwapItemOffHandKeyToOpenMainMenu);
fileConfiguration.set(ConfigPath.USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU_NEEDS_SHIFT.getPath(), useSwapItemOffHandKeyToOpenMainMenuNeedsShift);
fileConfiguration.set(ConfigPath.SPECIFY_PATH_MENUS.getPath(), specifyPathMenus);
fileConfiguration.set(ConfigPath.GENERATE_DEFAULT_FILE.getPath(), generateDefaultFile);
fileConfiguration.set(ConfigPath.DISABLE_DOUBLE_CLICK_EVENT.getPath(), disableDoubleClickEvent);
fileConfiguration.set(ConfigPath.ENABLE_ANTI_DUPE.getPath(), enableAntiDupe);
fileConfiguration.set(ConfigPath.ENABLE_ANTI_DUPE_DISCORD_NOTIFICATION.getPath(), enableAntiDupeDiscordNotification);
fileConfiguration.set(ConfigPath.ANTI_DUPE_DISCORD_WEBHOOK_URL.getPath(), antiDupeDiscordWebhookUrl);
fileConfiguration.set(ConfigPath.ANTI_DUPE_MESSAGE.getPath(), antiDupeMessage);
List<String> clickTypeNames = new ArrayList<>(allClicksType.size());
for (ClickType clickType : allClicksType) {
clickTypeNames.add(clickType.name());
}
fileConfiguration.set(ConfigPath.ALL_CLICKS_TYPE.getPath(), clickTypeNames);
fileConfiguration.set(ConfigPath.ENABLE_CACHE_ITEM_STACK.getPath(), enableCacheItemStack);
fileConfiguration.set(ConfigPath.ENABLE_COOLDOWN_CLICK.getPath(), enableCooldownClick);
fileConfiguration.set(ConfigPath.COOLDOWN_CLICK_MILLISECONDS.getPath(), cooldownClickMilliseconds);
fileConfiguration.set(ConfigPath.CACHE_PLACEHOLDER_API.getPath(), cachePlaceholderAPI);
fileConfiguration.set(ConfigPath.ENABLE_CACHE_PLACEHOLDER_API.getPath(), enableCachePlaceholderAPI);
fileConfiguration.set(ConfigPath.ENABLE_DOWNLOAD_COMMAND.getPath(), enableDownloadCommand);
fileConfiguration.set(ConfigPath.ENABLE_PLAYER_OPEN_INVENTORY_LOGS.getPath(), enablePlayerOpenInventoryLogs);
fileConfiguration.set(ConfigPath.ENABLE_PLAYER_COMMANDS_AS_OP_ACTION.getPath(), enablePlayerCommandsAsOPAction);
fileConfiguration.set(ConfigPath.OP_GRANT_METHOD.getPath(), opGrantMethod.name());
fileConfiguration.set(ConfigPath.ENABLE_TOAST.getPath(), enableToast);
fileConfiguration.set(ConfigPath.SKIP_CLOSE_ACTIONS_ON_INVENTORY_SWITCH.getPath(), skipCloseActionsOnInventorySwitch);
fileConfiguration.set(ConfigPath.ENABLE_PACKET_EVENT_CLICK_LIMITER.getPath(), enablePacketEventClickLimiter);
fileConfiguration.set(ConfigPath.PACKET_EVENT_CLICK_LIMITER_MILLISECONDS.getPath(), packetEventClickLimiterMilliseconds);
fileConfiguration.set(ConfigPath.ENABLE_PERFORMANCE_DEBUG.getPath(), enablePerformanceDebug);
fileConfiguration.set(ConfigPath.PERFORMANCE_DEBUG_THRESHOLD_MS.getPath(), performanceThresholdMs);
fileConfiguration.set(ConfigPath.PERFORMANCE_DEBUG_FILTER_MODE.getPath(), performanceFilterMode.name());
fileConfiguration.set(ConfigPath.PERFORMANCE_DEBUG_FILTER_OPERATIONS.getPath(), performanceFilterOperations);
updated = false;
try {
fileConfiguration.save(file);
} catch (IOException e) {
Bukkit.getLogger().warning("[zMenu] Unable to save config file: " + e.getMessage());
}
}
private enum ConfigPath {
ENABLE_DEBUG("enable-debug"),
ENABLE_DEBUG_TIME("enable-debug-time"),
ENABLE_INFORMATION_MESSAGE("enable-information-message"),
ENABLE_LOG_STORAGE_FILE("enable-log-storage-file"),
SKIP_UPDATE_CHECK("skip-update-check"),
ENABLE_OPEN_MESSAGE("enable-open-message"),
ENABLE_MINI_MESSAGE_FORMAT("enable-mini-message-format"),
ENABLE_PLAYER_COMMAND_IN_CHAT("enable-player-command-in-chat"),
ENABLE_FAST_EVENT("enable-fast-event"),
SECONDS_SAVE_PLAYER_DATA("seconds-save-player-data"),
SECONDS_SAVE_PLAYER_INVENTORIES("seconds-save-player-inventories"),
MAIN_MENU("main-menu"),
USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU("use-swap-item-off-hand-key-to-open-main-menu"),
USE_SWAP_ITEM_OFF_HAND_KEY_TO_OPEN_MAIN_MENU_NEEDS_SHIFT("use-swap-item-off-hand-key-to-open-main-menu-needs-shift"),
SPECIFY_PATH_MENUS("specify-path-menus"),
GENERATE_DEFAULT_FILE("generate-default-file"),
DISABLE_DOUBLE_CLICK_EVENT("disable-double-click-event"),
ENABLE_ANTI_DUPE("enable-anti-dupe"),
ENABLE_ANTI_DUPE_DISCORD_NOTIFICATION("enable-anti-dupe-discord-notification"),
ANTI_DUPE_DISCORD_WEBHOOK_URL("anti-dupe-discord-webhook-url"),
ANTI_DUPE_MESSAGE("anti-dupe-message"),
ALL_CLICKS_TYPE("all-clicks-type"),
ENABLE_CACHE_ITEM_STACK("enable-cache-item-stack"),
ENABLE_COOLDOWN_CLICK("enable-cooldown-click"),
COOLDOWN_CLICK_MILLISECONDS("cooldown-click-milliseconds"),
CACHE_PLACEHOLDER_API("cache-placeholder-api"),
ENABLE_CACHE_PLACEHOLDER_API("enable-cache-placeholder-api"),
ENABLE_DOWNLOAD_COMMAND("enable-download-command"),
ENABLE_PLAYER_OPEN_INVENTORY_LOGS("enable-player-open-inventory-logs"),
ENABLE_PLAYER_COMMANDS_AS_OP_ACTION("enable-player-commands-as-op-action"),
OP_GRANT_METHOD("op-grant-method"),
ENABLE_TOAST("enable-toast"),
SKIP_CLOSE_ACTIONS_ON_INVENTORY_SWITCH("skip-close-actions-on-inventory-switch"),
ENABLE_PACKET_EVENT_CLICK_LIMITER("enable-packet-event-click-limiter"),
PACKET_EVENT_CLICK_LIMITER_MILLISECONDS("packet-event-click-limiter-milliseconds"),
ENABLE_PERFORMANCE_DEBUG("enable-performance-debug"),
PERFORMANCE_DEBUG_THRESHOLD_MS("performance-debug.threshold-ms"),
PERFORMANCE_DEBUG_FILTER_MODE("performance-debug.filter.mode"),
PERFORMANCE_DEBUG_FILTER_OPERATIONS("performance-debug.filter.operations");
private final String path;
ConfigPath(@NotNull String path) {
this.path = path;
}
@Contract(pure = true)
@NotNull
public String getPath() {
return this.path;
}
}
}