From f00b7740561256aadeb14012b8cc9cb4ae517094 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Nov 2017 23:07:32 +0000 Subject: [PATCH] More CC stuff --- .../game/games/christmas/ChristmasCommon.java | 39 +++- .../game/games/christmasnew/ChristmasNew.java | 10 +- .../section/SectionChallenge.java | 2 +- .../christmasnew/section/five/Section5.java | 128 ++++++++++++ .../section/five/SnowmenKong.java | 34 ++++ .../SwitchParkour.java} | 57 +++++- .../christmasnew/section/four/MobDefense.java | 184 ++++++++++++++++++ .../christmasnew/section/four/Section4.java | 46 +++-- .../christmasnew/section/six/Section6.java | 80 ++++++++ 9 files changed, 543 insertions(+), 37 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/Section5.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SnowmenKong.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/{one/TreeParkour.java => five/SwitchParkour.java} (68%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/Section6.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/ChristmasCommon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/ChristmasCommon.java index d23add5c4..5c4868c8a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/ChristmasCommon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/ChristmasCommon.java @@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.explosion.ExplosionEvent; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.updater.UpdateType; @@ -52,7 +53,7 @@ public class ChristmasCommon extends SoloGame { private static final int BARRIER_BREAK_SQUARED = 400; - private static final int MAX_FALL_DISTANCE = 20; + private static final int MIN_Y = 50; protected final List
_sections; private Section _currentSection; @@ -187,11 +188,17 @@ public class ChristmasCommon extends SoloGame UtilServer.RegisterEvents(_currentSection); _currentSection.start(); + onNextSection(_currentSection); getSleigh().SetTarget(_currentSection.getSleighTarget()); } } + public void onNextSection(Section section) + { + + } + private Section getNext() { return _sections.isEmpty() ? null : _sections.remove(0); @@ -269,13 +276,23 @@ public class ChristmasCommon extends SoloGame if (event.GetCause() == DamageCause.FALL) { - if (event.GetDamageeEntity().getFallDistance() > MAX_FALL_DISTANCE) + event.SetCancelled("Fall Damage"); + } + } + + @EventHandler + public void updateDeath(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !IsLive()) + { + return; + } + + for (Player player : GetPlayers(true)) + { + if (player.getLocation().getY() < MIN_Y) { - event.AddMod("Fall Damage", 100); - } - else - { - event.SetCancelled("Fall Damage"); + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 100, false, true, true, GetName(), "Falling"); } } } @@ -370,9 +387,15 @@ public class ChristmasCommon extends SoloGame event.setDroppedExp(0); } + @EventHandler(priority = EventPriority.LOWEST) + public void explosion(ExplosionEvent event) + { + event.GetBlocks().clear(); + } + public void sendSantaMessage(String message, ChristmasNewAudio audio) { - GetPlayers(true).forEach(player -> sendSantaMessage(player, message, audio)); + GetPlayers(false).forEach(player -> sendSantaMessage(player, message, audio)); } public void sendSantaMessage(Player player, String message, ChristmasNewAudio audio) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java index c95c3a006..59f4b81ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java @@ -13,8 +13,10 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.games.christmas.ChristmasCommon; import nautilus.game.arcade.game.games.christmas.kits.KitPlayer; +import nautilus.game.arcade.game.games.christmasnew.section.five.Section5; import nautilus.game.arcade.game.games.christmasnew.section.four.Section4; import nautilus.game.arcade.game.games.christmasnew.section.one.Section1; +import nautilus.game.arcade.game.games.christmasnew.section.six.Section6; import nautilus.game.arcade.game.games.christmasnew.section.three.Section3; import nautilus.game.arcade.game.games.christmasnew.section.two.Section2; import nautilus.game.arcade.kit.Kit; @@ -46,10 +48,12 @@ public class ChristmasNew extends ChristmasCommon { new KitPlayer(manager) }, DESCRIPTION); + + WorldTimeSet = 4000; } // Take the parse at the purple bridge - // /parse600 129 87 88 137 165 14 110 179 + // /parse600 129 88 137 165 14 110 179 21 22 121 @Override public void ParseData() { @@ -64,7 +68,9 @@ public class ChristmasNew extends ChristmasCommon _sections.add(new Section1(this, targets.remove(0), presents.remove(0), presents.remove(0))); _sections.add(new Section2(this, targets.remove(0), presents.remove(0), presents.remove(0))); _sections.add(new Section3(this, targets.remove(0), presents.remove(0))); - _sections.add(new Section4(this, targets.remove(0), presents.remove(0))); + _sections.add(new Section4(this, targets.remove(0), presents.remove(0), presents.remove(0))); + _sections.add(new Section5(this, targets.remove(0), presents.remove(0), presents.remove(0))); + _sections.add(new Section6(this, targets.remove(0), presents.remove(0))); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/SectionChallenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/SectionChallenge.java index 8ad348fbe..e8e344a7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/SectionChallenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/SectionChallenge.java @@ -22,7 +22,7 @@ public abstract class SectionChallenge extends ListenerComponent implements Sect protected final WorldData _worldData; private final Present _present; - private final Section _section; + protected final Section _section; protected final List _entities; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/Section5.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/Section5.java new file mode 100644 index 000000000..6826f3df4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/Section5.java @@ -0,0 +1,128 @@ +package nautilus.game.arcade.game.games.christmasnew.section.five; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.FallingBlock; +import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; +import nautilus.game.arcade.game.games.christmasnew.section.Section; +import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge; + +public class Section5 extends Section +{ + + private static final byte[] COLOURS = { 14, 1, 4, 5, 3, 9, 11, 10, 6 }; + + private final List _bridgeBlocks; + private final Set _fallingBlocks; + private final int _solidifyAt; + + private int _colourIndex; + + public Section5(ChristmasNew host, Location sleighTarget, Location... presents) + { + super(host, sleighTarget); + + _bridgeBlocks = _worldData.GetDataLocs("PURPLE"); + _fallingBlocks = new HashSet<>(); + _solidifyAt = _bridgeBlocks.get(0).getBlockY(); + + registerChallenges( + new SnowmenKong(host, presents[1], this) + ); + } + + @Override + public void onRegister() + { + AtomicInteger lowestZ = new AtomicInteger(Integer.MAX_VALUE); + + for (Location location : _bridgeBlocks) + { + if (lowestZ.get() > location.getBlockZ()) + { + lowestZ.set(location.getBlockZ()); + } + } + + _host.getArcadeManager().runSyncTimer(new BukkitRunnable() + { + + @Override + public void run() + { + if (++_colourIndex == COLOURS.length) + { + _colourIndex = 0; + } + + byte colour = COLOURS[_colourIndex]; + int z = lowestZ.getAndIncrement(); + + _bridgeBlocks.removeIf(location -> + { + if (location.getBlockZ() == z) + { + FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0, 8, 0), Material.WOOL, colour); + fallingBlock.setDropItem(false); + fallingBlock.setHurtEntities(false); + return true; + } + + return false; + }); + + if (_bridgeBlocks.isEmpty()) + { + cancel(); + } + } + }, 10, 3); + } + + @Override + public void onUnregister() + { + + } + + @EventHandler + public void updateFallingBlocks(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + _fallingBlocks.removeIf(block -> + { + Location location = block.getLocation(); + + if (location.getBlockY() <= _solidifyAt) + { + MapUtil.QuickChangeBlockAt(location, block.getMaterial(), block.getBlockData()); + + if (Math.random() > 0.8) + { + location.getWorld().playEffect(location, Effect.STEP_SOUND, block.getMaterial(), block.getBlockData()); + } + + return true; + } + + return false; + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SnowmenKong.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SnowmenKong.java new file mode 100644 index 000000000..c8945c32b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SnowmenKong.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.christmasnew.section.five; + +import org.bukkit.Location; + +import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; +import nautilus.game.arcade.game.games.christmasnew.section.Section; +import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge; + +class SnowmenKong extends SectionChallenge +{ + + SnowmenKong(ChristmasNew host, Location present, Section section) + { + super(host, present, section); + } + + @Override + public void onPresentCollect() + { + + } + + @Override + public void onRegister() + { + + } + + @Override + public void onUnregister() + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/one/TreeParkour.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SwitchParkour.java similarity index 68% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/one/TreeParkour.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SwitchParkour.java index 3714669f2..04e01e6af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/one/TreeParkour.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/five/SwitchParkour.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.christmasnew.section.one; +package nautilus.game.arcade.game.games.christmasnew.section.five; import java.util.List; @@ -15,31 +15,42 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilPlayer; import mineplex.core.hologram.Hologram; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; import nautilus.game.arcade.game.games.christmasnew.section.Section; import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge; -class TreeParkour extends SectionChallenge +class SwitchParkour extends SectionChallenge { + private final List _black; + private final List _white; + + private boolean _blackSolid; + private boolean _removeTick; + private final Location _checkpointTrigger; private final Hologram _checkpointHologram; private final List _checkpoint; private boolean _hasCheckpointed; - TreeParkour(ChristmasNew host, Location present, Section section) + SwitchParkour(ChristmasNew host, Location present, Section section) { super(host, present, section); + _black = _worldData.GetDataLocs("BLACK"); + _white = _worldData.GetDataLocs("WHITE"); + _checkpointTrigger = _worldData.GetCustomLocs(String.valueOf(Material.LAPIS_BLOCK.getId())).get(0).getBlock().getLocation(); _checkpointHologram = new Hologram(host.getArcadeManager().getHologramManager(), _checkpointTrigger.clone().add(0.5, 1, 0.5), C.cGoldB + "Checkpoint") .setInteraction((player, clickType) -> activateCheckpoint()); _checkpoint = _worldData.GetCustomLocs(String.valueOf(Material.LAPIS_ORE.getId())); _checkpoint.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); - MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.LEVER, (byte) 4); + MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.LEVER, (byte) 3); } @Override @@ -60,6 +71,42 @@ class TreeParkour extends SectionChallenge _checkpointHologram.stop(); } + @EventHandler + public void updateSolids(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + if (_removeTick) + { + if (_blackSolid) + { + _white.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); + } + else + { + _black.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); + } + } + else + { + if (_blackSolid) + { + _white.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 14)); + } + else + { + _black.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 13)); + } + + _blackSolid = !_blackSolid; + } + + _removeTick = !_removeTick; + } + @EventHandler public void checkpointInteract(PlayerInteractEvent event) { @@ -106,7 +153,7 @@ class TreeParkour extends SectionChallenge if (location.getY() > y) { location.getWorld().playSound(location, Sound.PISTON_RETRACT, 1, 0.6F); - MapUtil.QuickChangeBlockAt(location, Material.WOOD_STAIRS, (byte) 1); + MapUtil.QuickChangeBlockAt(location, Material.COBBLESTONE_STAIRS, (byte) 1); return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java new file mode 100644 index 000000000..be3453703 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java @@ -0,0 +1,184 @@ +package nautilus.game.arcade.game.games.christmasnew.section.four; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.entity.Blaze; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Golem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; +import nautilus.game.arcade.game.games.christmasnew.section.Section; +import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge; + +class MobDefense extends SectionChallenge +{ + + private static final int GENERATOR_HEALTH = 100; + private static final long WAVE_TIME = TimeUnit.SECONDS.toMillis(30); + private static final int WAVES = 4; + private static final int GENERATOR_RANGE_SQUARED = 36; + + private final List _mobSpawns; + private final Location _generator; + + private int _generatorHealth; + private long _start; + private long _lastWave; + private int _wave; + + MobDefense(ChristmasNew host, Location present, Section section, List mobSpawns, Location generator) + { + super(host, present, section); + + _mobSpawns = mobSpawns; + _generator = generator; + _generatorHealth = GENERATOR_HEALTH; + } + + @Override + public void onPresentCollect() + { + + } + + @Override + public void onRegister() + { + + } + + @Override + public void onUnregister() + { + + } + + boolean isComplete() + { + return _wave == WAVES; + } + + @EventHandler + public void updateMobs(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || _wave == WAVES) + { + return; + } + + if (_start == 0) + { + if (UtilMath.offsetSquared(_host.getSleigh().GetLocation(), _section.getSleighTarget()) < 36) + { + _start = System.currentTimeMillis(); + } + + return; + } + + if (UtilTime.elapsed(_lastWave, WAVE_TIME)) + { + _lastWave = System.currentTimeMillis(); + + _wave++; + _host.sendSantaMessage("Wave: " + _wave, null); + } + + int zombies = 0, skeletons = 0, creepers = 0, blazes = 0, golems = 0; + + switch (_wave) + { + case 1: + zombies = 1; + break; + case 2: + zombies = 2; + skeletons = 1; + break; + case 3: + zombies = 1; + creepers = 2; + break; + case 4: + zombies = 2; + blazes = 1; + + if (Math.random() < 0.2) + { + golems = 1; + } + break; + } + + spawnMob(Zombie.class, zombies); + spawnMob(Skeleton.class, skeletons); + spawnMob(Creeper.class, creepers); + spawnMob(Blaze.class, blazes); + spawnMob(Golem.class, golems); + } + + @EventHandler + public void updateTracking(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Entity entity : _entities) + { + if (!(entity instanceof Monster)) + { + continue; + } + + Creature creature = (Creature) entity; + LivingEntity target = creature.getTarget(); + Location targetLocation; + + if (target == null) + { + targetLocation = _generator; + } + else if (_generatorHealth > 0) + { + targetLocation = target.getLocation(); + } + else + { + targetLocation = _host.getSleigh().GetLocation(); + } + + if (UtilMath.offsetSquared(creature.getLocation(), _generator) < GENERATOR_RANGE_SQUARED) + { + _generatorHealth--; + } + + UtilEnt.CreatureMove(creature, targetLocation, 1.2F); + } + } + + private void spawnMob(Class clazz, int amount) + { + for (int i = 0; i < amount; i++) + { + spawn(UtilAlg.Random(_mobSpawns), clazz); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java index a3093926f..701c0d67c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java @@ -2,9 +2,10 @@ package nautilus.game.arcade.game.games.christmasnew.section.four; import org.bukkit.Location; +import mineplex.core.lifetimes.Component; + import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; import nautilus.game.arcade.game.games.christmasnew.section.Section; -import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge; public class Section4 extends Section { @@ -13,26 +14,10 @@ public class Section4 extends Section { super(host, sleighTarget); - registerChallenges(new SectionChallenge(host, presents[0], this) - { - @Override - public void onPresentCollect() - { - - } - - @Override - public void onRegister() - { - - } - - @Override - public void onUnregister() - { - - } - }); + registerChallenges( + new MobDefense(host, presents[0], this, _worldData.GetDataLocs("SILVER"), _worldData.GetCustomLocs("GEN LEFT").get(0)), + new MobDefense(host, presents[1], this, _worldData.GetDataLocs("GRAY"), _worldData.GetCustomLocs("GEN RIGHT").get(0)) + ); } @Override @@ -46,4 +31,23 @@ public class Section4 extends Section { } + + @Override + public boolean isComplete() + { + for (Component component : _components) + { + if (component instanceof MobDefense) + { + boolean complete = ((MobDefense) component).isComplete(); + + if (!complete) + { + return false; + } + } + } + + return super.isComplete(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/Section6.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/Section6.java new file mode 100644 index 000000000..c3b235f04 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/Section6.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.game.games.christmasnew.section.six; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.MapUtil; + +import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; +import nautilus.game.arcade.game.games.christmasnew.section.Section; + +public class Section6 extends Section +{ + + private static final int GATE_OPEN_DELAY = 200; + + private final List _gate; + + public Section6(ChristmasNew host, Location sleighTarget, Location... presents) + { + super(host, sleighTarget); + + _gate = _worldData.GetCustomLocs(String.valueOf(Material.ENDER_STONE.getId())); + } + + @Override + public void onRegister() + { + AtomicInteger lowestY = new AtomicInteger(Integer.MAX_VALUE); + + for (Location location : _gate) + { + if (lowestY.get() > location.getBlockY()) + { + lowestY.set(location.getBlockY()); + } + } + + _host.getArcadeManager().runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + int y = lowestY.getAndIncrement(); + + _gate.removeIf(location -> + { + if (location.getBlockY() == y) + { + MapUtil.QuickChangeBlockAt(location, Material.AIR); + return true; + } + + return false; + }); + + if (_gate.isEmpty()) + { + cancel(); + } + else + { + Location location = _gate.get(0); + + location.getWorld().playSound(location, Sound.PISTON_RETRACT, 1.5F, 0.8F); + } + } + }, GATE_OPEN_DELAY, 4); + } + + @Override + public void onUnregister() + { + + } +}