diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/packages/SupportPackagePage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/packages/SupportPackagePage.java new file mode 100644 index 000000000..dfd9f0106 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/packages/SupportPackagePage.java @@ -0,0 +1,93 @@ +package mineplex.staffServer.ui.packages; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClient; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.MultiPageManager; +import mineplex.staffServer.customerSupport.CustomerSupport; +import mineplex.staffServer.ui.SupportPage; +import mineplex.staffServer.ui.SupportShop; + +public class SupportPackagePage extends SupportPage +{ + private MultiPageManager>> _multiPageManager; + + // Add items to this list for them to display on the page. + protected List>> _packageList; + + // Add package names to this list if they should be given + // as items when the above package is clicked. + protected List _itemPackages; + + public SupportPackagePage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage, String name) + { + super(plugin, shop, player, target, previousPage, name); + + _multiPageManager = new MultiPageManager<>(this, this::getPackageList, this::addPackage); + _packageList = new LinkedList<>(); + _itemPackages = new ArrayList<>(); + } + + protected Pair> getPackagePair(ItemBuilder builder, String name, String... packages) + { + builder.setTitle(C.cGreenB + name) + .addLore(C.mBody + "Click to give the") + .addLore(C.mBody + "following items:"); + + for (String packageName : packages) + { + builder.addLore(" " + C.cYellow + packageName); + } + + return Pair.create(builder.build(), Arrays.asList(packages)); + } + + protected Pair> getPackagePair(Material mat, String name, String... packages) + { + return getPackagePair(new ItemBuilder(mat), name, packages); + } + + protected Pair> getPackagePair(Material mat, String name) + { + return getPackagePair(mat, name, name); + } + + protected Pair> getPackagePair(ItemBuilder builder, String name) + { + return getPackagePair(builder, name, name); + } + + private void addPackage(Pair> item, int slot) + { + addButton(slot, item.getLeft(), (p, c) -> + { + for (String packageName : item.getRight()) + { + giveUnknownSalesPackage(packageName, _itemPackages.contains(packageName)); + } + }); + } + + private List>> getPackageList() + { + return _packageList; + } + + @Override + protected void buildPage() + { + super.buildPage(); + + _multiPageManager.buildPage(); + } +}