diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java new file mode 100644 index 000000000..abf86f368 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.quiver.data; + +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; + +public class SpawnBarrier +{ + + private Game _game; + private GameTeam _gameTeam; + private Set _barriers; + + public SpawnBarrier(Game game, GameTeam gameTeam, Set barriers) + { + _game = game; + _gameTeam = gameTeam; + _barriers = barriers; + + for (Location location : _barriers) + { + location.getBlock().setType(Material.AIR); + } + } + + public void update() + { + for (Player player : _game.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + if(_game.GetTeam(player).equals(_gameTeam)) + { + continue; + } + + for (Location location : _gameTeam.GetSpawns()) + { + if (UtilMath.offset(player.getLocation(), location) < 5) + { + _game.Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, _game.GetName(), "Spawn Shield"); + } + } + + for (Location location : _barriers) + { + if (UtilMath.offset(player.getLocation(), location) < 3) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4)); + } + + UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player); + } + } + } + + public GameTeam getGameTeam() + { + return _gameTeam; + } + + public Set getBlocks() + { + return _barriers; + } +}