Actually remove gems when players join

This commit is contained in:
Sam 2017-02-24 20:50:53 +00:00
parent 76ef632e81
commit 295f626ec4

View File

@ -11,18 +11,26 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
import mineplex.gemhunters.economy.command.GiveGemsCommand;
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
@ReflectivelyCreateMiniPlugin
public class EconomyModule extends MiniClientPlugin<Integer>
{
private static final float GEM_KILL_FACTOR = 0.5F;
private static final int GEM_START_COST = 100;
private final DonationManager _donation;
public EconomyModule()
{
super("Economy");
_donation = require(DonationManager.class);
}
@Override
@ -34,7 +42,19 @@ public class EconomyModule extends MiniClientPlugin<Integer>
@EventHandler
public void respawn(PlayerCustomRespawnEvent event)
{
addToStore(event.getPlayer(), null, 100);
addToStore(event.getPlayer(), null, GEM_START_COST);
}
@EventHandler
public void teleportIn(PlayerTeleportIntoMapEvent event)
{
Player player = event.getPlayer();
Donor donor = _donation.Get(event.getPlayer());
if (donor.getBalance(GlobalCurrency.GEM) >= GEM_START_COST)
{
_donation.purchaseUnknownSalesPackage(player, "Gem Hunters Access", GlobalCurrency.GEM, GEM_START_COST, false, null);
}
}
@EventHandler