From cfa5512141eccdbd42a4932aff2e9f38e601db56 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 22 Nov 2016 19:19:07 -0500 Subject: [PATCH] Implement Thankful chest, patch Trick or Treat chest showing as purchasable, make SubscriptionDuration enum public and static, and create a Power Play Reward --- .../core/powerplayclub/PowerPlayData.java | 2 +- .../mineplex/core/reward/RewardManager.java | 23 ++++++- .../src/mineplex/core/reward/RewardPool.java | 1 + .../src/mineplex/core/reward/RewardType.java | 3 +- .../core/reward/rewards/PowerPlayReward.java | 68 +++++++++++++++++++ .../core/reward/rewards/RankReward.java | 2 +- .../mineplex/core/treasure/TreasureStyle.java | 8 ++- .../mineplex/core/treasure/TreasureType.java | 4 +- .../animation/ChestSpawnAnimation.java | 2 +- .../core/treasure/gui/BuyChestButton.java | 8 +++ .../core/treasure/gui/TreasurePage.java | 47 +++++++++++-- 11 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PowerPlayReward.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index 178916f39..b1f0c93c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -138,7 +138,7 @@ public class PowerPlayData } } - enum SubscriptionDuration + public static enum SubscriptionDuration { MONTH, YEAR } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index b5a0f5b35..8bd1ac1c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -130,11 +130,13 @@ import mineplex.core.mount.types.MountValentinesSheep; import mineplex.core.mount.types.MountZombie; import mineplex.core.pet.PetManager; import mineplex.core.pet.PetType; +import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration; import mineplex.core.reward.RewardPool.Type; import mineplex.core.reward.rewards.ChestReward; import mineplex.core.reward.rewards.GameAmplifierReward; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.reward.rewards.PetReward; +import mineplex.core.reward.rewards.PowerPlayReward; import mineplex.core.reward.rewards.RankReward; import mineplex.core.reward.rewards.RuneAmplifierReward; import mineplex.core.reward.rewards.SpinTicketReward; @@ -460,6 +462,13 @@ public class RewardManager addReward(Type.TRICK_OR_TREAT, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0)); + + //THANKFUL + addReward(Type.THANKFUL, new SpinTicketReward(_clientManager, 1, 3, rarity, 150, 0)); + addReward(Type.THANKFUL, new RuneAmplifierReward(_inventoryManager, 20, 1, 3, rarity, 120, 0)); + addReward(Type.THANKFUL, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); + addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0)); + addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0)); } public void addLegendary() @@ -618,6 +627,13 @@ public class RewardManager addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25); addPetReward(Type.TRICK_OR_TREAT, PetType.ZOMBIE, rarity, 10); addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5); + + //THANKFUL + addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0)); + addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0)); + addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0)); + addPetReward(Type.THANKFUL, PetType.VILLAGER, rarity, 10); + addPetReward(Type.THANKFUL, PetType.PIG_ZOMBIE, rarity, 10); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -907,10 +923,15 @@ public class RewardManager //Dont give Rank Upgrade if already has Titan if (rarity == RewardRarity.MYTHICAL) { - if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN)) + PowerPlayReward rew = new PowerPlayReward(_clientManager, SubscriptionDuration.MONTH, rarity, 0, 0); + if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN)) { return new RankReward(_clientManager, 0, 0, rarity); } + else if (canGiveMythical && (type == RewardType.THANKFUL_CHEST) && rew.canGiveReward(player)) + { + return rew; + } else if (!canGiveMythical || _clientManager.Get(player).GetRank().has(Rank.LEGEND)) { rarity = RewardRarity.LEGENDARY; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java index 086909b66..54568ea23 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java @@ -58,6 +58,7 @@ public class RewardPool OMEGA(false), HAUNTED(false), TRICK_OR_TREAT(false), + THANKFUL(false), CARL_SPINNER(true); private boolean _useDuplicates; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 3d673f360..eb59b886f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -16,6 +16,7 @@ public enum RewardType HAUNTED_CHEST( 0, 5, 18, 0), OMEGA_CHEST( 0, 32, 16, 2), TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0), + THANKFUL_CHEST( 0.1, 2, 16, 0), VALENTINES_GIFT( 0, 7, 20, 20), SPINNER_FILLER( 0.1, 1, 4, 20), @@ -44,7 +45,7 @@ public enum RewardType else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY; else if (rand <= _rareChance) rarity = RewardRarity.RARE; else if (rand <= _uncommonChance || requiresUncommon) rarity = RewardRarity.UNCOMMON; - + return rarity; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PowerPlayReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PowerPlayReward.java new file mode 100644 index 000000000..ac86ed21f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PowerPlayReward.java @@ -0,0 +1,68 @@ +package mineplex.core.reward.rewards; + +import java.time.LocalDate; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.UtilServer; +import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; + +public class PowerPlayReward extends Reward +{ + private CoreClientManager _clientManager; + private SubscriptionDuration _duration; + + public PowerPlayReward(CoreClientManager clientManager, SubscriptionDuration duration, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + + _clientManager = clientManager; + _duration = duration; + } + + @Override + public RewardData giveRewardCustom(Player player, RewardType rewardType) + { + if (_clientManager.getAccountId(player) == -1) + { + return getFakeRewardData(player); + } + + Managers.get(BonusManager.class).getPowerPlayClubRepository().addSubscription(_clientManager.getAccountId(player), LocalDate.now(), _duration.toString().toLowerCase()); + player.setMetadata("GIVEN-PPC-REWARD", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); + + return new RewardData(getRarity().getDarkColor() + "Power Play Subscription", getRarity().getColor() + "1 " + _duration.toString().toLowerCase() + " Power Play Club Subscription", new ItemStack(Material.FIREBALL), getRarity()); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Power Play Subscription", getRarity().getColor() + "Power Play Subscription", new ItemStack(Material.FIREBALL), getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return !(Managers.get(BonusManager.class).getPowerPlayClubRepository().getCachedData(player).isSubscribed() || player.hasMetadata("GIVEN-PPC-REWARD")); + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof PowerPlayReward) + { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index c42b26dd1..339fc0bf5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -34,7 +34,7 @@ public class RankReward extends Reward if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; - else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; + else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent rank = Rank.TITAN; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java index 81c1af8d1..8c9c2f69d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -62,7 +62,13 @@ public enum TreasureStyle ParticleType.RED_DUST, Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_THROW - ); + ), + THANKFUL( + ParticleType.HAPPY_VILLAGER, + ParticleType.HAPPY_VILLAGER, + ParticleType.HAPPY_VILLAGER, + Sound.CHICKEN_IDLE, + Sound.CHICKEN_EGG_POP); private ParticleType _secondaryParticle; private ParticleType _chestSpawnParticle; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index 80cfff9fd..4e3dc49eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -24,7 +24,9 @@ public enum TreasureType HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, true, 35000), - TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000); + TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000), + + THANKFUL(C.cGold + "Thankful Treasure", "Thankful Chest", "ThankFul", RewardType.THANKFUL_CHEST, Material.CHEST, TreasureStyle.THANKFUL, RewardPool.Type.THANKFUL, true, 20000); private final String _name; private final RewardType _rewardType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index f581e576c..7c81c9245 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -155,7 +155,7 @@ public class ChestSpawnAnimation extends Animation UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, _centerLocation.clone().add(0, 5, 0), spread, 0.1f, spread, 0, 30, ViewDist.NORMAL, UtilServer.getPlayers()); } - else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED) + else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED || getTreasure().getTreasureType() == TreasureType.THANKFUL) { Location loc = _centerLocation.clone(); loc.add(Vector.getRandom().subtract(Vector.getRandom()).multiply(0.5)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index a0ee33418..5e1ad96e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -57,6 +57,14 @@ public class BuyChestButton implements IButton return; } } + if (_chestType == TreasureType.THANKFUL) + { + if (!new File("../../update/files/EnableThankful.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + } if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED) { if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index a4124c3a9..3c123eb71 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -1,5 +1,6 @@ package mineplex.core.treasure.gui; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -63,6 +64,7 @@ public class TreasurePage extends ShopPageBase int omegaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OMEGA.getItemName()); int hauntedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.HAUNTED.getItemName()); int trickCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.TRICK_OR_TREAT.getItemName()); + int thankCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.THANKFUL.getItemName()); List shardLore = new ArrayList<>(); shardLore.add(" "); @@ -227,9 +229,44 @@ public class TreasurePage extends ShopPageBase } else { - trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); - trickLore.add(" "); - hauntedLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + boolean available = new File("../../update/files/EnableTrickOrTreat.dat").exists(); + if (!available) + { + trickLore.add(ChatColor.RESET + "This chest is currently unavailable"); + } + else + { + trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); + trickLore.add(" "); + trickLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } + } + + List thankLore = Lists.newArrayList(); + thankLore.add(" "); + thankLore.add(F.value("Thankful Chests Owned", "" + thankCount)); + thankLore.add(" "); + thankLore.add(C.cGray + "The Thankful Chest is our way of"); + thankLore.add(C.cGray + "showing thanks to you, containing items from Rank Upgrades to"); + thankLore.add(C.cGray + "Power Play Club Subscriptions, among other things!"); + thankLore.add(" "); + if (thankCount > 0) + { + thankLore.add(ChatColor.RESET + C.cGreen + "Click to Open!"); + } + else + { + boolean available = new File("../../update/files/EnableThankful.dat").exists(); + if (!available) + { + thankLore.add(ChatColor.RESET + "This chest is currently unavailable"); + } + else + { + thankLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); + thankLore.add(" "); + thankLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } } ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); @@ -242,10 +279,12 @@ public class TreasurePage extends ShopPageBase ItemStack omega = SkinData.OMEGA_CHEST.getSkull(C.cAquaB + "Omega Treasure", omegaLore); ItemStack haunted = SkinData.HAUNTED_CHEST.getSkull(C.cGoldB + "Haunted Treasure", hauntedLore); ItemStack trick = new ShopItem(Material.SKULL_ITEM, C.cGoldB + "Trick or Treat Treasure", trickLore.toArray(new String[0]), 0, false, false); + ItemStack thank = new ShopItem(Material.COOKED_CHICKEN, C.cGoldB + "Thankful Treasure", thankLore.toArray(new String[0]), 0, false, false); addItem(49, shards); - addChest(4, trick, TreasureType.TRICK_OR_TREAT, trickCount); + addChest(3, trick, TreasureType.TRICK_OR_TREAT, trickCount); + addChest(5, thank, TreasureType.THANKFUL, thankCount); addChest(10, christmas, TreasureType.CHRISTMAS, christmasCount); addChest(12, freedom, TreasureType.FREEDOM, freedomCount); addChest(14, haunted, TreasureType.HAUNTED, hauntedCount);