geforkt von Mirrors/HeadDB
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) {
|
public static ItemStack uiGetItem(String category, ItemStack item) {
|
||||||
// Try to use the cached value first; then the config; then the given default.
|
// Try to use the cached value first.
|
||||||
if (!uiItem.containsKey(category)) {
|
if (uiItem.containsKey(category)) return uiItem.get(category);
|
||||||
if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".item")) {
|
|
||||||
String cfg = HeadDB.getInstance().getCfg().getString("ui.category." + category + ".item");
|
// Try to get a head from the config file.
|
||||||
Material mat = Material.matchMaterial(cfg);
|
if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".head")) {
|
||||||
if (mat == null || mat == Material.AIR) {
|
int id = HeadDB.getInstance().getCfg().getInt("ui.category." + category + ".head");
|
||||||
// Material set in config is invalid, use the given default.
|
Head head = HeadAPI.getHeadByID(id);
|
||||||
uiItem.put(category, item);
|
if (head != null) {
|
||||||
} else {
|
uiItem.put(category, head.getItemStack());
|
||||||
uiItem.put(category, new ItemStack(mat));
|
return uiItem.get(category);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uiItem.put(category, item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
public static void openLocalMenu(Player player) {
|
||||||
|
@ -26,26 +26,38 @@ economy:
|
|||||||
# UI customization options.
|
# UI customization options.
|
||||||
ui:
|
ui:
|
||||||
category:
|
category:
|
||||||
|
# Head categories.
|
||||||
alphabet:
|
alphabet:
|
||||||
location: 20
|
location: 20
|
||||||
|
head: 1788
|
||||||
animals:
|
animals:
|
||||||
location: 21
|
location: 21
|
||||||
|
head: 5741
|
||||||
blocks:
|
blocks:
|
||||||
location: 22
|
location: 22
|
||||||
|
head: 8624
|
||||||
decoration:
|
decoration:
|
||||||
location: 23
|
location: 23
|
||||||
|
head: 11046
|
||||||
food-drinks:
|
food-drinks:
|
||||||
location: 24
|
location: 24
|
||||||
|
head: 17442
|
||||||
humans:
|
humans:
|
||||||
location: 29
|
location: 29
|
||||||
|
head: 19361
|
||||||
humanoid:
|
humanoid:
|
||||||
location: 30
|
location: 30
|
||||||
|
head: 28320
|
||||||
miscellaneous:
|
miscellaneous:
|
||||||
location: 31
|
location: 31
|
||||||
|
head: 32746
|
||||||
monsters:
|
monsters:
|
||||||
location: 32
|
location: 32
|
||||||
|
head: 34819
|
||||||
plants:
|
plants:
|
||||||
location: 33
|
location: 33
|
||||||
|
head: 37278
|
||||||
|
# Meta categories, used for UI elements.
|
||||||
favorites:
|
favorites:
|
||||||
location: 39
|
location: 39
|
||||||
item: BOOK
|
item: BOOK
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren