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 index 04945be36..5feab31a7 100644 --- 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 @@ -1,9 +1,6 @@ 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; @@ -22,31 +19,25 @@ import mineplex.core.common.util.UtilParticle.ViewDist; public class LineParticle { - private Location _start; + private final Location _start; private Vector _direction; private Location _lastLocation; private double _curRange; - private double _incrementedRange; - private double _maxRange; + private final double _incrementedRange; + private final double _maxRange; - private Set _ignoredTypes; private boolean _ignoreAllBlocks; - private ParticleType _particleType; - private Player[] _toDisplay; + private final ParticleType _particleType; + private final Player[] _toDisplay; public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, ParticleType particleType, Player... toDisplay) { - this(start, null, direction, incrementedRange, maxRange, null, particleType, toDisplay); + this(start, null, direction, incrementedRange, maxRange, particleType, 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) + public LineParticle(Location start, Location end, Vector direction, double incrementedRange, double maxRange, ParticleType particleType, Player... toDisplay) { _start = start; _direction = direction; @@ -55,7 +46,6 @@ public class LineParticle _curRange = 0; _incrementedRange = incrementedRange; _maxRange = maxRange; - _ignoredTypes = ignoredTypes; _particleType = particleType; _toDisplay = toDisplay; @@ -69,8 +59,7 @@ public class LineParticle /** * Advances the line. * - * @return true when the line has reached its target or has collided with a - * block with a type contained in _ignoredTypes. + * @return true when the line has reached its target or has collided with a solid block. */ public boolean update() { @@ -84,17 +73,14 @@ public class LineParticle _lastLocation = newTarget; - if (!_ignoreAllBlocks && !(UtilBlock.airFoliage(newTarget.getBlock()) && UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))) + if (!_ignoreAllBlocks && UtilBlock.solid(newTarget.getBlock()) && UtilBlock.solid(newTarget.getBlock().getRelative(BlockFace.UP))) { - if (_ignoredTypes == null || !_ignoredTypes.contains(newTarget.getBlock().getType())) - { - done = true; - } + done = true; } _curRange += _incrementedRange; - UtilParticle.PlayParticle(_particleType, newTarget, 0, 0, 0, 0.001F, 1, ViewDist.LONG, _toDisplay); + UtilParticle.PlayParticle(_particleType, newTarget, null, 0, 1, ViewDist.LONG, _toDisplay); return done; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java index 2647564fa..932e6a78e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java @@ -119,7 +119,7 @@ public class MorphAnath extends MorphGadget player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2, 0.5F); - LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, null, ParticleType.LAVA, UtilServer.getPlayers()); + LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, ParticleType.LAVA, UtilServer.getPlayers()); particle.setIgnoreAllBlocks(true); Manager.runSyncTimer(new BukkitRunnable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java index 4a1cc5d7c..0d67ff1c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java @@ -144,7 +144,7 @@ public class MorphHattori extends MorphGadget return; } - LineParticle lineParticle = new LineParticle(start, start.getDirection(), 0.8, 15, null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + LineParticle lineParticle = new LineParticle(start, start.getDirection(), 0.8, 15, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); while (!lineParticle.update()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java b/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java index bc544dcec..770d4d0a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java @@ -3476,6 +3476,24 @@ public enum GameKit ) ), + // Squid Shooter + SQUID_SHOOTER + ( + 0, + GameDisplay.SquidShooter, + "Retro Squid", + null, + new String[] + { + + }, + new KitEntityData<> + ( + Squid.class, + new ItemStack(Material.INK_SACK) + ) + ), + // Survival Games SG_AXEMAN diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 62194eb58..33243957f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -92,6 +92,7 @@ import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; import nautilus.game.arcade.game.games.snowfight.SnowFight; import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.games.spleef.Spleef; +import nautilus.game.arcade.game.games.squidshooters.SquidShooters; import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewSolo; import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewTeams; import nautilus.game.arcade.game.games.turfforts.TurfForts; @@ -224,6 +225,8 @@ public enum GameType implements Voteable CakeWars4(CakeWars.class, GameDisplay.CakeWars4), CakeWarsDuos(CakeWarsDuos.class, GameDisplay.CakeWarsDuos), + SquidShooters(SquidShooters.class, GameDisplay.SquidShooter), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/alieninvasion/Beam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/alieninvasion/Beam.java index bfbff6594..b4e1468ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/alieninvasion/Beam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/alieninvasion/Beam.java @@ -25,7 +25,7 @@ public class Beam extends LineParticle public Beam(ArcadeManager manager, int id, BeamSource source, Location target) { - super(source.getSource(), target, null, 1, Integer.MAX_VALUE, null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + super(source.getSource(), target, null, 1, Integer.MAX_VALUE, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); _manager = manager; _id = id; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 4b4eb1fdb..ffe501167 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -54,7 +54,7 @@ public class SkillBurnBeam extends HeroSkill useSkill(player); - LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, null, ParticleType.LAVA, UtilServer.getPlayers()); + LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, ParticleType.LAVA, UtilServer.getPlayers()); particle.setIgnoreAllBlocks(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 217751e16..c996289c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -99,7 +99,7 @@ public class DashSkill extends HeroSkill direction.setY(0); } - LineParticle particle = new LineParticle(player.getEyeLocation(), direction, 0.8, _range, null, _particleType, UtilServer.getPlayers()); + LineParticle particle = new LineParticle(player.getEyeLocation(), direction, 0.8, _range, _particleType, UtilServer.getPlayers()); while (!particle.update()) { 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 541854a00..6af7560e1 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 @@ -18,8 +18,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import com.google.common.collect.Sets; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; @@ -35,6 +33,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.quiver.Quiver; @@ -157,7 +156,7 @@ public class UltimateSkyWarrior extends UltimatePerk player.getWorld().playSound(player.getLocation(), Sound.FIREWORK_BLAST, 5, 1); - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, _rangeLauncher, Sets.newHashSet(Material.BARRIER), ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, _rangeLauncher, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); while (!lineParticle.update()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/perks/PerkMagnetism.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/perks/PerkMagnetism.java index 810a6c138..0056334b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/perks/PerkMagnetism.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/perks/PerkMagnetism.java @@ -78,7 +78,7 @@ public class PerkMagnetism extends SkywarsPerk Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName()); - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), ParticleType.FIREWORKS_SPARK, UtilServer .getPlayers()); while (!lineParticle.update()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java index 486149217..5f17fce67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/enderman/PerkBlink.java @@ -91,7 +91,7 @@ public class PerkBlink extends SmashPerk return; } - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTATION, _range, null, ParticleType.SMOKE, UtilServer.getPlayers()); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTATION, _range, ParticleType.SMOKE, UtilServer.getPlayers()); while (!lineParticle.update()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java index 1e5a8d420..d65635b53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/guardian/SmashAnimationData.java @@ -132,7 +132,7 @@ public class SmashAnimationData continue; } - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), _target.getEyeLocation(), vector, 0.2, offset, null, ParticleType.WITCH_MAGIC, UtilServer.getPlayers()); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), _target.getEyeLocation(), vector, 0.2, offset, ParticleType.WITCH_MAGIC, UtilServer.getPlayers()); while (!lineParticle.update()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/SquidShooters.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/SquidShooters.java new file mode 100644 index 000000000..497fea84c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/SquidShooters.java @@ -0,0 +1,350 @@ +package nautilus.game.arcade.game.games.squidshooters; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import com.mineplex.anticheat.checks.move.Glide; +import com.mineplex.anticheat.checks.move.HeadRoll; +import com.mineplex.anticheat.checks.move.Speed; + +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.disguise.disguises.DisguiseSquid; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.squidshooters.kit.KitRetroSquid; +import nautilus.game.arcade.kit.Kit; + +public class SquidShooters extends SoloGame +{ + + private static final int KILLS_TO_WIN = 5; + private static final int MAX_DISPLAY = 14; + private static final String[] DESCRIPTION = + { + "Hold " + C.cYellow + "Sneak" + C.Reset + " to swim.", + "Stay in the Water.", + "You cannot swim when hit.", + "First squid to " + C.cYellow + KILLS_TO_WIN + C.Reset + " kills wins." + }; + + private final Map _kills = new HashMap<>(); + private final Set _inAir = new HashSet<>(); + + public SquidShooters(ArcadeManager manager) + { + super(manager, GameType.SquidShooters, new Kit[] + { + new KitRetroSquid(manager), + }, DESCRIPTION); + + PrepareFreeze = false; + DamageTeamSelf = true; + DeathOut = false; + NightVision = true; + WorldTimeSet = 6000; + + GlideCheckEnabled = false; + AntiHack antiHack = Managers.get(AntiHack.class); + antiHack.addIgnoredCheck(Speed.class); + antiHack.addIgnoredCheck(Glide.class); + antiHack.addIgnoredCheck(HeadRoll.class); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (!InProgress()) + { + return; + } + + Scoreboard.writeNewLine(); + + List alive = GetPlayers(true); + + if (alive.size() > MAX_DISPLAY) + { + alive = new ArrayList<>(alive); + + while (alive.size() > MAX_DISPLAY) + { + alive.remove(alive.size() - 1); + } + } + + Scoreboard.writeGroup(alive, player -> + { + Integer kills = _kills.get(player.getUniqueId()); + return kills == null ? null : Pair.create(C.cGreen + player.getName(), kills); + }, true); + + Scoreboard.draw(); + } + + @EventHandler + public void playerTeleportIn(PlayerPrepareTeleportEvent event) + { + Player player = event.GetPlayer(); + + player.setWalkSpeed(0.05F); + + DisguiseSquid disguise = new DisguiseSquid(player); + disguise.setName(getPlayersTeam().GetColor() + player.getName()); + disguise.setCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Manager.runSyncLater(() -> UtilTextMiddle.display(null, C.cYellow + "Hold Sneak to Swim", 10, 40, 10, UtilServer.getPlayers()), 20); + } + + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !IsLive()) + { + return; + } + + for (Player player : GetPlayers(true)) + { + if (!player.isSneaking() || player.hasPotionEffect(PotionEffectType.SLOW)) + { + continue; + } + + Vector direction = player.getLocation().getDirection(); + boolean inAirPast = _inAir.contains(player); + boolean inAirNow = !UtilEnt.isInWater(player); + + // Entering water + if (inAirPast && !inAirNow) + { + _inAir.remove(player); + } + // Leaving water + else if (!inAirPast && inAirNow) + { + _inAir.add(player); + } + // Already in air + else if (inAirNow) + { + continue; + } + // Already in water + else + { + direction.multiply(0.5); + } + + // If players are sneaking on the edge of a block and looking down (positive pitch). + // They won't have downwards velocity applied to them. So for one tick we give them a + // slight vertical velocity to fix this. + if (direction.getY() < 0) + { + Pair box = UtilEnt.getSideStandingBox(player); + Location min = box.getLeft(), max = box.getRight(); + + outerLoop: + for (int x = min.getBlockX(); x <= max.getBlockX(); x++) + { + for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) + { + Block block = player.getLocation().add(x, -0.5, z).getBlock(); + + if (UtilBlock.solid(block)) + { + direction.setY(0.01); + break outerLoop; + } + } + } + } + + UtilAction.velocity(player, direction); + } + } + + @EventHandler + public void updateHunger(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !InProgress()) + { + return; + } + + for (Player player : GetPlayers(true)) + { + if (UtilEnt.isInWater(player)) + { + UtilPlayer.hunger(player, 2); + } + else + { + UtilPlayer.hunger(player, -2); + + if (player.getFoodLevel() == 0) + { + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.SUFFOCATION, 2, false, true, true, GetName(), "Suffocation"); + } + } + + if (!player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, Integer.MAX_VALUE, 0, false, false)); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void playerDeath(CombatDeathEvent event) + { + CombatComponent killer = event.GetLog().GetKiller(); + + if (killer == null || !killer.IsPlayer()) + { + return; + } + + _kills.compute(killer.getUniqueIdOfEntity(), (k, v) -> _kills.getOrDefault(k, 0) + 1); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _kills.remove(player.getUniqueId()); + _inAir.remove(player); + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.GetCause() == DamageCause.ENTITY_ATTACK) + { + event.SetCancelled("Squid Melee Attack"); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List alive = GetPlayers(true); + + if (alive.isEmpty()) + { + SetState(GameState.End); + return; + } + + boolean end = alive.size() == 1; + + for (int kills : _kills.values()) + { + if (kills >= KILLS_TO_WIN) + { + end = true; + break; + } + } + + if (!end) + { + return; + } + + List places = alive.stream() + .sorted(Comparator.comparing(player -> _kills.getOrDefault(((Player) player).getUniqueId(), 0)).reversed()) + .collect(Collectors.toList()); + + if (!places.isEmpty()) + { + AddGems(places.get(0), 20, "1st Place", false, false); + } + if (places.size() > 1) + { + AddGems(places.get(1), 15, "2nd Place", false, false); + } + if (places.size() > 2) + { + AddGems(places.get(2), 10, "3rd Place", false, false); + } + + AnnounceEnd(places); + SetState(GameState.End); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void preventMovement(CustomDamageEvent event) + { + if (!IsLive()) + { + return; + } + + Player damagee = event.GetDamageePlayer(); + + if (event.IsCancelled() || damagee == null) + { + return; + } + + damagee.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 15, 0, false, false), true); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/kit/KitRetroSquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/kit/KitRetroSquid.java new file mode 100644 index 000000000..cd0ecee63 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooters/kit/KitRetroSquid.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.squidshooters.kit; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.game.kit.GameKit; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; + +public class KitRetroSquid extends Kit +{ + + private static final String NAME = "Squid Laser"; + private static final ItemStack[] PLAYER_ITEMS = + { + new ItemBuilder(Material.IRON_AXE) + .setTitle(C.cYellowB + "Right-Click" + C.cWhiteB + " - " + C.cGreenB + NAME) + .setUnbreakable(true) + .build() + }; + + public KitRetroSquid(ArcadeManager manager) + { + super(manager, GameKit.SQUID_SHOOTER); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @EventHandler(priority = EventPriority.HIGH) + public void playerInteract(PlayerInteractEvent event) + { + if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + Block block = event.getClickedBlock(); + + if (!HasKit(player) || !UtilItem.isAxe(itemStack) || UtilBlock.usable(block) || !Recharge.Instance.use(player, NAME, 1000, false, true)) + { + return; + } + + event.setCancelled(true); + + Location location = player.getEyeLocation(); + location.add(location.getDirection()); + location.getWorld().playSound(location, Sound.FIREWORK_LAUNCH, 1, 1); + + LineParticle lineParticle = new LineParticle(location, location.getDirection(), 0.3, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + Location from = lineParticle.getLastLocation().subtract(0, 1, 0); + Player closet = UtilPlayer.getClosest(from, 2, player); + + if (closet == null) + { + continue; + } + + from = closet.getLocation(); + + UtilFirework.playFirework(from.clone().add(0, 1, 0), FireworkEffect.builder() + .with(Type.BALL_LARGE) + .withColor(Color.AQUA) + .build()); + + UtilPlayer.getInRadius(from, 2).forEach((hit, scale) -> + { + if (player.equals(hit)) + { + return; + } + + Manager.GetDamage().NewDamageEvent(hit, player, null, DamageCause.CUSTOM, 15 * scale, true, true, true, player.getName(), GetName()); + }); + + break; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java index b54c5ab1d..22b230dd8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java @@ -6,7 +6,6 @@ import java.util.UUID; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -14,8 +13,6 @@ import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; -import com.google.common.collect.Sets; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilItem; @@ -24,6 +21,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; import mineplex.core.recharge.Recharge; + import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.kit.Perk; @@ -81,7 +79,7 @@ public class PerkDash extends Perk return; } - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, _distance, Sets.newHashSet(Material.RAILS), ParticleType.FIREWORKS_SPARK, + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, _distance, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); Set hitPlayers = new HashSet<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 85d2c40f5..22e7740e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -52,13 +52,26 @@ public class PerkLazer extends Perk private float _knockbackMagnitude; private double _range; - private Set _active = new HashSet<>(); + private final Set _active = new HashSet<>(); public PerkLazer() { super("Static Laser", new String[] { C.cYellow + "Hold Block" + C.cGray + " with Sword to use " + C.cGreen + "Static Laser" }); } + public PerkLazer(String name, long recharge, float chargePerTick, float hitBoxRadius, float damageRadius, int damage, float knockbackMagnitude, double range) + { + super(name); + + _recharge = recharge; + _chargePerTick = chargePerTick; + _hitBoxRadius = hitBoxRadius; + _damageRadius = damageRadius; + _damage = damage; + _knockbackMagnitude = knockbackMagnitude; + _range = range; + } + @Override public void setupValues() { @@ -180,7 +193,7 @@ public class PerkLazer extends Perk return; } - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTATION, _range * player.getExp(), null, ParticleType.FIREWORKS_SPARK, + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), INCREMENTATION, _range * player.getExp(), ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); particleLoop: while (!lineParticle.update()) @@ -237,7 +250,7 @@ public class PerkLazer extends Perk event.AddKnockback(GetName(), _knockbackMagnitude); } - public void setWoolColor(Player player, DyeColor color) + private void setWoolColor(Player player, DyeColor color) { DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);