diff --git a/pom.xml b/pom.xml
index 84587f7..7cd6cd0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,11 @@
jitpack.io
https://jitpack.io
+
+
+ codemc-snapshots
+ https://repo.codemc.io/repository/maven-snapshots/
+
@@ -57,6 +62,12 @@
simplixstorage
3.2.0
+
+
+ net.wesjd
+ anvilgui
+ 1.4.0-SNAPSHOT
+
diff --git a/src/main/java/tsp/headdb/inventory/InventoryUtils.java b/src/main/java/tsp/headdb/inventory/InventoryUtils.java
index 6d500b4..4a8bb88 100644
--- a/src/main/java/tsp/headdb/inventory/InventoryUtils.java
+++ b/src/main/java/tsp/headdb/inventory/InventoryUtils.java
@@ -143,6 +143,13 @@ public class InventoryUtils {
"&8Click to view your favorites")
);
+ inventory.setItem(40, buildButton(
+ XMaterial.DARK_OAK_SIGN.parseItem(),
+ "&9Search",
+ "",
+ "&8Click to open search menu"
+ ));
+
inventory.setItem(41, buildButton(
XMaterial.COMPASS.parseItem(),
"&aLocal",
@@ -155,7 +162,7 @@ public class InventoryUtils {
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, 41};
+ int[] ignored = new int[]{20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 39, 40, 41};
// Fill
for (int i = 0; i < size; i++) {
diff --git a/src/main/java/tsp/headdb/inventory/PagedPane.java b/src/main/java/tsp/headdb/inventory/PagedPane.java
index e67ba6b..d9783e7 100644
--- a/src/main/java/tsp/headdb/inventory/PagedPane.java
+++ b/src/main/java/tsp/headdb/inventory/PagedPane.java
@@ -1,15 +1,18 @@
package tsp.headdb.inventory;
+import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
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;
@@ -245,9 +248,38 @@ public class PagedPane implements InventoryHolder {
"&3&lPage &a&l%d &7/ &c&l%d",
getCurrentPage(), getPageAmount()
);
- 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()));
+ ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MWY1MTI2NmVkZGM2MjA3ZjEyYWU4ZDdhNDljNWRiMDQxNWFkYTA0ZGFiOTJiYjc2ODZhZmRiMTdmNGQ0ZSJ9fX0=").getItemStack(),
+ name,
+ "&7Left-Click to go to the &cMain Menu",
+ "&7Right-Click to go to a &6Specific Page");
+ controlMain = new Button(itemStack, event -> {
+ if (event.getClick() == ClickType.RIGHT) {
+ new AnvilGUI.Builder()
+ .onComplete((player, text) -> {
+ try {
+ int i = Integer.parseInt(text);
+ if (i > getPageAmount()) {
+ Utils.sendMessage(player, "&cPage number is out of bounds! Max: &e" + getPageAmount());
+ return AnvilGUI.Response.text("&cOut of bounds!");
+ }
+ Bukkit.getScheduler().runTaskLater(HeadDB.getInstance(), () -> {
+ open(player);
+ selectPage(i - 1);
+ }, 40L);
+ return AnvilGUI.Response.close();
+ } catch (NumberFormatException nfe) {
+ Utils.sendMessage(player, "&cValue must be a number!");
+ return AnvilGUI.Response.text(Utils.colorize("&cValue must be a number!"));
+ }
+ })
+ .title("Select Page")
+ .text("Page number...")
+ .plugin(HeadDB.getInstance())
+ .open((Player) event.getWhoClicked());
+ } else {
+ InventoryUtils.openDatabase((Player) event.getWhoClicked());
+ }
+ });
inventory.setItem(inventory.getSize() - 5, itemStack);
}
}
diff --git a/src/main/java/tsp/headdb/listener/MenuListener.java b/src/main/java/tsp/headdb/listener/MenuListener.java
index 2dcd2b5..e8c9949 100644
--- a/src/main/java/tsp/headdb/listener/MenuListener.java
+++ b/src/main/java/tsp/headdb/listener/MenuListener.java
@@ -1,5 +1,6 @@
package tsp.headdb.listener;
+import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -8,6 +9,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
+import tsp.headdb.HeadDB;
import tsp.headdb.database.Category;
import tsp.headdb.inventory.InventoryUtils;
import tsp.headdb.util.Utils;
@@ -53,6 +55,18 @@ public class MenuListener implements Listener {
InventoryUtils.openLocalMenu(player);
return;
}
+ if (name.equalsIgnoreCase("search")) {
+ new AnvilGUI.Builder()
+ .onComplete((p, text) -> {
+ InventoryUtils.openSearchDatabase(p, text);
+ return AnvilGUI.Response.text(Utils.colorize("Searching for &e" + text));
+ })
+ .title("Search Heads")
+ .text("Name...")
+ .plugin(HeadDB.getInstance())
+ .open(player);
+ return;
+ }
Category category = Category.getByName(name);