Remove old unused build race challenge.
This commit is contained in:
parent
91e0547612
commit
a943808250
|
@ -38,7 +38,6 @@ import nautilus.game.arcade.game.games.holeinwall.KitNormal;
|
|||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeAnvilDance;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeArrowRampage;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockLobbers;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockRunner;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBouncingBlock;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBuildRace;
|
||||
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeChestLoot;
|
||||
|
|
|
@ -1,221 +0,0 @@
|
|||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ChallengeBlockRunner extends Challenge
|
||||
{
|
||||
// The amount of blocks for every hotbar slot.
|
||||
private static final int InventoryBlockAmount = 5;
|
||||
|
||||
private static Material[] _materials =
|
||||
{ Material.DIRT, Material.STONE, Material.COBBLESTONE, Material.LOG, Material.WOOD, Material.WOOL, Material.BRICK, Material.SMOOTH_BRICK,
|
||||
Material.GLASS };
|
||||
|
||||
public ChallengeBlockRunner(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.FirstComplete, "Block Runner", "Your inventory is filled with blocks.",
|
||||
"Be the first to place them all in the ground!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
Location center = new Location(Host.WorldData.World, 0, 0, 0);
|
||||
|
||||
for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3))
|
||||
{
|
||||
double x = location.getX() + 0.5;
|
||||
double y = 1.1;
|
||||
double z = location.getZ() + 0.5;
|
||||
|
||||
spawns.add(getCenter().add(x, y, z));
|
||||
}
|
||||
|
||||
return spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
Location center = new Location(Host.WorldData.World, 0, 0, 0);
|
||||
|
||||
for(Location location : UtilShapes.getCircle(center, false, getArenaSize()))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
block.setType(Material.GRASS);
|
||||
|
||||
addBlock(location.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
for(Material allowed : _materials)
|
||||
{
|
||||
Host.BlockPlaceAllow.add(allowed.getId());
|
||||
}
|
||||
|
||||
for(Player player : Host.GetPlayers(true))
|
||||
{
|
||||
setupInventoryContents(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupInventoryContents(Player player)
|
||||
{
|
||||
ArrayList<Material> shuffledMaterials = new ArrayList<Material>(Arrays.asList(_materials));
|
||||
Collections.shuffle(shuffledMaterials);
|
||||
|
||||
for(Material material : shuffledMaterials)
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(material, InventoryBlockAmount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
for(Material allowed : _materials)
|
||||
{
|
||||
Host.BlockPlaceAllow.remove(allowed.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if(!Host.IsLive() || !Host.isChallengeStarted())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(IsCompleted(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
addBlock(block);
|
||||
|
||||
// First Check
|
||||
// Checking if the player is trying to get off the map.
|
||||
|
||||
Block bottomVoid1 = block.getRelative(BlockFace.DOWN);
|
||||
Block bottomVoid2 = bottomVoid1.getRelative(BlockFace.DOWN);
|
||||
Block bottomVoid3 = bottomVoid2.getRelative(BlockFace.DOWN);
|
||||
|
||||
if(bottomVoid1.isEmpty() && bottomVoid2.isEmpty() && bottomVoid3.isEmpty())
|
||||
{
|
||||
UtilTextMiddle.display("", C.cRed + "You can't place blocks that far from the ground.", 5, 40, 5, player);
|
||||
blockBreakEffect(block);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Second Check
|
||||
// Checking if the player is trying to trap another player.
|
||||
|
||||
for(Player others : Host.GetPlayers(true))
|
||||
{
|
||||
if(others.equals(player))
|
||||
continue;
|
||||
|
||||
if(block.getLocation().add(0.5, 0.5, 0.5).distanceSquared(others.getLocation()) <= 1.5)
|
||||
{
|
||||
UtilTextMiddle.display("", C.cRed + "You can't place blocks near other players.", 5, 40, 5, player);
|
||||
blockBreakEffect(block);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Third Check
|
||||
// Checking if the player is trying to make a tower up to the sky.
|
||||
|
||||
Block bottom1 = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
Block bottom2 = bottom1.getRelative(BlockFace.DOWN);
|
||||
Block bottom3 = bottom2.getRelative(BlockFace.DOWN);
|
||||
|
||||
if(!bottom1.isEmpty() && !bottom2.isEmpty() && !bottom3.isEmpty() && block.getY() < player.getLocation().getY())
|
||||
{
|
||||
// Adding broken blocks back to inventory even if he didn't placed them.
|
||||
// This is so we can prevent quick block farming.
|
||||
|
||||
ItemStack handItem = player.getItemInHand();
|
||||
UtilInv.remove(player, handItem.getType(), handItem.getData().getData(), 1);
|
||||
|
||||
if(bottom1.getType() != Material.GRASS)
|
||||
{
|
||||
UtilInv.insert(player, new ItemStack(bottom1.getType()));
|
||||
blockBreakEffect(bottom1);
|
||||
}
|
||||
|
||||
if(bottom2.getType() != Material.GRASS)
|
||||
{
|
||||
UtilInv.insert(player, new ItemStack(bottom2.getType()));
|
||||
blockBreakEffect(bottom2);
|
||||
}
|
||||
|
||||
if(bottom3.getType() != Material.GRASS && bottom3.getType() != Material.DIRT)
|
||||
{
|
||||
UtilInv.insert(player, new ItemStack(bottom3.getType()));
|
||||
blockBreakEffect(bottom3);
|
||||
}
|
||||
|
||||
UtilTextMiddle.display("", C.cRed + "You can't build a tower that high.", 5, 40, 5, player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Last Check
|
||||
// Checking if the player has successfully placed all blocks.
|
||||
|
||||
ArrayList<ItemStack> items = UtilInv.getItems(player);
|
||||
|
||||
if((items.size() - 1) == 0)
|
||||
{
|
||||
if(items.get(0).getAmount() == 1)
|
||||
{
|
||||
SetCompleted(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void blockBreakEffect(Block block)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0,
|
||||
10, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue