Add SupportHomePage + reflective buildPageButton method
This commit is contained in:
parent
18ad75582a
commit
248472a5d3
|
@ -30,7 +30,7 @@ public class SupportChestPage extends SupportPage
|
|||
|
||||
private Map<TreasureType, Integer> _treasureRecieved;
|
||||
|
||||
public SupportChestPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportHomePage homePage)
|
||||
public SupportChestPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage homePage)
|
||||
{
|
||||
super(plugin, shop, player, target, homePage, "Chests");
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package mineplex.staffServer.ui;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.staffServer.customerSupport.CustomerSupport;
|
||||
|
||||
public class SupportHomePage extends SupportPage
|
||||
{
|
||||
public SupportHomePage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target)
|
||||
{
|
||||
super(plugin, shop, player, target, null);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void buildPageButton(int slot,ShopItem shopItem, Class<? extends SupportPage> clazz)
|
||||
{
|
||||
Constructor pageConstructor;
|
||||
try
|
||||
{
|
||||
pageConstructor = clazz.getConstructor(CustomerSupport.class, SupportShop.class, Player.class, CoreClient.class, SupportPage.class);
|
||||
} catch (NoSuchMethodException e)
|
||||
{
|
||||
System.out.println("Could not get page constructor:");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
addButton(slot, shopItem, (p, c) -> {
|
||||
try
|
||||
{
|
||||
getShop().openPageForPlayer(getPlayer(), (SupportPage) pageConstructor.newInstance(getPlugin(), getShop(), getPlayer(), _target, this));
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
System.out.println("Could not instantiate page:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
super.buildPage();
|
||||
|
||||
buildPageButton(getSlotIndex(1, 1), new ShopItem(Material.CHEST, "Chests", new String[] {
|
||||
C.mBody + "Click to view or add",
|
||||
C.mBody + "chests for " + C.cYellow + _target.getName()
|
||||
}, 1, false, true), SupportChestPage.class);
|
||||
|
||||
buildPageButton(getSlotIndex(1, 3), new ShopItem(Material.EMERALD, "Currency", new String[] {
|
||||
C.mBody + "Click to add gems or",
|
||||
C.mBody + "shards for " + C.cYellow + _target.getName()
|
||||
}, 1, false, true), SupportCurrencyPage.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue