Re-implement a reward for unknown sales packages
This commit is contained in:
parent
c56dfee78d
commit
9be986c2d3
@ -0,0 +1,76 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public class UnknownPackageReward extends Reward
|
||||
{
|
||||
|
||||
private final String _header, _displayName, _package;
|
||||
private final String[] _alternativePackages;
|
||||
private final ItemStack _itemStack;
|
||||
|
||||
public UnknownPackageReward(String header, String displayName, String package, ItemStack item, RewardRarity rarity, int shardValue)
|
||||
{
|
||||
super(rarity, shardValue);
|
||||
|
||||
_header = header;
|
||||
_displayName = displayName;
|
||||
_package = package;
|
||||
_itemStack = item;
|
||||
_alternativePackages = new String[]{};
|
||||
}
|
||||
|
||||
public UnknownPackageReward(String header, String displayName, String package, ItemStack item, RewardRarity rarity, int shardValue, String... alternativePackages)
|
||||
{
|
||||
super(rarity, shardValue);
|
||||
|
||||
_header = header;
|
||||
_displayName = displayName;
|
||||
_package = package;
|
||||
_itemStack = item;
|
||||
_alternativePackages = _alternativePackages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
DONATION_MANAGER.purchaseUnknownSalesPackage(player, _packageName, GlobalCurrency.TREASURE_SHARD, 0, true, null);
|
||||
|
||||
return getFakeRewardData(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _displayName, _itemStack, getRarity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
if (DONATION_MANAGER.Get(player) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (DONATION_MANAGER.Get(player).ownsUnknownSalesPackage(_packageName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (String alternative : _alternativePackages)
|
||||
{
|
||||
if (DONATION_MANAGER.Get(player).ownsUnknownSalesPackage(alternative))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user