Whoops, actually commit shard changes to chest page

This commit is contained in:
Spencer 2018-01-05 20:41:39 -05:00 committed by Alexander Meech
parent c26831614c
commit 992a6aafe9
1 changed files with 20 additions and 13 deletions

View File

@ -23,15 +23,17 @@ import mineplex.staffServer.ui.SupportShop;
public class SupportChestPage extends SupportPage
{
private Map<TreasureType, Integer> _treasureRecieved;
private Map<TreasureType, Integer> _treasurePurchasedShop;
private Map<TreasureType, Integer> _treasurePurchasedShards;
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()));
_treasurePurchasedShop = new LinkedHashMap<>();
_treasurePurchasedShards = new LinkedHashMap<>();
_multiPageManager = new MultiPageManager<>(this, this::getTypesList, this::buildTreasure);
processReceivedTreasures();
@ -60,31 +62,36 @@ public class SupportChestPage extends SupportPage
treasureNameToType.put(type.getItemName(), type);
}
Map<String, Integer> ownership = getPackageOwnership(new LinkedList<>(treasureNameToType.keySet()));
Map<String, Integer> shopPurchases = getPackageOwnership(new LinkedList<>(treasureNameToType.keySet()));
Map<String, Integer> shardPurchases = getPackageOwnership(new LinkedList<>(treasureNameToType.keySet()), (transactionToken) -> transactionToken.Coins != 0);
ownership.forEach((treasureName, count) -> {
_treasureRecieved.put(treasureNameToType.get(treasureName), count);
});
shopPurchases.forEach((treasureName, count) -> _treasurePurchasedShop.put(treasureNameToType.get(treasureName), count));
shardPurchases.forEach((treasureName, count) -> _treasurePurchasedShards.put(treasureNameToType.get(treasureName), count));
}
private void buildTreasure(TreasureType type, int slot)
{
int count = _treasureRecieved.computeIfAbsent(type, t -> 0);
int shopCount = _treasurePurchasedShop.computeIfAbsent(type, t -> 0);
int shardCount = _treasurePurchasedShards.computeIfAbsent(type, t -> 0);
ItemStack item = getTreasureItem(type, Arrays.asList(
C.cYellow + _target.getName() + C.mBody + " has received " + C.cYellow + count,
C.cYellow + type.getItemName() + C.mBody + ".",
C.Reset + "Received from:",
C.cGray + "Shop: " + C.cYellow + shopCount,
C.cGray + "Shards: " + C.cYellow + shardCount,
"",
C.cGreen + "Click to give chests of this type"));
C.cGreen + "Click to give chests",
C.cGreen + "of this type"));
item.setAmount(Math.min(count, 64));
item.setAmount(1);
addButton(slot, item, (p, c)-> getShop().openPageForPlayer(getPlayer(), new SupportGiveChestPage(getPlugin(), getShop(), getPlayer(), _target, this, type)));
}
private LinkedList<TreasureType> getTypesList()
{
return _treasureRecieved.keySet().stream().sorted(Comparator.comparingInt(Enum::ordinal)).collect(Collectors.toCollection(LinkedList::new));
return Arrays.stream(TreasureType.values())
.filter(treasureType -> _treasurePurchasedShards.containsKey(treasureType) || _treasurePurchasedShop.containsKey(treasureType))
.collect(Collectors.toCollection(LinkedList::new));
}
@Override