Add experience rewards to reward manager
This commit is contained in:
parent
6311ceaa0f
commit
be18dc1bf5
@ -18,11 +18,13 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.reward.rewards.CoinReward;
|
||||
import mineplex.core.reward.rewards.ExperienceReward;
|
||||
import mineplex.core.reward.rewards.GemReward;
|
||||
import mineplex.core.reward.rewards.InventoryReward;
|
||||
import mineplex.core.reward.rewards.PetReward;
|
||||
import mineplex.core.reward.rewards.RankReward;
|
||||
import mineplex.core.reward.rewards.UnknownPackageReward;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class RewardManager
|
||||
{
|
||||
@ -31,10 +33,10 @@ public class RewardManager
|
||||
private Random _random;
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
|
||||
private boolean _doubleGadgetValue;
|
||||
|
||||
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager,
|
||||
public RewardManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager,
|
||||
int commonValueMin, int commonValueMax,
|
||||
int uncommonValueMin, int uncommonValueMax,
|
||||
int rareValueMin, int rareValueMax,
|
||||
@ -51,19 +53,20 @@ public class RewardManager
|
||||
}
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
|
||||
_doubleGadgetValue = doubleGadgetValue;
|
||||
|
||||
addGame(donationManager, inventoryManager, petManager);
|
||||
addGame(donationManager, inventoryManager, petManager, statsManager);
|
||||
addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax);
|
||||
addUncommon(donationManager, inventoryManager, petManager, uncommonValueMin, uncommonValueMax);
|
||||
addRare(donationManager, inventoryManager, petManager, rareValueMin, rareValueMax);
|
||||
addLegendary(donationManager, inventoryManager, petManager, legendValueMin, legendValueMax);
|
||||
}
|
||||
|
||||
public void addGame(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager)
|
||||
public void addGame(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager)
|
||||
{
|
||||
addReward(new GemReward(donationManager, 100, 500, 1, RewardRarity.GAME));
|
||||
addReward(new GemReward(donationManager, 100, 500, 100, RewardRarity.GAME));
|
||||
addReward(new ExperienceReward(statsManager, 100, 5000, 100, RewardRarity.GAME));
|
||||
}
|
||||
|
||||
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
|
@ -0,0 +1,52 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class ExperienceReward extends Reward
|
||||
{
|
||||
private StatsManager _statsManager;
|
||||
private Random _random;
|
||||
private int _minExperience;
|
||||
private int _maxExperience;
|
||||
|
||||
public ExperienceReward(StatsManager statsManager, int minExperience, int maxExperience, int weight, RewardRarity rarity)
|
||||
{
|
||||
super(rarity, weight);
|
||||
|
||||
_statsManager = statsManager;
|
||||
_random = new Random();
|
||||
_minExperience = minExperience;
|
||||
_maxExperience = maxExperience;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience;
|
||||
|
||||
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
|
||||
|
||||
return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData getFakeRewardData(Player player)
|
||||
{
|
||||
return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -179,7 +179,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
||||
|
||||
RewardManager rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager,
|
||||
RewardManager rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager,
|
||||
100, 250,
|
||||
500, 1000,
|
||||
4000, 6000,
|
||||
|
@ -50,7 +50,7 @@ public class GameLootManager implements Listener
|
||||
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
|
||||
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager,
|
||||
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(),
|
||||
100, 250,
|
||||
500, 1000,
|
||||
1500, 2500,
|
||||
|
Loading…
Reference in New Issue
Block a user