Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-09-13 13:41:48 +10:00
commit 4454627b32
2 changed files with 12 additions and 9 deletions

View File

@ -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)

View File

@ -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];