From 88b8fcce0c9c5196fe095bee0d25a7ab75d23a3b Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 11 Jun 2021 23:38:50 +0200 Subject: [PATCH] xmaterial hates me --- src/main/java/tsp/headdb/api/Head.java | 3 ++- src/main/java/tsp/headdb/api/LocalHead.java | 3 ++- .../java/tsp/headdb/inventory/InventoryUtils.java | 11 +++-------- src/main/java/tsp/headdb/inventory/PagedPane.java | 3 +-- src/main/resources/plugin.yml | 1 + 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/tsp/headdb/api/Head.java b/src/main/java/tsp/headdb/api/Head.java index ead2171..5fc5fff 100644 --- a/src/main/java/tsp/headdb/api/Head.java +++ b/src/main/java/tsp/headdb/api/Head.java @@ -3,6 +3,7 @@ package tsp.headdb.api; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import org.apache.commons.lang.Validate; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import tsp.headdb.database.Category; @@ -35,7 +36,7 @@ public class Head { Validate.notNull(uuid, "uuid must not be null!"); Validate.notNull(value, "value must not be null!"); - ItemStack item = new ItemStack(XMaterial.PLAYER_HEAD.parseItem()); + ItemStack item = new ItemStack(Material.PLAYER_HEAD); SkullMeta meta = (SkullMeta) item.getItemMeta(); meta.setDisplayName(Utils.colorize(category != null ? category.getColor() + name : "&8" + name)); // set skull owner diff --git a/src/main/java/tsp/headdb/api/LocalHead.java b/src/main/java/tsp/headdb/api/LocalHead.java index abbe340..fc443e3 100644 --- a/src/main/java/tsp/headdb/api/LocalHead.java +++ b/src/main/java/tsp/headdb/api/LocalHead.java @@ -2,6 +2,7 @@ package tsp.headdb.api; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import tsp.headdb.util.Utils; @@ -19,7 +20,7 @@ public class LocalHead { public ItemStack getItemStack() { Validate.notNull(uuid, "uuid must not be null!"); - ItemStack item = new ItemStack(XMaterial.PLAYER_HEAD.parseItem()); + ItemStack item = new ItemStack(Material.PLAYER_HEAD); SkullMeta meta = (SkullMeta) item.getItemMeta(); meta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid)); meta.setDisplayName(Utils.colorize("&e" + name)); diff --git a/src/main/java/tsp/headdb/inventory/InventoryUtils.java b/src/main/java/tsp/headdb/inventory/InventoryUtils.java index bf24ac3..16f7323 100644 --- a/src/main/java/tsp/headdb/inventory/InventoryUtils.java +++ b/src/main/java/tsp/headdb/inventory/InventoryUtils.java @@ -15,6 +15,7 @@ import tsp.headdb.util.Utils; import tsp.headdb.util.XMaterial; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class InventoryUtils { @@ -150,7 +151,7 @@ public class InventoryUtils { public static void openDatabase(Player player) { Inventory inventory = Bukkit.createInventory(null, 54, Utils.colorize("&c&lHeadDB &8(" + HeadAPI.getHeads().size() + ")")); - fill(inventory, XMaterial.BLACK_STAINED_GLASS_PANE.parseItem()); + fill(inventory, new ItemStack(Material.BLACK_STAINED_GLASS_PANE)); for (Category category : Category.getCategories()) { ItemStack item = category.getItem(); ItemMeta meta = item.getItemMeta(); @@ -202,13 +203,7 @@ public class InventoryUtils { } private static boolean contains(int n, int... array) { - for (int i : array) { - if (i == n) { - return true; - } - } - - return false; + return Arrays.binarySearch(array, n) > -1; } private static ItemStack buildButton(ItemStack item, String name, String... lore) { diff --git a/src/main/java/tsp/headdb/inventory/PagedPane.java b/src/main/java/tsp/headdb/inventory/PagedPane.java index d9783e7..4e71492 100644 --- a/src/main/java/tsp/headdb/inventory/PagedPane.java +++ b/src/main/java/tsp/headdb/inventory/PagedPane.java @@ -15,7 +15,6 @@ import org.bukkit.inventory.meta.ItemMeta; import tsp.headdb.HeadDB; import tsp.headdb.api.HeadAPI; import tsp.headdb.util.Utils; -import tsp.headdb.util.XMaterial; import java.util.*; import java.util.Map.Entry; @@ -206,7 +205,7 @@ public class PagedPane implements InventoryHolder { // create separator fillRow( inventory.getSize() / 9 - 2, - XMaterial.BLACK_STAINED_GLASS_PANE.parseItem(), + new ItemStack(Material.BLACK_STAINED_GLASS_PANE), inventory ); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d73ac3e..2308a61 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,6 +3,7 @@ description: ${project.description} main: tsp.headdb.HeadDB version: ${project.version} +api-version: 1.16 author: Silent commands: