Update PPC button to reflect new claiming style
This commit is contained in:
parent
20c37bf3d6
commit
bd90c465dd
@ -3,7 +3,13 @@ package mineplex.core.bonuses.gui.buttons;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -60,7 +66,7 @@ public class PowerPlayClubButton implements GuiItem
|
||||
{
|
||||
_player.closeInventory();
|
||||
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository);
|
||||
PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,21 +92,25 @@ public class PowerPlayClubButton implements GuiItem
|
||||
{
|
||||
final Material material;
|
||||
final String itemName;
|
||||
final List<String> lore;
|
||||
final List<String> lore = new ArrayList<>();
|
||||
|
||||
|
||||
PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player);
|
||||
Optional<LocalDate> maybeNextClaimDate = cached.getNextClaimDate();
|
||||
Set<YearMonth> unclaimed = cached.getUnclaimedMonths();
|
||||
|
||||
if (!cached.getUsableCosmeticMonths().isEmpty())
|
||||
{
|
||||
lore.addAll(buildCosmeticsLore(cached.getUsableCosmeticMonths()));
|
||||
}
|
||||
|
||||
if (!unclaimed.isEmpty())
|
||||
{
|
||||
// Player has unclaimed rewards, even if s/he's not currently subscribed
|
||||
material = Material.GOLD_INGOT;
|
||||
itemName = C.cGreenB + "Power Play Club";
|
||||
|
||||
lore = buildLore(unclaimed);
|
||||
lore.add(" ");
|
||||
lore.addAll(buildOtherRewardsLore(unclaimed.size()));
|
||||
lore.add(C.cGold + "Click to claim!");
|
||||
|
||||
} else if (maybeNextClaimDate.isPresent()) // Player is still subscribed, and has claimed everything so far
|
||||
@ -110,9 +120,9 @@ public class PowerPlayClubButton implements GuiItem
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRedB + "Power Play Club";
|
||||
|
||||
lore = new ArrayList<>();
|
||||
lore.add(C.cWhite + "Come back on " + C.cGreen + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth());
|
||||
lore.add(C.cWhite + "for your next reward!");
|
||||
lore.add(C.cYellow + "Come back " + C.cGreen + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth());
|
||||
lore.add(C.cWhite + " " + PowerPlayClubRewards.AMPLIFIERS_PER_MONTH + " Game Amplifier");
|
||||
lore.add(C.cWhite + " " + PowerPlayClubRewards.CHESTS_PER_MONTH + " Omega Chest");
|
||||
|
||||
} else
|
||||
{
|
||||
@ -120,8 +130,10 @@ public class PowerPlayClubButton implements GuiItem
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRedB + "Power Play Club";
|
||||
|
||||
lore = buildLore(Collections.singleton(YearMonth.now()));
|
||||
lore.add(C.cYellow + YearMonth.now().getMonth().getDisplayName(TextStyle.FULL, Locale.US) + "'s Cosmetic");
|
||||
lore.add(C.cWhite + " " + PowerPlayClubRewards.rewards().get(YearMonth.now()).getPrize());
|
||||
lore.add(" ");
|
||||
lore.addAll(buildOtherRewardsLore(1));
|
||||
lore.add(C.cRed + "Get Power Play Club months at");
|
||||
lore.add(C.cAqua + "mineplex.com/shop");
|
||||
}
|
||||
@ -129,17 +141,29 @@ public class PowerPlayClubButton implements GuiItem
|
||||
_item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false);
|
||||
}
|
||||
|
||||
private List<String> buildLore(Set<YearMonth> unclaimed)
|
||||
private List<String> buildCosmeticsLore(Set<YearMonth> cosmeticsMonths)
|
||||
{
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(C.cYellow + "Rewards");
|
||||
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier");
|
||||
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest");
|
||||
lore.add(C.cYellow + "Unlocked cosmetics");
|
||||
PowerPlayClubRewards.rewards().entrySet().stream()
|
||||
.filter(entry -> cosmeticsMonths.contains(entry.getKey()))
|
||||
.sorted(Comparator.comparing(Map.Entry::getKey))
|
||||
.forEach(entry ->
|
||||
{
|
||||
YearMonth yearMonth = entry.getKey();
|
||||
lore.add(C.cWhite + " " + entry.getValue().getPrize() + " " + C.cGold + yearMonth.getMonth().getDisplayName(TextStyle.SHORT, Locale.US) + " " + yearMonth.getYear());
|
||||
});
|
||||
lore.add(" ");
|
||||
return lore;
|
||||
}
|
||||
|
||||
PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize ->
|
||||
{
|
||||
lore.add(" " + C.cWhite + prize.getPrize());
|
||||
});
|
||||
private List<String> buildOtherRewardsLore(int unclaimed)
|
||||
{
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(C.cYellow + "Other Rewards");
|
||||
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed) + " Game Amplifier");
|
||||
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed) + " Omega Chest");
|
||||
lore.add(" ");
|
||||
return lore;
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,13 @@ public class PowerPlayClubRewards
|
||||
return months.stream().sorted().map(rewards::get).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Map<YearMonth, PowerPlayClubItem> rewards()
|
||||
{
|
||||
return rewards;
|
||||
}
|
||||
|
||||
public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo)
|
||||
|
||||
public static void giveAllItems(Player player, InventoryManager inventoryManager, PowerPlayClubRepository repo)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
|
||||
|
||||
@ -70,18 +75,7 @@ public class PowerPlayClubRewards
|
||||
}
|
||||
|
||||
PowerPlayData cached = repo.getCachedData(player);
|
||||
List<PowerPlayClubItem> items = rewardsForMonths(cached.getUnclaimedMonths());
|
||||
|
||||
|
||||
// Give normal power play items
|
||||
items.forEach(item ->
|
||||
{
|
||||
donationManager.PurchaseUnknownSalesPackage(null, player.getName(),
|
||||
donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(),
|
||||
GlobalCurrency.TREASURE_SHARD, 0, true);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received the " +
|
||||
F.elem(item.getPrize()) + "."));
|
||||
});
|
||||
int unclaimed = cached.getUnclaimedMonths().size();
|
||||
|
||||
// Give amplifiers and chests
|
||||
Item gameAmplifier = inventoryManager.getItem("Game Booster");
|
||||
@ -91,8 +85,8 @@ public class PowerPlayClubRewards
|
||||
}
|
||||
else
|
||||
{
|
||||
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size());
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + "."));
|
||||
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * unclaimed);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * unclaimed) + "x " + F.elem("Game Amplifier") + "."));
|
||||
}
|
||||
Item omegaChest = inventoryManager.getItem("Omega Chest");
|
||||
if (omegaChest == null)
|
||||
@ -101,8 +95,8 @@ public class PowerPlayClubRewards
|
||||
}
|
||||
else
|
||||
{
|
||||
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size());
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + "."));
|
||||
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * unclaimed);
|
||||
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * unclaimed) + "x " + F.elem("Omega Chest") + "."));
|
||||
}
|
||||
|
||||
// Refresh Power Play data on the server
|
||||
|
@ -60,6 +60,7 @@ public class PowerPlayData
|
||||
nextClaimDate = Optional.of(claimDates.get(claimDates.size() - 1))
|
||||
.map(date -> date.plusMonths(1))
|
||||
.filter(date -> date.isAfter(LocalDate.now())); // and make sure it's after today
|
||||
nextClaimDate.ifPresent(claimDates::add);
|
||||
}
|
||||
|
||||
// Determine the months whose cosmetics can be used by this player
|
||||
|
Loading…
Reference in New Issue
Block a user