-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
ConfigInventories.java
79 lines (71 loc) · 3.53 KB
/
ConfigInventories.java
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
package io.github.thatsmusic99.headsplus.config;
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.inventories.BaseInventory;
import io.github.thatsmusic99.headsplus.inventories.InventoryManager;
import io.github.thatsmusic99.headsplus.inventories.list.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ConfigInventories extends HPConfig {
private static ConfigInventories instance;
public ConfigInventories() throws Exception {
super("inventories.yml");
instance = this;
}
public static ConfigInventories get() {
return instance;
}
@Override
public void addDefaults() {
for (InventoryManager.IconType i : InventoryManager.IconType.values()) {
addDefault("icons." + i.getId() + ".material", i.getMaterial());
addDefault("icons." + i.getId() + ".display-name", i.getDisplayName());
addDefault("icons." + i.getId() + ".lore", i.getLore());
}
for (String s : Arrays.asList("next", "next_2", "next_3", "back", "back_2", "back_3", "start", "last")) {
addDefault("icons." + s + ".material", "ARROW");
addDefault("icons." + s + ".data-value", 0);
addDefault("icons." + s + ".display-name", "{msg_inventory.icon." + s.replaceAll("_", "-") + "}");
addDefault("icons." + s + ".lore", new ArrayList<>());
}
for (BaseInventory inv : Arrays.asList(new ChallengesMenu(),
new ChallengesSection(),
new HeadsFavourite(),
new HeadsMenu(),
new HeadsSection(),
new SellheadCategory(),
new SellheadMenu(), new ChallengesPinnedInv())) {
addDefault("inventories." + inv.getId() + ".title", inv.getDefaultTitle());
if (get("inventories." + inv.getId() + ".icons") instanceof List) {
HeadsPlus.get().getLogger().warning("Old format for inventories.yml detected for " + inv.getId() + "!" +
" Starting over...");
set("inventories." + inv.getId() + ".icons", inv.getDefaultItems());
}
addDefault("inventories." + inv.getId() + ".icons", inv.getDefaultItems());
addDefault("inventories." + inv.getId() + ".size", 54);
}
if (getDouble("version") < 0.1) {
ConfigSection section = getConfigSection("inventories");
if (section != null) {
for (String inventory : section.getKeys(false)) {
String items = getString("inventories." + inventory + ".icons");
if (inventory.equalsIgnoreCase("challenges-menu")) {
items = items.replaceAll("[S]", "C");
char[] chars = items.toCharArray();
chars[0] = 'P';
set("inventories." + inventory + ".icons", String.valueOf(chars));
continue;
} else if (inventory.equalsIgnoreCase("challenge-section")) {
char[] chars = items.toCharArray();
chars[0] = 'P';
set("inventories." + inventory + ".icons", String.valueOf(chars));
continue;
}
set("inventories." + inventory + ".icons", items.replaceAll("[HL]", "C"));
}
}
}
addDefault("version", 0.1);
}
}