From 96717d05e012ff9d27185caa1151b6522846d602 Mon Sep 17 00:00:00 2001 From: Leandro Date: Thu, 1 Jul 2021 02:31:53 -0300 Subject: [PATCH] Hide the Favorites, Search and Local UI options based on permissions. The Search UI option uses a new permission, headdb.searchui in order to keep the /hdb search command in servers where the UI errors out. --- .../tsp/headdb/inventory/InventoryUtils.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/tsp/headdb/inventory/InventoryUtils.java b/src/main/java/tsp/headdb/inventory/InventoryUtils.java index 16f7323..e39bd35 100644 --- a/src/main/java/tsp/headdb/inventory/InventoryUtils.java +++ b/src/main/java/tsp/headdb/inventory/InventoryUtils.java @@ -163,33 +163,39 @@ public class InventoryUtils { inventory.addItem(item); } - inventory.setItem(39, buildButton( + if (player.hasPermission("headdb.favorites")) { + inventory.setItem(39, buildButton( XMaterial.BOOK.parseItem(), "&eFavorites", "", "&8Click to view your favorites") - ); + ); + } - inventory.setItem(40, buildButton( + if (player.hasPermission("headdb.searchui")) { + inventory.setItem(40, buildButton( XMaterial.DARK_OAK_SIGN.parseItem(), "&9Search", "", "&8Click to open search menu" - )); + )); + } - inventory.setItem(41, buildButton( + if (player.hasPermission("headdb.local")) { + inventory.setItem(41, buildButton( XMaterial.COMPASS.parseItem(), "&aLocal", "", "&8Heads from any players that have logged on the server" - )); + )); + } player.openInventory(inventory); } public static void fill(Inventory inv, ItemStack item) { int size = inv.getSize(); - int[] ignored = new int[]{20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 39, 40, 41}; + int[] ignored = new int[]{20, 21, 22, 23, 24, 29, 30, 31, 32, 33}; // Fill for (int i = 0; i < size; i++) {