Make it possible to change the default heads in the categories menu through the config.

Dieser Commit ist enthalten in:
Leandro 2021-07-04 21:35:50 -03:00
Ursprung 63ffca71fd
Commit d6cdde98c4
2 geänderte Dateien mit 36 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -39,22 +39,32 @@ public class InventoryUtils {
}
public static ItemStack uiGetItem(String category, ItemStack item) {
// Try to use the cached value first; then the config; then the given default.
if (!uiItem.containsKey(category)) {
if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".item")) {
String cfg = HeadDB.getInstance().getCfg().getString("ui.category." + category + ".item");
Material mat = Material.matchMaterial(cfg);
if (mat == null || mat == Material.AIR) {
// Material set in config is invalid, use the given default.
uiItem.put(category, item);
} else {
uiItem.put(category, new ItemStack(mat));
}
} else {
uiItem.put(category, item);
// Try to use the cached value first.
if (uiItem.containsKey(category)) return uiItem.get(category);
// Try to get a head from the config file.
if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".head")) {
int id = HeadDB.getInstance().getCfg().getInt("ui.category." + category + ".head");
Head head = HeadAPI.getHeadByID(id);
if (head != null) {
uiItem.put(category, head.getItemStack());
return uiItem.get(category);
}
}
return uiItem.get(category);
// Try to get an item from the config file.
if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".item")) {
String cfg = HeadDB.getInstance().getCfg().getString("ui.category." + category + ".item");
Material mat = Material.matchMaterial(cfg);
if (mat != null && mat != Material.AIR) {
uiItem.put(category, new ItemStack(mat));
return uiItem.get(category);
}
}
// No valid head or item in the config file, return the given default.
uiItem.put(category, item);
return item;
}
public static void openLocalMenu(Player player) {

Datei anzeigen

@ -26,26 +26,38 @@ economy:
# UI customization options.
ui:
category:
# Head categories.
alphabet:
location: 20
head: 1788
animals:
location: 21
head: 5741
blocks:
location: 22
head: 8624
decoration:
location: 23
head: 11046
food-drinks:
location: 24
head: 17442
humans:
location: 29
head: 19361
humanoid:
location: 30
head: 28320
miscellaneous:
location: 31
head: 32746
monsters:
location: 32
head: 34819
plants:
location: 33
head: 37278
# Meta categories, used for UI elements.
favorites:
location: 39
item: BOOK