diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index e3673d011..7b908b134 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -20,6 +20,7 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; @@ -124,7 +125,7 @@ public class TreasureManager extends MiniPlugin public void attemptOpenTreasure(Player player) { - if (!checkNearbyBlocks(player)) + if (!checkNearbyBlocks(player) || checkNearSpawn(player)) return; TreasureStartEvent event = new TreasureStartEvent(player); @@ -136,13 +137,7 @@ public class TreasureManager extends MiniPlugin return; } - ITreasureReward[] rewards = new ITreasureReward[4]; - - for (int i = 0; i < 4; i++) - { - rewards[i] = _rewardManager.nextReward(player); - } - + ITreasureReward[] rewards = _rewardManager.getRewards(player); Treasure treasure = new Treasure(player, rewards); _playerTreasureMap.put(player, treasure); @@ -177,6 +172,15 @@ public class TreasureManager extends MiniPlugin return true; } + private boolean checkNearSpawn(Player player) + { + boolean nearSpawn = UtilMath.offset2d(new Location(player.getWorld(), 0, 0, 0), player.getLocation()) < 10; + + if (nearSpawn) + UtilPlayer.message(player, F.main("Treasure", "You are too close to the spawn to open a treasure chest!")); + + return nearSpawn; + } @EventHandler public void update(UpdateEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardManager.java index d484997ea..cee10b136 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardManager.java @@ -37,7 +37,6 @@ public class RewardManager public ITreasureReward[] getRewards(Player player) { - System.out.println("getting rewards"); int currentReward = 0; ITreasureReward[] rewards = new ITreasureReward[4];