Add Titles to chests

This commit is contained in:
cnr 2017-03-16 00:14:02 -05:00
parent 94009cd652
commit 78b6846cf6
3 changed files with 134 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.banner.CountryFlag;
@ -163,9 +164,11 @@ import mineplex.core.reward.rewards.PowerPlayReward;
import mineplex.core.reward.rewards.RankReward;
import mineplex.core.reward.rewards.RuneAmplifierReward;
import mineplex.core.reward.rewards.SpinTicketReward;
import mineplex.core.reward.rewards.TitleReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import mineplex.core.stats.StatsManager;
import mineplex.core.titles.tracks.TrackManager;
import mineplex.core.treasure.TreasureType;
public class RewardManager
@ -173,6 +176,7 @@ public class RewardManager
private EnumMap<RewardPool.Type, RewardPool> _rewardPools;
private Random _random;
private final TrackManager _trackManager = Managers.require(TrackManager.class);
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private InventoryManager _inventoryManager;
@ -420,6 +424,37 @@ public class RewardManager
addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.P90_Asiimov, rarity, 100, 1000);
addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.SG553_Pulse, rarity, 100, 1000);
// Titles
addTitle(Type.NORMAL, "shrug", rarity, 10, 500);
addTitle(Type.NORMAL, "tableflip", rarity, 10, 500);
addTitle(Type.NORMAL, "tablerespecter", rarity, 15, 500);
addTitle(Type.NORMAL, "tableflip-disgusted", rarity, 15, 500);
addTitle(Type.NORMAL, "tableflip-enraged", rarity, 15, 500);
addTitle(Type.NORMAL, "tableflip-riot", rarity, 10, 500);
addTitle(Type.NORMAL, "teddy-bear", rarity, 10, 500);
addTitle(Type.NORMAL, "disgust", rarity, 10, 500);
addTitle(Type.NORMAL, "old-man", rarity, 5, 500);
addTitle(Type.NORMAL, "jake", rarity, 5, 500);
addTitle(Type.NORMAL, "finn", rarity, 5, 500);
addTitle(Type.NORMAL, "finn-and-jake", rarity, 5, 500);
addTitle(Type.NORMAL, "boxer", rarity, 5, 500);
addTitle(Type.NORMAL, "zoidberg", rarity, 5, 500);
addTitle(Type.OMEGA, "shrug", rarity, 10, 500);
addTitle(Type.OMEGA, "tableflip", rarity, 10, 500);
addTitle(Type.OMEGA, "tablerespecter", rarity, 15, 500);
addTitle(Type.OMEGA, "tableflip-disgusted", rarity, 15, 500);
addTitle(Type.OMEGA, "tableflip-enraged", rarity, 15, 500);
addTitle(Type.OMEGA, "tableflip-riot", rarity, 10, 500);
addTitle(Type.OMEGA, "teddy-bear", rarity, 10, 500);
addTitle(Type.OMEGA, "disgust", rarity, 10, 500);
addTitle(Type.OMEGA, "old-man", rarity, 5, 500);
addTitle(Type.OMEGA, "jake", rarity, 5, 500);
addTitle(Type.OMEGA, "finn", rarity, 5, 500);
addTitle(Type.OMEGA, "finn-and-jake", rarity, 5, 500);
addTitle(Type.OMEGA, "boxer", rarity, 5, 500);
addTitle(Type.OMEGA, "zoidberg", rarity, 5, 500);
// VALENTINES
//Hats
@ -635,6 +670,38 @@ public class RewardManager
addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.XM1014_Pig_Gun, rarity, 10, 7500);
addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.M4A4_Enderman, rarity, 10, 7500);
// Titles
addTitle(Type.NORMAL, "ayyye", rarity, 25, 500);
addTitle(Type.NORMAL, "ameno", rarity, 15, 5000);
addTitle(Type.NORMAL, "magician", rarity, 25, 5000);
addTitle(Type.NORMAL, "fireball", rarity, 75, 5000);
addTitle(Type.NORMAL, "magic-missile", rarity, 75, 5000);
addTitle(Type.NORMAL, "pewpewpew", rarity, 75, 5000);
addTitle(Type.NORMAL, "stardust", rarity, 60, 5000);
addTitle(Type.NORMAL, "blow-a-kiss", rarity, 60, 5000);
addTitle(Type.NORMAL, "cool-guy", rarity, 60, 5000);
addTitle(Type.NORMAL, "deal-with-it", rarity, 60, 5000);
addTitle(Type.NORMAL, "party-time", rarity, 55, 5000);
addTitle(Type.NORMAL, "lalala", rarity, 30, 5000);
addTitle(Type.NORMAL, "gotta-go", rarity, 30, 5000);
addTitle(Type.NORMAL, "whaaat", rarity, 30, 5000);
addTitle(Type.OMEGA, "ayyye", rarity, 25, 500);
addTitle(Type.OMEGA, "ameno", rarity, 15, 5000);
addTitle(Type.OMEGA, "magician", rarity, 25, 5000);
addTitle(Type.OMEGA, "fireball", rarity, 75, 5000);
addTitle(Type.OMEGA, "magic-missile", rarity, 75, 5000);
addTitle(Type.OMEGA, "pewpewpew", rarity, 75, 5000);
addTitle(Type.OMEGA, "stardust", rarity, 60, 5000);
addTitle(Type.OMEGA, "blow-a-kiss", rarity, 60, 5000);
addTitle(Type.OMEGA, "cool-guy", rarity, 60, 5000);
addTitle(Type.OMEGA, "deal-with-it", rarity, 60, 5000);
addTitle(Type.OMEGA, "party-time", rarity, 55, 5000);
addTitle(Type.OMEGA, "lalala", rarity, 30, 5000);
addTitle(Type.OMEGA, "gotta-go", rarity, 30, 5000);
addTitle(Type.OMEGA, "whaaat", rarity, 30, 5000);
//WINTER
//Arrow Trails
@ -874,6 +941,11 @@ public class RewardManager
return addGadget(type, gadget, gadget.getDisplayName() + " (Minestrike Weapon Skin)", rarity, weight, shards);
}
public void addTitle(Type type, String trackName, RewardRarity rarity, int weight, int shards)
{
addReward(type, new TitleReward(_trackManager.getTrackById(trackName), rarity, weight, shards));
}
public UnknownPackageReward addHat(Type type, HatType hatType, RewardRarity rarity, int weight)
{
return addHat(type, hatType, rarity, weight, getShards(rarity));

View File

@ -0,0 +1,49 @@
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackManager;
public class TitleReward extends Reward
{
private final ItemStack ITEM_STACK = new ItemStack(Material.BOOK);
private final TrackManager _trackManager = Managers.require(TrackManager.class);
private final Track _track;
public TitleReward(Track track, RewardRarity rarity, int weight, int shardValue)
{
super(rarity, weight, shardValue);
if (track == null)
{
throw new IllegalStateException();
}
_track = track;
}
@Override
protected RewardData giveRewardCustom(Player player, RewardType rewardType)
{
_trackManager.unlockTrack(player, _track);
return getFakeRewardData(player);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Title", getRarity().getColor() + _track.getLongName(), ITEM_STACK, getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return !_trackManager.hasTrack(player, _track);
}
}

View File

@ -108,7 +108,7 @@ public class TrackManager extends MiniPlugin
// registerTrack(track("unknown", "Unknown", "(◕‿◕✿)"));
registerTrack(track("fireball", "Fireball", "༼つಠ益ಠ༽つ ─=≡ΣO))"));
registerTrack(track("stardust", "Stardust", "(つ◕౪◕)つ━☆゚.*・。゚"));
registerTrack(track("magic-whistle", "Magic Whistle", "( °-°)シ ミ★ ミ☆"));
registerTrack(track("magic-missile", "Magic Missile", "( °-°)シ ミ★ ミ☆"));
registerTrack(track("blow-a-kiss", "Blowing a Kiss", "♡(´ε` )"));
registerTrack(track("pewpewpew", "PEWPEWPEW", "(☞^o^)☞"));
// registerTrack(track("pewpew", "pew pew", "(☞゚ヮ゚)☞"));
@ -162,11 +162,21 @@ public class TrackManager extends MiniPlugin
return new ArrayList<>(_trackById.values());
}
public void unlockTrack(String player, String track)
public boolean hasTrack(Player player, Track track)
{
return _inventoryManager.Get(player).getItemCount("track." + track.getId()) > 0;
}
public void unlockTrack(Player player, Track track)
{
unlockTrack(player, track, null);
}
public void unlockTrack(Player player, Track track, Consumer<TrackGiveResult> consumer)
{
unlockTrack(player.getName(), track.getId(), consumer);
}
public void unlockTrack(String player, String track, Consumer<TrackGiveResult> consumer)
{
_coreClientManager.getOrLoadClient(player, client ->