geforkt von Mirrors/HeadDB
Redesigned the GUI & added main menu to categories
Dieser Commit ist enthalten in:
Ursprung
8ae2b7fecf
Commit
25283705f6
@ -22,9 +22,9 @@ public class LocalHead {
|
||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
|
||||
meta.setDisplayName(Utils.colorize("&8" + name));
|
||||
meta.setDisplayName(Utils.colorize("&e" + name));
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(Utils.colorize("&aUUID: " + uuid.toString()));
|
||||
lore.add(Utils.colorize("&7UUID: " + uuid.toString()));
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package tsp.headdb.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -62,7 +63,7 @@ public class InventoryUtils {
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
HeadAPI.removeFavoriteHead(player.getUniqueId(), head.getId());
|
||||
openFavoritesMenu(player);
|
||||
Utils.sendMessage(player, "Removed &e" + head.getName() + " &8from favorites.");
|
||||
Utils.sendMessage(player, "Removed &e" + head.getName() + " &7from favorites.");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -87,7 +88,7 @@ public class InventoryUtils {
|
||||
}
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
HeadAPI.addFavoriteHead(player.getUniqueId(), head.getId());
|
||||
Utils.sendMessage(player, "Added &e" + head.getName() + " &8to favorites.");
|
||||
Utils.sendMessage(player, "Added &e" + head.getName() + " &7to favorites.");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -123,7 +124,7 @@ public class InventoryUtils {
|
||||
public static void openDatabase(Player player) {
|
||||
Inventory inventory = Bukkit.createInventory(null, 54, Utils.colorize("&c&lHeadDB &8(" + HeadAPI.getHeads().size() + ")"));
|
||||
|
||||
fillBorder(inventory, XMaterial.BLACK_STAINED_GLASS_PANE.parseItem());
|
||||
fill(inventory, XMaterial.BLACK_STAINED_GLASS_PANE.parseItem());
|
||||
for (Category category : Category.getCategories()) {
|
||||
ItemStack item = category.getItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -135,14 +136,14 @@ public class InventoryUtils {
|
||||
inventory.addItem(item);
|
||||
}
|
||||
|
||||
inventory.setItem(37, buildButton(
|
||||
inventory.setItem(39, buildButton(
|
||||
XMaterial.BOOK.parseItem(),
|
||||
"&eFavorites",
|
||||
"",
|
||||
"&8Click to view your favorites")
|
||||
);
|
||||
|
||||
inventory.setItem(43, buildButton(
|
||||
inventory.setItem(41, buildButton(
|
||||
XMaterial.COMPASS.parseItem(),
|
||||
"&aLocal",
|
||||
"",
|
||||
@ -152,28 +153,31 @@ public class InventoryUtils {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
public static void fillBorder(Inventory inv, ItemStack item) {
|
||||
public static void fill(Inventory inv, ItemStack item) {
|
||||
int size = inv.getSize();
|
||||
int rows = (size + 1) / 9;
|
||||
int[] ignored = new int[]{20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 39, 41};
|
||||
|
||||
// Fill top
|
||||
for (int i = 0; i < 9; i++) {
|
||||
// Fill
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!contains(i, ignored)) {
|
||||
ItemStack slotItem = inv.getItem(i);
|
||||
if (slotItem == null || slotItem.getType() == Material.AIR) {
|
||||
inv.setItem(i, item);
|
||||
}
|
||||
|
||||
// Fill bottom
|
||||
for (int i = size - 9; i < size; i++) {
|
||||
inv.setItem(i, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill sides
|
||||
for (int i = 2; i <= rows - 1; i++) {
|
||||
int[] slots = new int[]{i * 9 - 1, (i - 1) * 9};
|
||||
inv.setItem(slots[0], item);
|
||||
inv.setItem(slots[1], item);
|
||||
private static boolean contains(int n, int... array) {
|
||||
for (int i : array) {
|
||||
if (i == n) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemStack buildButton(ItemStack item, String name, String... lore) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Utils.colorize(name));
|
||||
|
@ -33,6 +33,8 @@ public class PagedPane implements InventoryHolder {
|
||||
protected Button controlBack;
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected Button controlNext;
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected Button controlMain;
|
||||
|
||||
/**
|
||||
* @param pageSize The page size. inventory rows - 2
|
||||
@ -145,6 +147,7 @@ public class PagedPane implements InventoryHolder {
|
||||
|
||||
controlBack = null;
|
||||
controlNext = null;
|
||||
controlMain = null;
|
||||
createControls(inventory);
|
||||
}
|
||||
|
||||
@ -169,6 +172,12 @@ public class PagedPane implements InventoryHolder {
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (event.getSlot() == inventory.getSize()- 5) {
|
||||
if (controlMain != null){
|
||||
controlMain.onClick(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
pages.get(currentIndex).handleClick(event);
|
||||
|
||||
@ -236,12 +245,9 @@ public class PagedPane implements InventoryHolder {
|
||||
"&3&lPage &a&l%d &7/ &c&l%d",
|
||||
getCurrentPage(), getPageAmount()
|
||||
);
|
||||
String lore = String.format(
|
||||
Locale.ROOT,
|
||||
"&7Current: &a%d",
|
||||
getCurrentPage()
|
||||
);
|
||||
String lore = "&7Click to go to the &cMain Menu";
|
||||
ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MWY1MTI2NmVkZGM2MjA3ZjEyYWU4ZDdhNDljNWRiMDQxNWFkYTA0ZGFiOTJiYjc2ODZhZmRiMTdmNGQ0ZSJ9fX0=").getItemStack(), name, lore);
|
||||
controlMain = new Button(itemStack, event -> InventoryUtils.openDatabase((Player) event.getWhoClicked()));
|
||||
inventory.setItem(inventory.getSize() - 5, itemStack);
|
||||
}
|
||||
}
|
||||
@ -250,7 +256,7 @@ public class PagedPane implements InventoryHolder {
|
||||
int yMod = rowIndex * 9;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int slot = yMod + i;
|
||||
inventory.setItem(slot, itemStack);
|
||||
inventory.setItem(slot, setMeta(itemStack, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren