Implement Thankful chest, patch Trick or Treat chest showing as purchasable, make SubscriptionDuration enum public and static, and create a Power Play Reward

This commit is contained in:
AlexTheCoder 2016-11-22 19:19:07 -05:00 committed by Shaun Bennett
parent ca68b59ba2
commit cfa5512141
11 changed files with 157 additions and 11 deletions

View File

@ -138,7 +138,7 @@ public class PowerPlayData
}
}
enum SubscriptionDuration
public static enum SubscriptionDuration
{
MONTH, YEAR
}

View File

@ -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;

View File

@ -58,6 +58,7 @@ public class RewardPool
OMEGA(false),
HAUNTED(false),
TRICK_OR_TREAT(false),
THANKFUL(false),
CARL_SPINNER(true);
private boolean _useDuplicates;

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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))

View File

@ -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<TreasureManager, TreasureShop>
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<String> shardLore = new ArrayList<>();
shardLore.add(" ");
@ -227,9 +229,44 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
}
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<String> 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<TreasureManager, TreasureShop>
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);