Make RankBonusPage work

This commit is contained in:
Spencer 2018-01-04 22:15:12 -05:00 committed by Alexander Meech
parent 8820e33d09
commit 100df70157

View File

@ -1,17 +1,57 @@
package mineplex.staffServer.ui.rank;
import java.text.SimpleDateFormat;
import java.util.Calendar;
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.shop.item.ShopItem;
import mineplex.core.shop.page.MultiPageManager;
import mineplex.core.treasure.types.TreasureType;
import mineplex.database.tables.BonusLog;
import mineplex.staffServer.customerSupport.CustomerSupport;
import mineplex.staffServer.repository.BonusEntry;
import mineplex.staffServer.ui.SupportPage;
import mineplex.staffServer.ui.SupportShop;
public class SupportRankBonusPage extends SupportPage
{
public SupportRankBonusPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage, String name)
private MultiPageManager<BonusEntry> _multiPageManager;
public SupportRankBonusPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage)
{
super(plugin, shop, player, target, previousPage, "Rank Bonus");
getBonusLog().sort((a, b) -> Long.compare(b.getCalendar().getTimeInMillis(), a.getCalendar().getTimeInMillis()));
_multiPageManager = new MultiPageManager<>(
this,
this::getBonusLog,
(Pair<BonusEntry, Integer> pair) -> this.buildEntry(pair.getLeft(), pair.getRight())
);
buildPage();
}
private List<BonusEntry> getBonusLog()
{
return getShop().getBonusLog(_target.getAccountId());
}
private void buildEntry(BonusEntry entry, int slot)
{
addItem(slot, new ShopItem(Material.BOOK, new SimpleDateFormat("MMMM").format(entry.getCalendar().getTime()), new String[] {
"",
C.cGray + "Time: " + C.cYellow + new SimpleDateFormat("MMMM dd YYYY, KK:mm aa").format(entry.getCalendar().getTime()),
C.cGray + "Item Received: " + C.cYellow + entry.getItemName(),
C.cGray + "Amount Received: " + C.cYellow + entry.getItemCount()
}, entry.getCalendar().get(Calendar.MONTH) + 1, false, true));
}
@Override
@ -19,6 +59,6 @@ public class SupportRankBonusPage extends SupportPage
{
super.buildPage();
_multiPageManager.buildPage();
}
}