Tons more stuff on the checklist.

This commit is contained in:
Virizion 2015-12-06 22:54:45 -05:00
parent ca7e5d0d6d
commit 6904f7c9a9
3 changed files with 212 additions and 43 deletions

View File

@ -1,13 +1,13 @@
package nautilus.game.arcade.game.games.speedbuilder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
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.UtilEnt;
@ -26,14 +26,21 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.speedbuilder.data.BuildData;
import nautilus.game.arcade.game.games.speedbuilder.data.DemolitionData;
import nautilus.game.arcade.game.games.speedbuilder.data.RecreationData;
import nautilus.game.arcade.game.games.speedbuilder.kits.DefaultKit;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -42,16 +49,16 @@ import org.bukkit.block.BlockState;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.material.Bed;
import org.bukkit.util.Vector;
public class SpeedBuilder extends SoloGame
{
@ -74,9 +81,8 @@ public class SpeedBuilder extends SoloGame
private NautHashMap<Player, RecreationData> _buildRecreations = new NautHashMap<Player, RecreationData>();
private Zombie _judgeEntity;
private ArmorStand _judgeEntity;
private DisguiseGuardian _judgeDisguise;
private ArmorStand _judgeSupport;
private Location _judgeSpawn;
private ArmorStand _judgeLaserTarget;
@ -211,24 +217,19 @@ public class SpeedBuilder extends SoloGame
{
CreatureAllowOverride = true;
_judgeEntity = _judgeSpawn.getWorld().spawn(_judgeSpawn, Zombie.class);
_judgeSupport = _judgeSpawn.getWorld().spawn(_judgeSpawn, ArmorStand.class);
_judgeEntity = _judgeSpawn.getWorld().spawn(_judgeSpawn, ArmorStand.class);
CreatureAllowOverride = false;
UtilEnt.Vegetate(_judgeEntity, true);
_judgeEntity.setVisible(false);
_judgeEntity.setGravity(false);
_judgeEntity.setSmall(true);
_judgeDisguise = new DisguiseGuardian(_judgeEntity);
_judgeDisguise.setElder(true);
Manager.GetDisguise().disguise(_judgeDisguise);
_judgeSupport.setVisible(false);
_judgeSupport.setGravity(false);
_judgeSupport.setSmall(true);
_judgeSupport.setPassenger(_judgeEntity);
}
public void despawnJudge()
@ -236,11 +237,9 @@ public class SpeedBuilder extends SoloGame
Manager.GetDisguise().undisguise(_judgeEntity);
_judgeEntity.remove();
_judgeSupport.remove();
_judgeDisguise = null;
_judgeEntity = null;
_judgeSupport = null;
}
public void judgeTargetLocation(Location loc)
@ -272,6 +271,7 @@ public class SpeedBuilder extends SoloGame
_judgeLaserTarget.setVisible(false);
_judgeLaserTarget.setGravity(false);
_judgeLaserTarget.setSmall(true);
_judgeLaserTarget.setGhost(true);
UtilEnt.CreatureLook(_judgeEntity, _judgeLaserTarget.getLocation());
@ -281,6 +281,22 @@ public class SpeedBuilder extends SoloGame
}
}
public void moveToGuardians(Player player)
{
GetTeamList().get(0).SetPlacement(player, PlayerState.OUT);
GetTeamList().get(0).RemovePlayer(player);
GetTeamList().get(1).AddPlayer(player, true);
DisguiseGuardian disguise = new DisguiseGuardian(player);
Manager.GetDisguise().disguise(disguise);
player.setAllowFlight(true);
player.setFlying(true);
EndCheck();
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPrepare(GameStateChangeEvent event)
{
@ -290,6 +306,8 @@ public class SpeedBuilder extends SoloGame
spawnJudge();
//GUARDIAN LAZORZ WILL ROXORZ YOUR BOXORZ
AddTeam(new GameTeam(this, "Guardians", ChatColor.RED, new ArrayList<Location>()));
ArrayList<Player> players = GetPlayers(true);
for (int i = 0; i < players.size(); i++)
@ -364,8 +382,33 @@ public class SpeedBuilder extends SoloGame
return;
}
if (_buildRecreations.get(event.getPlayer()).inBuildArea(event.getBlock()))
if (_buildRecreations.get(event.getPlayer()).isQueuedForDemolition(event.getBlock()))
{
event.setCancelled(true);
return;
}
if (_buildRecreations.get(event.getPlayer()).inBuildArea(event.getBlock()) && event.getBlock().getType() != Material.BED_BLOCK)
return;
else if (event.getBlock().getType() == Material.BED_BLOCK)
{
Bed bed = (Bed) event.getBlock().getState().getData();
if (bed.isHeadOfBed())
{
Block foot = event.getBlock().getRelative(bed.getFacing().getOppositeFace());
if (_buildRecreations.get(event.getPlayer()).inBuildArea(foot))
return;
}
else
{
Block head = event.getBlock().getRelative(bed.getFacing());
if (_buildRecreations.get(event.getPlayer()).inBuildArea(head))
return;
}
}
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!"));
@ -429,6 +472,9 @@ public class SpeedBuilder extends SoloGame
if (!IsLive())
return;
if (_state == SpeedBuilderState.Reviewing)
return;
for (Player player : GetPlayers(true))
{
if (!_buildRecreations.containsKey(player))
@ -456,6 +502,25 @@ public class SpeedBuilder extends SoloGame
}
}
@EventHandler
public void stopGuardiansBuildEnter(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
for (Player player : GetTeamList().get(1).GetPlayers(false))
{
for (RecreationData recreation : _buildRecreations.values())
{
if (UtilMath.offsetSquared(player.getLocation(), recreation.getMidpoint()) < 25)
UtilAction.velocity(player, player.getLocation().getDirection().multiply(-1));
}
}
}
@EventHandler
public void stateUpdate(UpdateEvent event)
{
@ -509,6 +574,15 @@ public class SpeedBuilder extends SoloGame
//Sometimes doesn't show in the update method
UtilTextMiddle.display("", C.cRed + "TIME'S UP!");
for (Player player : UtilServer.getPlayers())
{
player.setGameMode(GameMode.SPECTATOR);
player.setSpectatorTarget(_judgeEntity);
PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(10, 0.0F);
UtilPlayer.sendPacket(player, packet);
}
_perfectBuild.clear();
ItemPickup = false;
@ -560,6 +634,22 @@ public class SpeedBuilder extends SoloGame
recreation.pasteBuildData(_currentBuild);
}
for (Player player : UtilServer.getPlayers())
{
player.setGameMode(GameMode.SURVIVAL);
if (_buildRecreations.containsKey(player))
player.teleport(_buildRecreations.get(player).PlayerSpawn);
if (!IsAlive(player) || GetTeamList().get(1).HasPlayer(player))
{
player.setAllowFlight(true);
player.setFlying(true);
player.teleport(GetSpectatorLocation());
}
}
if (_buildTime > 1)
_buildTime--;
@ -603,10 +693,7 @@ public class SpeedBuilder extends SoloGame
_buildRecreations.remove(eliminating.Player);
eliminating.Player.damage(9001);
if (_toEliminate.isEmpty() && GetPlayers(true).size() > 1)
UtilTextMiddle.display("", C.cRed + "Next Build Commencing...");
moveToGuardians(eliminating.Player);
}
}, 40L);
}
@ -742,25 +829,70 @@ public class SpeedBuilder extends SoloGame
}
@EventHandler
public void stopJudgeCombust(EntityCombustEvent event)
public void judgeStaring(UpdateEvent event)
{
if (event.getEntity().equals(_judgeEntity))
event.setCancelled(true);
}
@EventHandler
public void judgeRandomLook(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.FASTEST)
return;
if (!InProgress())
return;
if (_state != SpeedBuilderState.Building && _state != SpeedBuilderState.Viewing)
return;
for (Player player : UtilServer.getPlayers())
{
Vector trajectory = UtilAlg.getTrajectory(_judgeEntity.getEyeLocation(), player.getEyeLocation());
PacketPlayOutEntityLook packetLook = new PacketPlayOutEntityLook();
packetLook.a = _judgeEntity.getEntityId();
packetLook.e = (byte)(int)(UtilAlg.GetYaw(trajectory) * 256d / 360d);
packetLook.f = (byte)(int)(UtilAlg.GetPitch(trajectory) * 256d / 360d);
packetLook.g = false;
packetLook.h = true;
PacketPlayOutEntityHeadRotation packetRot = new PacketPlayOutEntityHeadRotation();
packetRot.a = packetLook.a;
packetRot.b = packetLook.e;
UtilPlayer.sendPacket(player, packetLook, packetRot);
}
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (_state != SpeedBuilderState.Building)
return;
GameTeam playersTeam = GetTeamList().get(0);
if (playersTeam.GetPlayers(true).size() <= 1)
{
ArrayList<Player> places = playersTeam.GetPlacements(true);
//Announce
AnnounceEnd(places);
//Gems
if (places.size() >= 1)
AddGems(places.get(0), 20, "1st Place", false, false);
if (places.size() >= 2)
AddGems(places.get(1), 15, "2nd Place", false, false);
if (places.size() >= 3)
AddGems(places.get(2), 10, "3rd Place", false, false);
for (Player player : GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
//End
SetState(GameState.End);
}
}
@Override
@ -775,7 +907,7 @@ public class SpeedBuilder extends SoloGame
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreenB + "Players Left:");
Scoreboard.Write("" + GetPlayers(true).size());
Scoreboard.Write("" + GetTeamList().get(0).GetPlayers(true).size());
Scoreboard.WriteBlank();

View File

@ -3,13 +3,16 @@ package nautilus.game.arcade.game.games.speedbuilder.data;
import java.util.ArrayList;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilTime;
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.block.BlockState;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Bed;
@ -20,16 +23,25 @@ public class DemolitionData
public RecreationData Parent;
public ArrayList<Block> Blocks;
public NautHashMap<Block, BlockState> Blocks;
public Long Start;
private Hologram _hologram;
private boolean _flickerAir = true;
private long _lastFlicker = System.currentTimeMillis();
public DemolitionData(RecreationData parent, ArrayList<Block> blocks)
{
Parent = parent;
Blocks = blocks;
Blocks = new NautHashMap<Block, BlockState>();
for (Block block : blocks)
{
Blocks.put(block, block.getState());
}
Start = System.currentTimeMillis();
spawnHologram();
@ -37,7 +49,7 @@ public class DemolitionData
public void spawnHologram()
{
_hologram = new Hologram(Parent.Game.Manager.getHologramManager(), Blocks.get(0).getLocation().add(0.5, 0.5, 0.5), "3");
_hologram = new Hologram(Parent.Game.Manager.getHologramManager(), Blocks.keySet().iterator().next().getLocation().add(0.5, 0.5, 0.5), "3");
_hologram.start();
}
@ -58,6 +70,21 @@ public class DemolitionData
_hologram.setText("" + secondsLeft);
if (UtilTime.elapsed(_lastFlicker, 500))
{
_lastFlicker = System.currentTimeMillis();
for (Block block : Blocks.keySet())
{
if (_flickerAir)
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
else
Blocks.get(block).update(true, false);
}
_flickerAir = !_flickerAir;
}
if (secondsLeft == 0)
breakBlocks();
}
@ -74,12 +101,14 @@ public class DemolitionData
despawnHologram();
//Effect will play for all blocks even two-parted ones
for (Block block : Blocks)
for (Block block : Blocks.keySet())
{
Blocks.get(block).update(true, false);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
}
for (Block block : Blocks)
for (Block block : Blocks.keySet())
{
if (block.getType() == Material.AIR)
continue;

View File

@ -238,14 +238,22 @@ public class RecreationData
return UtilBlock.getInBoundingBox(CornerA, CornerB);
}
public void addToDemolition(Block block)
public boolean isQueuedForDemolition(Block block)
{
for (DemolitionData demolition : BlocksForDemolition)
{
if (demolition.Blocks.contains(block))
return;
if (demolition.Blocks.containsKey(block))
return true;
}
return false;
}
public void addToDemolition(Block block)
{
if (isQueuedForDemolition(block))
return;
ArrayList<Block> blocks = new ArrayList<Block>();
blocks.add(block);