diff --git a/src/main/java/com/songoda/epicheads/command/commands/CommandAdd.java b/src/main/java/com/songoda/epicheads/command/commands/CommandAdd.java index 0ba5ce2..09ecbe3 100644 --- a/src/main/java/com/songoda/epicheads/command/commands/CommandAdd.java +++ b/src/main/java/com/songoda/epicheads/command/commands/CommandAdd.java @@ -36,6 +36,7 @@ public class CommandAdd extends AbstractCommand { Category category = categories.isEmpty() ? new Category(categoryStr) : categories.get(0); headManager.addLocalHead(new Head(headManager.getNextLocalId(), name, url, category, null, (byte)0)); + sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.add.success", name)); if (categories.isEmpty()) { instance.reload(); diff --git a/src/main/java/com/songoda/epicheads/gui/GUIOverview.java b/src/main/java/com/songoda/epicheads/gui/GUIOverview.java index 346eb5b..f0e97fe 100644 --- a/src/main/java/com/songoda/epicheads/gui/GUIOverview.java +++ b/src/main/java/com/songoda/epicheads/gui/GUIOverview.java @@ -14,10 +14,12 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.stream.Collectors; public class GUIOverview extends AbstractGUI { private final EpicHeads plugin; + private int page = 0; public GUIOverview(EpicHeads plugin, Player player) { super(player); @@ -28,6 +30,9 @@ public class GUIOverview extends AbstractGUI { @Override protected void constructGUI() { + inventory.clear(); + resetClickables(); + registerClickables(); ArrayList lore = new ArrayList<>(); String[] parts = plugin.getLocale().getMessage("gui.overview.favoriteslore").split("\\|"); @@ -58,12 +63,32 @@ public class GUIOverview extends AbstractGUI { inventory.setItem(38, Methods.getBackgroundGlass(false)); inventory.setItem(42, Methods.getBackgroundGlass(false)); - List tags = plugin.getHeadManager().getCategories(); + int numTemplates = plugin.getHeadManager().getCategories().size(); + int maxPage = (int) Math.floor(numTemplates / 21.0); + + List categories = plugin.getHeadManager().getCategories().stream().skip(page * 21).limit(21) + .collect(Collectors.toList()); + + if (page != 0) { + createButton(37, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous")); + registerClickable(37, ((player1, inventory1, cursor, slot, type) -> { + page --; + constructGUI(); + })); + } + + if (page != maxPage) { + createButton(43, Material.ARROW, plugin.getLocale().getMessage("gui.general.next")); + registerClickable(43, ((player1, inventory1, cursor, slot, type) -> { + page ++; + constructGUI(); + })); + } int add = 0; - for (int i = 0; i < tags.size(); i++) { + for (int i = 0; i < categories.size(); i++) { if (i + add == 7 || i + add == 16) add = add + 2; - Category category = plugin.getHeadManager().getCategories().get(i); + Category category = plugin.getHeadManager().getCategories().get((page * 21) + i); List heads = category.isLatestPack() ? plugin.getHeadManager().getLatestPack() : plugin.getHeadManager().getHeadsByCategory(category); diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang index 503f6d1..d92f02a 100644 --- a/src/main/resources/en_US.lang +++ b/src/main/resources/en_US.lang @@ -19,6 +19,9 @@ gui.heads.refine = "&9Refine Search" gui.heads.search = "&9Create Search" gui.heads.categories = "&cBack To Categories" +gui.general.previous = "&6Previous Page" +gui.general.next = "&6Next Page" + gui.overview.title = "EpicHeads (%count% heads)" gui.overview.search = "&a&lSearch" gui.overview.headname = "&c&l%name%"