Make it possible to change the item used to fill the categories menu.

Dieser Commit ist enthalten in:
Leandro 2021-07-04 22:11:23 -03:00
Ursprung d6cdde98c4
Commit 5fb844f4b7
2 geänderte Dateien mit 14 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -56,7 +56,9 @@ public class InventoryUtils {
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) {
// AIR is allowed as the fill material for the menu, but not as a category item.
if (mat != null && (category.equals("fill") || mat != Material.AIR)) {
uiItem.put(category, new ItemStack(mat));
return uiItem.get(category);
}
@ -226,14 +228,17 @@ public class InventoryUtils {
));
}
fill(inventory, new ItemStack(Material.BLACK_STAINED_GLASS_PANE));
fill(inventory);
player.openInventory(inventory);
}
public static void fill(Inventory inv, ItemStack item) {
int size = inv.getSize();
public static void fill(Inventory inv) {
ItemStack item = uiGetItem("fill", new ItemStack(Material.BLACK_STAINED_GLASS_PANE));
// Do not bother filling the inventory if item to fill it with is AIR.
if (item == null || item.getType() == Material.AIR) return;
// Fill any non-empty inventory slots with the given item.
int size = inv.getSize();
for (int i = 0; i < size; i++) {
ItemStack slotItem = inv.getItem(i);
if (slotItem == null || slotItem.getType() == Material.AIR) {

Datei anzeigen

@ -26,7 +26,7 @@ economy:
# UI customization options.
ui:
category:
# Head categories.
# Head categories. You can use item: instead of head: here, but AIR is not supported.
alphabet:
location: 20
head: 1788
@ -57,7 +57,7 @@ ui:
plants:
location: 33
head: 37278
# Meta categories, used for UI elements.
# Meta categories, used for UI elements. AIR is not supported. You can use head: instead of item: here.
favorites:
location: 39
item: BOOK
@ -67,6 +67,9 @@ ui:
local:
location: 41
item: COMPASS
# Item used to fill unused slots in the categories menu. AIR is supported. You can use head: instead of item: here.
fill:
item: BLACK_STAINED_GLASS_PANE
# Debug Mode
debug: false