Use CoreClient instead of Player in case the player quits

This commit is contained in:
samczsun 2017-01-07 01:07:17 -05:00 committed by cnr
parent ac63985419
commit c5d5d86c1d
2 changed files with 14 additions and 3 deletions

View File

@ -284,7 +284,17 @@ public class DonationManager extends MiniClientPlugin<Donor>
*/
public void rewardCurrencyUntilSuccess(GlobalCurrency currency, Player player, String reason, int amount)
{
CoreClient client = _clientManager.Get(player);
rewardCurrencyUntilSuccess(currency, _clientManager.Get(player), reason, amount);
}
/**
* Rewards the {@link CoreClient} with {@code amount} of {@code currency} because of {@code reason}
* This method will retry the transaction for up to {@link DonationManager#MAX_GIVE_ATTEMPTS} attempts.
*
* This method is <b>not</b> thread safe, and should be called on the main thread
*/
public void rewardCurrencyUntilSuccess(GlobalCurrency currency, CoreClient client, String reason, int amount)
{
rewardCurrencyUntilSuccess(currency, client.getName(), client.getUniqueId(), reason, amount, null);
}

View File

@ -1,5 +1,6 @@
package mineplex.core.reward.rewards;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.UtilMath;
@ -63,7 +64,7 @@ public class TreasureShardReward extends Reward
rewardData = new RewardData(null, getRarity().getColor() + shards + " Treasure Shards", new ItemStack(Material.PRISMARINE_SHARD), getRarity());
}
int accountId = _clientManager.getAccountId(player);
CoreClient client = _clientManager.Get(player);
// Give shards 5 seconds later for better effect
Bukkit.getScheduler().runTaskLater(_donationManager.getPlugin(), new Runnable()
@ -71,7 +72,7 @@ public class TreasureShardReward extends Reward
@Override
public void run()
{
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Treasure", shards);
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, client, "Treasure", shards);
}
}, 100);