Remove debug message, make sure player is far enough from spawn to open treasure

This commit is contained in:
Shaun Bennett 2014-09-12 22:41:10 -05:00
parent 88ef0ce35b
commit fc6a2633c9
2 changed files with 23 additions and 20 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)
@ -264,16 +268,16 @@ public class TreasureManager extends MiniPlugin
_playerTreasureMap.remove(event.getPlayer());
}
// @EventHandler
// public void command(PlayerCommandPreprocessEvent event)
// {
// //TODO Remove
// if (event.getMessage().startsWith("/treasure"))
// {
// event.getPlayer().sendMessage("Attempting to open treasure...");
// attemptOpenTreasure(event.getPlayer());
// event.setCancelled(true);
// }
// }
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
//TODO Remove
if (event.getMessage().startsWith("/treasure"))
{
event.getPlayer().sendMessage("Attempting to open treasure...");
attemptOpenTreasure(event.getPlayer());
event.setCancelled(true);
}
}
}

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