Made some bugfixes and made a challenge harder

This commit is contained in:
Morten 2016-01-04 21:13:12 +01:00
parent 5ac841dbf1
commit f24cc35ef8
2 changed files with 50 additions and 36 deletions

View File

@ -197,7 +197,11 @@ public class ChallengeAnvilDance extends Challenge
}
if(!_paused)
if(GetTimeLeftPercent() <= .5f)
{
createAnvil();
}
}
}.runTaskTimer(Host.getArcadeManager().getPlugin(), 20L, 1L);
}

View File

@ -19,12 +19,14 @@ import org.bukkit.inventory.ItemStack;
public class ChallengeMineADiamond extends Challenge
{
private ArrayList<Material> ores = new ArrayList<Material>(Arrays.asList(Material.IRON_ORE, Material.GOLD_ORE, Material.REDSTONE_ORE,
Material.EMERALD_ORE, Material.COAL_ORE, Material.LAPIS_ORE));
private ArrayList<Material> _ores = new ArrayList<Material>(Arrays.asList(Material.IRON_ORE, Material.GOLD_ORE,
Material.REDSTONE_ORE, Material.EMERALD_ORE, Material.COAL_ORE, Material.LAPIS_ORE));
private ArrayList<Block> _diamonds = new ArrayList<Block>();
public ChallengeMineADiamond(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Mine a Diamond", "Find a diamond around the map.", "Be the first to mine one!");
super(host, ChallengeType.FirstComplete, "Mine a Diamond", "Find a diamond around the map.",
"Be the first to mine one!");
}
@Override
@ -32,11 +34,11 @@ public class ChallengeMineADiamond extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -getArenaSize() + 1; x <= getArenaSize() - 1; x++)
for (int x = -getArenaSize() + 1; x <= getArenaSize() - 1; x++)
{
for(int z = -getArenaSize() + 1; z <= getArenaSize() - 1; z++)
for (int z = -getArenaSize() + 1; z <= getArenaSize() - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
if (x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
}
@ -54,10 +56,14 @@ public class ChallengeMineADiamond extends Challenge
@Override
public void setupPlayers()
{
for(Player player : Host.GetPlayers(true))
for (Player player : Host.GetPlayers(true))
{
player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE));
}
for(Block diamond: _diamonds)
{
diamond.setType(Material.DIAMOND);
}
Host.BlockBreak = true;
}
@ -65,49 +71,53 @@ public class ChallengeMineADiamond extends Challenge
public void generateRoom()
{
int amountOfDiamonds = 0;
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
for (int y = 0; y <= 2; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
if (y == 0)
{
b.setType(Material.DIRT);
b.setData((byte) 2);
}
else
{
if(amountOfDiamonds == 0)
if (amountOfDiamonds == 0)
{
for(int i = 0; i < Math.ceil((Host.GetPlayers(true).size() + 1) / 2); i++)
if (y <= 1)
{
Block copy = getCenter().getBlock().getRelative(UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1,
UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
if(copy.getType() == Material.DIAMOND_ORE)
for (int i = 0; i < Math.ceil((Host.GetPlayers(true).size() + 1) / 2); i++)
{
i--;
continue;
}
copy.setType(Material.DIAMOND_ORE);
addBlock(copy);
Block copy = getCenter().getBlock().getRelative(
UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1,
UtilMath.r(getArenaSize() * 2) - (getArenaSize()));
if (copy.getType() == Material.DIAMOND_ORE)
{
i--;
continue;
}
_diamonds.add(copy);
addBlock(copy);
amountOfDiamonds++;
amountOfDiamonds++;
}
}
if (b.getType() != Material.DIAMOND_ORE)
{
b.setType(_ores.get(UtilMath.r(_ores.size())));
}
}
if(b.getType() != Material.DIAMOND_ORE)
{
b.setType(ores.get(UtilMath.r(ores.size())));
}
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
if ((Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) && y >= 2)
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
if (b.getType() != Material.AIR)
{
addBlock(b);
}
@ -119,37 +129,37 @@ public class ChallengeMineADiamond extends Challenge
@EventHandler
public void onDiamondMine(PlayerInteractEvent event)
{
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(!Host.IsAlive(event.getPlayer()))
if (!Host.IsAlive(event.getPlayer()))
{
return;
}
if(IsCompleted(event.getPlayer()))
if (IsCompleted(event.getPlayer()))
{
event.setCancelled(true);
return;
}
if(event.getAction() == Action.LEFT_CLICK_BLOCK)
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if(event.getClickedBlock().getType() == Material.DIAMOND_ORE)
if (event.getClickedBlock().getType() == Material.DIAMOND_ORE)
{
SetCompleted(event.getPlayer(), true);
event.getClickedBlock().setType(Material.AIR);
}
}
}
@EventHandler
public void onPlayerMineblock(BlockBreakEvent event)
{
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(event.getBlock().getType() != Material.DIAMOND_ORE)
if (event.getBlock().getType() != Material.DIAMOND_ORE)
{
event.setCancelled(true);
}