Some more stuff on the checklist.
This commit is contained in:
parent
62c49fa8e6
commit
d3ce0d6434
@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
@ -48,7 +49,6 @@ import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
@ -62,7 +62,8 @@ public class SpeedBuilder extends SoloGame
|
||||
private int _buildCountStage;
|
||||
private int _viewCountStage;
|
||||
|
||||
private int _buildTime = 35;
|
||||
private int _buildTime = 25;
|
||||
private int _viewTime = 6;
|
||||
|
||||
private Location _buildMiddle;
|
||||
|
||||
@ -131,6 +132,11 @@ public class SpeedBuilder extends SoloGame
|
||||
_buildData.add(new BuildData(loc.clone().subtract(0.5, 0, 0.5)));
|
||||
}
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs("YELLOW"))
|
||||
{
|
||||
loc.subtract(0.5, 0, 0.5);
|
||||
}
|
||||
|
||||
for (Location loc : GetTeamList().get(0).GetSpawns())
|
||||
{
|
||||
loc.setDirection(UtilAlg.getTrajectory(loc, _buildMiddle.clone().add(0.5, 0, 0.5)));
|
||||
@ -275,7 +281,7 @@ public class SpeedBuilder extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPrepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
@ -283,6 +289,17 @@ public class SpeedBuilder extends SoloGame
|
||||
|
||||
spawnJudge();
|
||||
//GUARDIAN LAZORZ WILL ROXORZ YOUR BOXORZ
|
||||
|
||||
ArrayList<Player> players = GetPlayers(true);
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
if (i >= WorldData.GetDataLocs("YELLOW").size())
|
||||
{
|
||||
Manager.addSpectator(players.get(i), true);
|
||||
GetTeamList().get(0).RemovePlayer(players.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -302,7 +319,7 @@ public class SpeedBuilder extends SoloGame
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
Location buildLoc = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW")).clone().subtract(0.5, 0, 0.5);
|
||||
Location buildLoc = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW"));
|
||||
Location spawnLoc = UtilAlg.findClosest(buildLoc, GetTeamList().get(0).GetSpawns());
|
||||
|
||||
_buildRecreations.put(player, new RecreationData(this, player, buildLoc, spawnLoc));
|
||||
@ -332,7 +349,7 @@ public class SpeedBuilder extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (_state != SpeedBuilderState.Building)
|
||||
@ -341,6 +358,12 @@ public class SpeedBuilder extends SoloGame
|
||||
if (!_buildRecreations.containsKey(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (_perfectBuild.containsKey(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_buildRecreations.get(event.getPlayer()).inBuildArea(event.getBlock()))
|
||||
return;
|
||||
|
||||
@ -374,6 +397,8 @@ public class SpeedBuilder extends SoloGame
|
||||
|
||||
UtilTextMiddle.display("", C.cGreen + "Perfect Match", event.getPlayer());
|
||||
|
||||
Announce(F.main("Build", C.mElem + event.getPlayer().getName() + C.mBody + " got a perfect build!"));
|
||||
|
||||
_perfectBuild.put(event.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
@ -396,24 +421,37 @@ public class SpeedBuilder extends SoloGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopMoveIntoBuildAreas(PlayerMoveEvent event)
|
||||
public void stopMoveOffArea(UpdateEvent event)
|
||||
{
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
for (RecreationData recreation : _buildRecreations.values())
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (recreation.Player.equals(event.getPlayer()))
|
||||
if (!_buildRecreations.containsKey(player))
|
||||
continue;
|
||||
|
||||
if (recreation.inBuildArea(event.getTo()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Build", "You cannot enter other build areas!"));
|
||||
RecreationData recreation = _buildRecreations.get(player);
|
||||
double dist = UtilMath.offsetSquared(player.getLocation(), recreation.OriginalBuildLocation.clone().add(0.5, 0, 0.5));
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs("YELLOW"))
|
||||
{
|
||||
if (loc.equals(recreation.OriginalBuildLocation))
|
||||
continue;
|
||||
|
||||
event.getPlayer().teleport(_buildRecreations.get(event.getPlayer()).PlayerSpawn);
|
||||
double distFromOther = UtilMath.offsetSquared(player.getLocation(), loc.clone().add(0.5, 0, 0.5));
|
||||
|
||||
if (dist > distFromOther || player.getLocation().getY() < recreation.OriginalBuildLocation.getY() - 2)
|
||||
{
|
||||
player.teleport(recreation.PlayerSpawn);
|
||||
|
||||
UtilPlayer.message(player, F.main("Build", "You cannot leave your area!"));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -429,7 +467,7 @@ public class SpeedBuilder extends SoloGame
|
||||
|
||||
if (_state == SpeedBuilderState.Viewing)
|
||||
{
|
||||
if (UtilTime.elapsed(_stateTime, 10000))
|
||||
if (UtilTime.elapsed(_stateTime, _viewTime * 1000))
|
||||
{
|
||||
for (RecreationData recreation : _buildRecreations.values())
|
||||
{
|
||||
@ -593,7 +631,7 @@ public class SpeedBuilder extends SoloGame
|
||||
if (timeLeft < 0)
|
||||
timeLeft = 0;
|
||||
|
||||
UtilTextBottom.displayProgress("Time Left:", timeLeft / (_buildTime * 1000.0D), UtilTime.MakeStr(timeLeft), UtilServer.getPlayers());
|
||||
UtilTextBottom.displayProgress("Time Left", timeLeft / (_buildTime * 1000.0D), UtilTime.MakeStr(timeLeft), UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -611,7 +649,12 @@ public class SpeedBuilder extends SoloGame
|
||||
if (UtilTime.elapsed(_stateTime, 1000 * _buildCountStage))
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<Player>(UtilServer.getServer().getOnlinePlayers());
|
||||
players.removeAll(_perfectBuild.keySet());
|
||||
|
||||
for (Entry<Player, Long> entry : _perfectBuild.entrySet())
|
||||
{
|
||||
if (!UtilTime.elapsed(entry.getValue(), 5000))
|
||||
players.remove(entry.getKey());
|
||||
}
|
||||
|
||||
if (_buildCountStage == _buildTime)
|
||||
UtilTextMiddle.display("", C.cRed + "TIME'S UP!");
|
||||
@ -636,33 +679,15 @@ public class SpeedBuilder extends SoloGame
|
||||
|
||||
if (UtilTime.elapsed(_stateTime, _viewCountStage * 1000))
|
||||
{
|
||||
if (_viewCountStage == 10)
|
||||
if (_viewCountStage == _viewTime)
|
||||
UtilTextMiddle.display("", C.cRed + "View Time Over!");
|
||||
else
|
||||
UtilTextMiddle.display("", C.cGreen + (10 - _viewCountStage));
|
||||
UtilTextMiddle.display("", C.cGreen + (_viewTime - _viewCountStage));
|
||||
|
||||
_viewCountStage++;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cleanPerfectBuilders(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
Iterator<Entry<Player, Long>> iterator = _perfectBuild.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry<Player, Long> entry = iterator.next();
|
||||
|
||||
//Title gets 5 secs so the 5, 4, 3, 2, 1 doesn't override it
|
||||
if (UtilTime.elapsed(entry.getValue(), 5000))
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void markBlockForDemolition(PlayerInteractEvent event)
|
||||
{
|
||||
@ -675,6 +700,9 @@ public class SpeedBuilder extends SoloGame
|
||||
if (!UtilEvent.isAction(event, ActionType.L_BLOCK))
|
||||
return;
|
||||
|
||||
if (_perfectBuild.containsKey(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!_buildRecreations.get(event.getPlayer()).inBuildArea(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
|
@ -7,8 +7,11 @@ import mineplex.core.hologram.Hologram;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Bed;
|
||||
import org.bukkit.material.Door;
|
||||
|
||||
public class DemolitionData
|
||||
{
|
||||
@ -73,6 +76,33 @@ public class DemolitionData
|
||||
Item item = Block.getWorld().dropItem(Block.getLocation().add(0.5, 0.5, 0.5), itemStack);
|
||||
|
||||
Parent.DroppedItems.add(item);
|
||||
|
||||
//Destroy the other part
|
||||
if (Block.getType() == Material.BED_BLOCK)
|
||||
{
|
||||
Bed bed = (Bed) Block.getState().getData();
|
||||
|
||||
if (bed.isHeadOfBed())
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(bed.getFacing().getOppositeFace()).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(bed.getFacing()).getLocation(), Material.AIR);
|
||||
}
|
||||
else if (Block.getType() == Material.WOODEN_DOOR || Block.getType() == Material.IRON_DOOR_BLOCK || Block.getType() == Material.SPRUCE_DOOR || Block.getType() == Material.BIRCH_DOOR || Block.getType() == Material.JUNGLE_DOOR || Block.getType() == Material.ACACIA_DOOR || Block.getType() == Material.DARK_OAK_DOOR)
|
||||
{
|
||||
Door door = (Door) Block.getState().getData();
|
||||
|
||||
if (door.isTopHalf())
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(BlockFace.UP).getLocation(), Material.AIR);
|
||||
}
|
||||
else if (Block.getType() == Material.DOUBLE_PLANT)
|
||||
{
|
||||
if (Block.getData() > 7)
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(Block.getRelative(BlockFace.UP).getLocation(), Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
Block.getWorld().playEffect(Block.getLocation(), Effect.STEP_SOUND, Block.getTypeId());
|
||||
|
@ -12,10 +12,13 @@ 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.block.BlockState;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Bed;
|
||||
import org.bukkit.material.Door;
|
||||
|
||||
public class RecreationData
|
||||
{
|
||||
@ -26,6 +29,8 @@ public class RecreationData
|
||||
|
||||
public BlockState[][] DefaultGround = new BlockState[5][5];
|
||||
|
||||
public Location OriginalBuildLocation;
|
||||
|
||||
public Location CornerA;
|
||||
public Location CornerB;
|
||||
|
||||
@ -41,6 +46,8 @@ public class RecreationData
|
||||
|
||||
Player = player;
|
||||
|
||||
OriginalBuildLocation = loc;
|
||||
|
||||
CornerA = loc.clone().subtract(2, 0, 2);
|
||||
CornerB = loc.clone().add(2, 4, 2);
|
||||
|
||||
@ -147,13 +154,43 @@ public class RecreationData
|
||||
public void breakAndDropItems()
|
||||
{
|
||||
for (Block block : getBlocks())
|
||||
{
|
||||
{
|
||||
if (block.getType() == Material.AIR)
|
||||
continue;
|
||||
|
||||
for (ItemStack itemStack : UtilBlock.blockToInventoryItemStacks(block))
|
||||
{
|
||||
Item item = block.getWorld().dropItem(getMidpoint(), itemStack);
|
||||
|
||||
DroppedItems.add(item);
|
||||
}
|
||||
|
||||
//Destroy the other part
|
||||
if (block.getType() == Material.BED_BLOCK)
|
||||
{
|
||||
Bed bed = (Bed) block.getState().getData();
|
||||
|
||||
if (bed.isHeadOfBed())
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing().getOppositeFace()).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing()).getLocation(), Material.AIR);
|
||||
}
|
||||
else if (block.getType() == Material.WOODEN_DOOR || block.getType() == Material.IRON_DOOR_BLOCK || block.getType() == Material.SPRUCE_DOOR || block.getType() == Material.BIRCH_DOOR || block.getType() == Material.JUNGLE_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR)
|
||||
{
|
||||
Door door = (Door) block.getState().getData();
|
||||
|
||||
if (door.isTopHalf())
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR);
|
||||
}
|
||||
else if (block.getType() == Material.DOUBLE_PLANT)
|
||||
{
|
||||
if (block.getData() > 7)
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
CornerA.getWorld().playEffect(getMidpoint(), Effect.STEP_SOUND, Material.LOG.getId());
|
||||
|
Loading…
Reference in New Issue
Block a user