Add RankBonusPage to home, minor visual changes, use MultiPageManager in ChestPage

This commit is contained in:
Spencer 2018-01-04 22:15:42 -05:00 committed by Alexander Meech
parent 100df70157
commit b5ef5d9011
3 changed files with 25 additions and 50 deletions

View File

@ -91,7 +91,7 @@ public abstract class ShopPageBase<PluginType extends Lifetimed, ShopType extend
return slot >= (inventory.getSize() + 27) ? slot - (inventory.getSize() + 27) : slot - (inventory.getSize() - 9);
}
protected void addButton(int slot, ItemStack item, IButton button)
public void addButton(int slot, ItemStack item, IButton button)
{
if (button == null)
{

View File

@ -12,6 +12,7 @@ import mineplex.core.shop.item.ShopItem;
import mineplex.staffServer.customerSupport.CustomerSupport;
import mineplex.staffServer.ui.chest.SupportChestPage;
import mineplex.staffServer.ui.currency.SupportCurrencyPage;
import mineplex.staffServer.ui.rank.SupportRankBonusPage;
public class SupportHomePage extends SupportPage
{
@ -24,12 +25,12 @@ public class SupportHomePage extends SupportPage
private void buildUnavailableButton(int slot)
{
addItem(slot, new ShopItem(Material.BARRIER, "Unavailable", new String[] {
"Sorry, but this button is",
"not currently available.",
"",
"Please contact a developer",
"to get it fixed."
addItem(slot, new ShopItem(Material.BARRIER, C.cRedB + "Unavailable", new String[] {
C.cRed + "Sorry, but this button is",
C.cRed + "not currently available.",
C.cGray + " ",
C.cGray + "Please contact a developer",
C.cGray + "to get it fixed."
}, 1, true, true));
}
@ -77,10 +78,16 @@ public class SupportHomePage extends SupportPage
if (getShop().getBonusLog(_target.getAccountId()) != null)
{
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);
buildPageButton(getSlotIndex(1, 5), new ShopItem(Material.ENCHANTED_BOOK, "Rank Bonus", new String[] {
C.mBody + "Click to view rank",
C.mBody + "bonus log for " + C.cYellow + _target.getName()
}, 1, false, true), SupportRankBonusPage.class);
}
else
{
buildUnavailableButton(getSlotIndex(1, 5));
}
}
}

View File

@ -8,14 +8,14 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.MultiPageManager;
import mineplex.core.treasure.types.TreasureType;
import mineplex.staffServer.customerSupport.CustomerSupport;
import mineplex.staffServer.ui.SupportPage;
@ -23,16 +23,16 @@ import mineplex.staffServer.ui.SupportShop;
public class SupportChestPage extends SupportPage
{
private static final int ELEMENTS_PER_PAGE = 28;
private int _page;
private Map<TreasureType, Integer> _treasureRecieved;
private MultiPageManager<TreasureType> _multiPageManager;
public SupportChestPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage homePage)
{
super(plugin, shop, player, target, homePage, "Chests");
_treasureRecieved = new LinkedHashMap<>();
_multiPageManager = new MultiPageManager<>(this, this::getTypesList, (Pair<TreasureType, Integer> pair) -> this.buildTreasure(pair.getLeft(), pair.getRight()));
processReceivedTreasures();
buildPage();
@ -82,7 +82,7 @@ public class SupportChestPage extends SupportPage
addButton(slot, item, (p, c)-> getShop().openPageForPlayer(getPlayer(), new SupportGiveChestPage(getPlugin(), getShop(), getPlayer(), _target, this, type)));
}
private LinkedList<TreasureType> getTypesSet()
private LinkedList<TreasureType> getTypesList()
{
return _treasureRecieved.keySet().stream().sorted(Comparator.comparingInt(Enum::ordinal)).collect(Collectors.toCollection(LinkedList::new));
}
@ -92,38 +92,6 @@ public class SupportChestPage extends SupportPage
{
super.buildPage();
LinkedList<TreasureType> types = getTypesSet();
int slot = 10;
int startIndex = _page * ELEMENTS_PER_PAGE;
int endIndex = startIndex + ELEMENTS_PER_PAGE;
for (TreasureType type : types)
{
buildTreasure(type, slot);
if (++slot % 9 == 8)
{
slot += 2;
}
}
if (_page != 0)
{
addButton(45, new ShopItem(Material.ARROW, C.cGreen + "Previous Page", new String[0], 1, false), (player, clickType) ->
{
_page--;
refresh();
});
}
if (endIndex <= getTypesSet().size())
{
addButton(53, new ShopItem(Material.ARROW, C.cGreen + "Next Page", new String[0], 1, false), (player, clickType) ->
{
_page++;
refresh();
});
}
_multiPageManager.buildPage();
}
}