Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-27 11:20:05 +01:00
Make it possible to change the default heads in the categories menu through the config.
Dieser Commit ist enthalten in:
Ursprung
63ffca71fd
Commit
d6cdde98c4
@ -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) {
|
||||
|
@ -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
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren