diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java new file mode 100644 index 000000000..31f06938f --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java @@ -0,0 +1,111 @@ +package mineplex.core.common.util.particles.effects; + +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; + +/** + * Creates a line of particles with customise able traits. + * + * Most noticeable with Blink skills. + */ +public class LineParticle +{ + + private Location _start; + private Vector _direction; + private Location _lastLocation; + + private double _curRange; + private double _incrementedRange; + private double _maxRange; + private double _actualRange; + + private Set _ignoredTypes; + + private ParticleType _particleType; + private Player[] _toDisplay; + + public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, Set ignoredTypes, ParticleType particleType, Player... toDisplay) + { + this(start, null, direction, incrementedRange, maxRange, ignoredTypes, particleType, toDisplay); + } + + public LineParticle(Location start, Location end, Vector direction, double incrementedRange, double maxRange, Set ignoredTypes, ParticleType particleType, Player... toDisplay) + { + _start = start; + _direction = direction; + _lastLocation = start; + + _curRange = 0; + _incrementedRange = incrementedRange; + _maxRange = maxRange; + _ignoredTypes = ignoredTypes; + + _particleType = particleType; + _toDisplay = toDisplay; + + if (_direction == null) + { + direction = UtilAlg.getTrajectory(start, end).normalize(); + } + } + + /** + * Advances the line. + * + * @return true when the line has reached its target or has collided with a + * block with a type contained in _ignoredTypes. + */ + public boolean update() + { + boolean done = _curRange > _maxRange; + + Location newTarget = _start.clone().add(new Vector(0, 0.2, 0)).add(_direction.clone().multiply(_curRange)); + _lastLocation = newTarget; + + if (!UtilBlock.airFoliage(newTarget.getBlock()) || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) + { + if (_ignoredTypes == null) + { + done = true; + } + + if (!_ignoredTypes.contains(newTarget.getBlock().getType())) + { + done = true; + } + } + + _curRange += _incrementedRange; + + UtilParticle.PlayParticle(_particleType, newTarget, 0, 0, 0, 0.001F, 1, ViewDist.LONG, _toDisplay); + + if (done) + { + _actualRange = _curRange; + } + + return done; + } + + public Location getLastLocation() + { + return _lastLocation; + } + + public Location getDestination() + { + return _start.add(_direction.multiply(Math.max(0, _actualRange - 0.4)).add(new Vector(0, 0.4, 0))); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ObjectiveParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java similarity index 71% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ObjectiveParticle.java rename to Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java index 8bda42d34..cf4f940d0 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ObjectiveParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java @@ -1,20 +1,28 @@ -package mineplex.core.common.util; +package mineplex.core.common.util.particles.effects; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +/** + * Creates a particle curve that bends towards a location. + * + * Most noticeable in Gladiators and TOITQ. + */ public class ObjectiveParticle { - + private Location _current; private Location _target; private Vector _direction; - + private float _turnMultipler; private float _blocksToAdvance; private float _particleOffset; @@ -22,17 +30,18 @@ public class ObjectiveParticle private float _soundVolume; private float _soundPitch; private double _stopAtDistance; - + private Sound _sound; private ParticleType _particleType; private Player[] _toDisplay; - + public ObjectiveParticle(Location start, Vector startVector, Location target, Player... toDisplay) { this(start, startVector, target, 0.15F, 0.5F, 0.03F, 3, ParticleType.HAPPY_VILLAGER, 0.2F, 3F, Sound.FIZZ, 4, toDisplay); } - - public ObjectiveParticle(Location start, Vector startVector, Location target, float turnMutlipler, float blocksToAdvance, float particleOffset, int particleCount, ParticleType particleType, float soundVolume, float soundPitch, Sound sound, double stopAtDistance, Player... toDisplay) + + public ObjectiveParticle(Location start, Vector startVector, Location target, float turnMutlipler, float blocksToAdvance, float particleOffset, int particleCount, ParticleType particleType, + float soundVolume, float soundPitch, Sound sound, double stopAtDistance, Player... toDisplay) { _current = start; _target = target; @@ -45,29 +54,38 @@ public class ObjectiveParticle _soundPitch = soundPitch; _sound = sound; _stopAtDistance = stopAtDistance; - _toDisplay = toDisplay; + _toDisplay = toDisplay; _direction = startVector; - + if (_direction.getY() < 0) { _direction.setY(0); } - + _direction.normalize(); } - + + /** + * Advances the curve. + * + * @return true when the curve is within _stopAtDistance blocks of the + * target. + */ public boolean update() { _direction.add(UtilAlg.getTrajectory(_current, _target).multiply(_turnMultipler)); _direction.normalize(); - + _current.add(_direction.clone().multiply(_blocksToAdvance)); - + UtilParticle.PlayParticle(_particleType, _current, _particleOffset, _particleOffset, _particleOffset, 0, _particleCount, ViewDist.LONG, _toDisplay); - - _current.getWorld().playSound(_current, _sound, _soundVolume, _soundPitch); - + + for (Player player : _toDisplay) + { + player.playSound(_current, _sound, _soundVolume, _soundPitch); + } + return UtilMath.offset(_current, _target) < _stopAtDistance; } - + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java index 1ff8f94b9..127233cc8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java @@ -38,7 +38,6 @@ import org.bukkit.util.Vector; import mineplex.core.common.MinecraftVersion; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.ObjectiveParticle; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilItem; @@ -52,7 +51,7 @@ import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; -import mineplex.core.hologram.Hologram; +import mineplex.core.common.util.particles.effects.ObjectiveParticle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -99,7 +98,7 @@ public class QuiverPayload extends TeamGame private static final long POWERUP_SPAWN_DELAY = 20000; - private static final int RESPAWN_INITAL_SECONDS = 5; + private static final int RESPAWN_INITAL_SECONDS = 2; private static final int RESPAWN_ARROW_GIVE_DELAY = 20; private static final int END_EFFECT_DELAY = 100; @@ -109,6 +108,7 @@ public class QuiverPayload extends TeamGame private static final long KILLSTREAK_TIME_PERIOD = 1500; private static final long TEAM_KILL_MINIMUM_DELAY = 20000; + private static final int TEAM_KILL_MINIMUM_PLAYERS = 6; private static final long OBJECTIVE_PARTICLES_TIME = 10000; @@ -121,7 +121,6 @@ public class QuiverPayload extends TeamGame public static final String DATA_POINT_KIT_BLUE = "LIGHT_BLUE"; private Minecart _minecart; - private Hologram _hologram; private GameTeam _teamDirection; private int _targetIndex; private boolean _hasMoved; @@ -223,7 +222,7 @@ public class QuiverPayload extends TeamGame for (GameTeam gameTeam : _teamScore.keySet()) { - int score = _teamScore.get(gameTeam); + int score = Math.min(_teamScore.get(gameTeam), MAX_SCORE); Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName()); Scoreboard.write(score + " Point" + (score == 1 ? "" : "s") + " (" + (MAX_SCORE - score) + ")"); @@ -269,12 +268,9 @@ public class QuiverPayload extends TeamGame Location location = WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0); _minecart = location.getWorld().spawn(location, Minecart.class); - _hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None"); - + _minecart.spigot().forceGlowing(true); _minecart.setDisplayBlock(new MaterialData(Material.TNT)); - _hologram.setFollowEntity(_minecart); - _hologram.start(); _payloadTeam.addEntry(_minecart.getUniqueId().toString()); for (Player player : GetPlayers(true)) @@ -389,7 +385,7 @@ public class QuiverPayload extends TeamGame return; } - if (event.getType() == UpdateType.MIN_01) + if (event.getType() == UpdateType.MIN_02) { this.DeathSpectateSecs++; } @@ -553,32 +549,35 @@ public class QuiverPayload extends TeamGame } if (event.getType() == UpdateType.FAST) - { - for (GameTeam gameTeam : GetTeamList()) + { + if (GetPlayers(true).size() >= TEAM_KILL_MINIMUM_PLAYERS) { - if (!UtilTime.elapsed(_lastTeamKill, TEAM_KILL_MINIMUM_DELAY)) + for (GameTeam gameTeam : GetTeamList()) { - break; - } - - boolean gameTeamKill = true; - - for (Player player : gameTeam.GetPlayers(false)) - { - if (!UtilPlayer.isSpectator(player)) + if (!UtilTime.elapsed(_lastTeamKill, TEAM_KILL_MINIMUM_DELAY)) { - gameTeamKill = false; + break; } - } - if (gameTeamKill) - { - String message = gameTeam.GetColor() + C.Bold + "TEAM KILL"; + boolean gameTeamKill = true; - UtilTextMiddle.display(message, "", 10, 30, 10); - UtilServer.broadcast(message); + for (Player player : gameTeam.GetPlayers(false)) + { + if (!UtilPlayer.isSpectator(player)) + { + gameTeamKill = false; + } + } - _lastTeamKill = System.currentTimeMillis(); + if (gameTeamKill) + { + String message = gameTeam.GetColor() + C.Bold + "TEAM KILL"; + + UtilTextMiddle.display(message, "", 10, 30, 10); + UtilServer.broadcast(message); + + _lastTeamKill = System.currentTimeMillis(); + } } } @@ -695,12 +694,10 @@ public class QuiverPayload extends TeamGame if (gameTeamACount > 0 && gameTeamBCount > 0) { _payloadState = PayloadState.CONTESTED; - _hologram.setText(C.cDPurpleB + "Contested"); } else { _payloadState = PayloadState.NONE; - _hologram.setText("None"); } setMinecartTeam(_payloadState); @@ -746,7 +743,6 @@ public class QuiverPayload extends TeamGame _minecart.setVelocity(UtilAlg.getTrajectory(_minecart.getLocation(), _pathMarkers.get(_targetIndex)).normalize().multiply(PAYLOAD_VELOCITY)); _hasMoved = true; - _hologram.setText(_teamDirection.GetFormattedName()); } if (event.getType() == UpdateType.FASTER && _payloadState.equals(PayloadState.RESTARTING)) @@ -884,11 +880,13 @@ public class QuiverPayload extends TeamGame _recentlyChanged = false; UtilAction.zeroVelocity(_minecart); - String message = WinnerTeam.GetFormattedName() + " scored a point! Payload respawning..."; - - UtilTextMiddle.display("", message, 10, 20, 10); - UtilServer.broadcast(message); + if (_teamScore.get(_teamDirection) < MAX_SCORE) + { + String message = WinnerTeam.GetFormattedName() + " scored a point! Payload respawning..."; + UtilTextMiddle.display("", message, 10, 20, 10); + UtilServer.broadcast(message); + } displayPointScoreEffect(); for (Player player : UtilServer.getPlayers()) @@ -1073,7 +1071,7 @@ public class QuiverPayload extends TeamGame } Player player = event.getPlayer(); - Kit kit = GetKit(player); + ProgressingKit kit = (ProgressingKit) GetKit(player); if (!event.isSneaking()) { @@ -1090,23 +1088,26 @@ public class QuiverPayload extends TeamGame return; } - for (Perk perk : kit.GetPerks()) + for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())]) { if (perk instanceof Ultimate) { Ultimate ultimate = (Ultimate) perk; - ultimate.activate(player); - resetUltimate(player, false); + if (ultimate.isUsable(player)) + { + ultimate.activate(player); + resetUltimate(player, false); + } } } } public void incrementUltimate(Player player, double percentage) { - Kit kit = GetKit(player); + ProgressingKit kit = (ProgressingKit) GetKit(player); - for (Perk perk : kit.GetPerks()) + for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())]) { if (perk instanceof Ultimate) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java index 4f65c0b46..2ad26fd72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java @@ -38,32 +38,32 @@ public class KitNecromancer extends ProgressingKit private static final Perk[][] PERKS = { { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(10000, 3) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(10500, 3) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(11000, 3) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(11500, 3) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(12000, 3) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkLifestealArrows(4), + new PerkLifestealArrows(8), new UltimateNecromancer(12500, 3) } }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java index 1b6ed984c..0cb079a6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.quiver.kits; + package nautilus.game.arcade.game.games.quiver.kits; import java.util.UUID; @@ -52,33 +52,33 @@ public class KitSkyWarrior extends ProgressingKit private static final Perk[][] PERKS = { { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) }, { new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), - new PerkSpeed(1), - new UltimateSkyWarrior(2, 10, 10, 5, 30) + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) } }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java index 413805d11..0c73b11f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java @@ -57,6 +57,11 @@ public abstract class Ultimate extends Perk player.sendMessage(F.main("Game", "Deactivated " + F.skill(GetName()))); player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0); } + + public boolean isUsable(Player player) + { + return true; + } public abstract double getChargeIncreasePerSecond(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java index 20edce0a4..8690c588e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java @@ -37,7 +37,7 @@ public class UltimateNecromancer extends Ultimate public UltimateNecromancer(long length, int skeletons) { - super("Undead Minions", new String[] {}); + super("Summon Undead", new String[] {}); _length = length; _skeletons = skeletons; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java index 3563e0505..319abc37c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java @@ -17,13 +17,13 @@ public class UltimateNinja extends Ultimate { private static final double CHARGE_PER_SECOND = 0.4; - private static final int SPEED_AMPLIFiER = 1; + private static final int SPEED_AMPLIFIER = 1; private long _length; public UltimateNinja(long length) { - super("Blood Forge", new String[] {}); + super("Ancient Blade", new String[] {}); _length = length; } @@ -49,7 +49,7 @@ public class UltimateNinja extends Ultimate super.activate(player); player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD)); - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) ((_length / 1000) * 20), SPEED_AMPLIFiER)); + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) ((_length / 1000) * 20), SPEED_AMPLIFIER)); UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 0, 0, 0, 1F, 100, ViewDist.NORMAL); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java index c4494c875..2690d1e3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java @@ -25,7 +25,7 @@ public class UltimatePyromancer extends Ultimate public UltimatePyromancer() { - super("Flare Blitz", new String[] {}); + super("Pincushion", new String[] {}); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java index 7cdc87d35..25d347b1f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.FireworkEffect.Type; -import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -17,16 +16,20 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; + +import com.google.common.collect.Sets; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; 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 mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -38,7 +41,9 @@ public class UltimateSkyWarrior extends Ultimate { private static final double CHARGE_PER_SECOND = 0.4; - private static final long LAUNCHER_FIRE_DELAY = 1000; + private static final long LAUNCHER_FIRE_DELAY = 500; + private static final long LAUNCHER_MAX_TIME = 15000; + private static final int Y_INCREASE = 10; private double _damageTeleport; private double _radiusTeleport; @@ -50,7 +55,7 @@ public class UltimateSkyWarrior extends Ultimate public UltimateSkyWarrior(double damageTeleport, double radiusTeleport, double damageLauncher, double radiusLauncher, int rangeLauncher) { - super("Astral Arrows", new String[] {}); + super("Bombardment", new String[] {}); _damageTeleport = damageTeleport; _radiusTeleport = radiusTeleport; @@ -67,7 +72,7 @@ public class UltimateSkyWarrior extends Ultimate Location playerLocation = player.getLocation(); // This is to stop the players getting killed by the border if they were // teleported above it. - Location toTeleport = new Location(player.getWorld(), playerLocation.getX(), Math.min(Manager.GetGame().WorldData.MaxY - 3, playerLocation.getY() + 10), playerLocation.getZ()); + Location toTeleport = new Location(player.getWorld(), playerLocation.getX(), Math.min(Manager.GetGame().WorldData.MaxY - 3, playerLocation.getY() + Y_INCREASE), playerLocation.getZ()); toTeleport.setYaw(playerLocation.getYaw()); toTeleport.setPitch(playerLocation.getPitch()); @@ -79,7 +84,7 @@ public class UltimateSkyWarrior extends Ultimate player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -10)); player.teleport(toTeleport); - _data.add(new SkyWarriorData(player, block, 3)); + _data.add(new SkyWarriorData(player, block, 3, UtilInv.getAmount(player, Material.ARROW), System.currentTimeMillis())); player.getInventory().clear(); @@ -90,21 +95,31 @@ public class UltimateSkyWarrior extends Ultimate player.getInventory().addItem(itemStack); } - UtilFirework.playFirework(playerLocation, Type.BALL_LARGE, Color.WHITE, false, false); - UtilFirework.playFirework(toTeleport, Type.BALL_LARGE, Color.WHITE, false, false); + Game game = Manager.GetGame(); + + UtilFirework.playFirework(playerLocation, Type.BALL, game.GetTeam(player).GetColorBase(), false, false); + UtilFirework.playFirework(toTeleport, Type.BALL, game.GetTeam(player).GetColorBase(), false, false); } @EventHandler public void onUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() == UpdateType.TICK) { - return; + for (SkyWarriorData data : _data) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getPlayer().getLocation().subtract(0, 0.5, 0), 0.5F, 0.25F, 0.5F, 0.01F, 6, ViewDist.MAX); + } } - - for (SkyWarriorData data : _data) + else if (event.getType() == UpdateType.FAST) { - UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getPlayer().getLocation().subtract(0, 0.5, 0), 0.5F, 0.25F, 0.5F, 0.01F, 6, ViewDist.MAX); + for (SkyWarriorData data : _data) + { + if (UtilTime.elapsed(data.getStartTimeStamp(), LAUNCHER_MAX_TIME)) + { + cancel(data.getPlayer()); + } + } } } @@ -124,53 +139,25 @@ public class UltimateSkyWarrior extends Ultimate return; } - if (!Recharge.Instance.use(player, "Sky Launcher", LAUNCHER_FIRE_DELAY, true, false)) + if (!Recharge.Instance.use(player, GetName(), LAUNCHER_FIRE_DELAY, true, false)) { return; } player.getWorld().playSound(player.getLocation(), Sound.FIREWORK_BLAST, 5, 1); - // Particle Trail - Block lastParticle = player.getLocation().getBlock(); - - double curRange = 0; - while (curRange <= _rangeLauncher) - { - Location newTarget = player.getLocation().add(new Vector(0, 0.2, 0)).add(player.getLocation().getDirection().multiply(curRange)); - - if (!UtilBlock.airFoliage(newTarget.getBlock()) || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) - { - if (newTarget.getBlock().getType() != Material.BARRIER) - { - break; - } - } - - // Progress Forwards - curRange += 0.2; - - // Particles - if (!lastParticle.equals(newTarget.getBlock())) - { - UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, lastParticle.getLocation(), 0, 0, 0, 0.001F, 1, ViewDist.LONG); - } - - lastParticle = newTarget.getBlock(); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, _rangeLauncher, Sets.newHashSet(Material.BARRIER), ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { } - - // Modify Range - curRange -= 0.4; - if (curRange < 0) - curRange = 0; - - // Destination - Location location = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0))); - + + Location location = lineParticle.getDestination(); + // Damage Players for (Player other : UtilPlayer.getNearby(location, _radiusLauncher)) { - Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damageLauncher, true, true, false, player.getName(), GetName() + " Launcher"); + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damageLauncher, true, true, false, player.getName(), GetName()); } UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1F, 1, ViewDist.LONG); @@ -190,7 +177,6 @@ public class UltimateSkyWarrior extends Ultimate player.getInventory().clear(); Kit.GiveItems(player); - player.getInventory().addItem(Quiver.SUPER_ARROW); player.setWalkSpeed(0.2F); player.removePotionEffect(PotionEffectType.JUMP); @@ -200,6 +186,11 @@ public class UltimateSkyWarrior extends Ultimate data.getBlock().setType(Material.AIR); + for (int i = 0; i < data.getPreviousArrows(); i++) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + } + boolean found = false; for (Player other : game.GetPlayers(true)) @@ -211,11 +202,11 @@ public class UltimateSkyWarrior extends Ultimate if (game.GetTeam(player).equals(game.GetTeam(other))) { - UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getEyeLocation(), 0.5F, 0.5F, 0.5F, 1F, 20, ViewDist.LONG); - UtilParticle.PlayParticleToAll(ParticleType.FLAME, other.getEyeLocation(), 0.5F, 0.5F, 0.5F, 1F, 20, ViewDist.LONG); - player.sendMessage(F.main("Game", "You were teleported to " + other.getName())); + player.sendMessage(F.main("Game", "You were teleported to " + F.elem(other.getName()) + ".")); player.teleport(other); - + other.getWorld().strikeLightningEffect(other.getLocation()); + UtilFirework.playFirework(other.getLocation(), Type.STAR, game.GetTeam(player).GetColorBase(), false, false); + for (Player toDamage : UtilPlayer.getNearby(other.getEyeLocation(), _radiusTeleport)) { Manager.GetDamage().NewDamageEvent(toDamage, player, null, DamageCause.CUSTOM, _damageTeleport, false, true, false, player.getName(), GetName() + " Teleportation"); @@ -233,6 +224,21 @@ public class UltimateSkyWarrior extends Ultimate _data.remove(data); } + + @Override + public boolean isUsable(Player player) + { + for (int i = 2; i <= Y_INCREASE; i++) + { + if (player.getLocation().add(0, i, 0).getBlock().getType() != Material.AIR) + { + player.sendMessage(F.main("Game", "You do not have enough room to use this!"));; + return false; + } + } + + return true; + } @Override public double getChargeIncreasePerSecond() @@ -265,12 +271,16 @@ public class UltimateSkyWarrior extends Ultimate private Player _player; private Block _block; private int _shotsLeft; + private int _previousArrows; + private long _startTimeStamp; - public SkyWarriorData(Player player, Block block, int shots) + public SkyWarriorData(Player player, Block block, int shots, int previousArrows, long startTimeStamp) { _player = player; _block = block; _shotsLeft = shots; + _previousArrows = previousArrows; + _startTimeStamp = startTimeStamp; } public void setShotsLeft(int slotsLeft) @@ -292,6 +302,16 @@ public class UltimateSkyWarrior extends Ultimate { return _shotsLeft; } + + public int getPreviousArrows() + { + return _previousArrows; + } + + public long getStartTimeStamp() + { + return _startTimeStamp; + } } }