Finish the first 3 sections
This commit is contained in:
parent
eda592a35f
commit
faf0ebd1ef
@ -22,6 +22,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -43,6 +44,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.christmasnew.ChristmasNewAudio;
|
||||
import nautilus.game.arcade.game.games.christmasnew.section.Section;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
@ -50,14 +52,18 @@ public class ChristmasCommon extends SoloGame
|
||||
{
|
||||
|
||||
private static final int BARRIER_BREAK_SQUARED = 400;
|
||||
private static final int MAX_FALL_DISTANCE = 20;
|
||||
|
||||
protected final List<Section> _sections;
|
||||
private Section _currentSection;
|
||||
|
||||
private GameTeam _badGuys;
|
||||
|
||||
private List<Location> _barrier = new ArrayList<>();
|
||||
private List<Location> _barrier;
|
||||
private long _santaSayTime;
|
||||
|
||||
private Sleigh _sleigh;
|
||||
private Location _sleighSpawn;
|
||||
protected Location _sleighSpawn;
|
||||
private final IPacketHandler _reindeerPackets = new IPacketHandler()
|
||||
{
|
||||
|
||||
@ -119,6 +125,8 @@ public class ChristmasCommon extends SoloGame
|
||||
{
|
||||
super(manager, gameType, kits, gameDesc);
|
||||
|
||||
_sections = new ArrayList<>(6);
|
||||
|
||||
HungerSet = 20;
|
||||
PrepareFreeze = false;
|
||||
|
||||
@ -154,6 +162,41 @@ public class ChristmasCommon extends SoloGame
|
||||
AddTeam(_badGuys);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateSection(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || !IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentSection == null || _currentSection.isComplete())
|
||||
{
|
||||
if (_currentSection != null)
|
||||
{
|
||||
UtilServer.Unregister(_currentSection);
|
||||
_currentSection.end();
|
||||
}
|
||||
|
||||
_currentSection = getNext();
|
||||
|
||||
if (_currentSection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.RegisterEvents(_currentSection);
|
||||
_currentSection.start();
|
||||
|
||||
getSleigh().SetTarget(_currentSection.getSleighTarget());
|
||||
}
|
||||
}
|
||||
|
||||
private Section getNext()
|
||||
{
|
||||
return _sections.isEmpty() ? null : _sections.remove(0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void sleighSpawn(GameStateChangeEvent event)
|
||||
{
|
||||
@ -177,7 +220,12 @@ public class ChristmasCommon extends SoloGame
|
||||
|
||||
for (Location location : elfSpawns)
|
||||
{
|
||||
Villager elf = location.getWorld().spawn(UtilAlg.getRandomLocation(location, 2, 0, 2), Villager.class);
|
||||
if (Math.random() < 0.6)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Villager elf = location.getWorld().spawn(UtilAlg.getRandomLocation(location, 3, 0, 3), Villager.class);
|
||||
|
||||
elf.setBaby();
|
||||
elf.setAgeLock(true);
|
||||
@ -221,7 +269,14 @@ public class ChristmasCommon extends SoloGame
|
||||
|
||||
if (event.GetCause() == DamageCause.FALL)
|
||||
{
|
||||
event.SetCancelled("Fall Damage");
|
||||
if (event.GetDamageeEntity().getFallDistance() > MAX_FALL_DISTANCE)
|
||||
{
|
||||
event.AddMod("Fall Damage", 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.SetCancelled("Fall Damage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,6 +364,12 @@ public class ChristmasCommon extends SoloGame
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityDeath(EntityDeathEvent event)
|
||||
{
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
|
||||
public void sendSantaMessage(String message, ChristmasNewAudio audio)
|
||||
{
|
||||
GetPlayers(true).forEach(player -> sendSantaMessage(player, message, audio));
|
||||
|
@ -1,12 +1,22 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
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.four.Section4;
|
||||
import nautilus.game.arcade.game.games.christmasnew.section.one.Section1;
|
||||
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;
|
||||
|
||||
public class ChristmasNew extends ChristmasCommon
|
||||
@ -17,14 +27,44 @@ public class ChristmasNew extends ChristmasCommon
|
||||
|
||||
};
|
||||
|
||||
private final Comparator<Location> _locationComparator = (o1, o2) ->
|
||||
{
|
||||
double o1Dist = UtilMath.offsetSquared(o1, _sleighSpawn);
|
||||
double o2Dist = UtilMath.offsetSquared(o2, _sleighSpawn);
|
||||
|
||||
if (o1Dist == o2Dist)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return o1Dist > o2Dist ? 1 : -1;
|
||||
};
|
||||
|
||||
public ChristmasNew(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.ChristmasNew, new Kit[]
|
||||
{
|
||||
new KitPlayer(manager)
|
||||
}, DESCRIPTION);
|
||||
}
|
||||
|
||||
PrepareTime = 2000;
|
||||
// Take the parse at the purple bridge
|
||||
// /parse600 129 87 88 137 165 14 110 179
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
super.ParseData();
|
||||
|
||||
List<Location> presents = WorldData.GetDataLocs("LIME");
|
||||
presents.sort(_locationComparator);
|
||||
|
||||
List<Location> targets = WorldData.GetDataLocs("PINK");
|
||||
targets.sort(_locationComparator);
|
||||
|
||||
_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)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,18 +1,13 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.present;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.lifetimes.Component;
|
||||
|
||||
@ -21,7 +16,8 @@ public class Present implements Component
|
||||
|
||||
private static final ItemStack PRESENT = SkinData.PRESENT.getSkull();
|
||||
private static final int ROTATION_ITERATIONS = 20;
|
||||
private static final int ROTATION_DELTA_Y = 1 / ROTATION_ITERATIONS;
|
||||
private static final double ROTATION_DELTA_Y = 1D / ROTATION_ITERATIONS;
|
||||
private static final float ROTATION_DELTA_YAW = 360F / ROTATION_ITERATIONS;
|
||||
|
||||
private final Location _location;
|
||||
private final ArmorStand _stand;
|
||||
@ -35,21 +31,18 @@ public class Present implements Component
|
||||
{
|
||||
_location = location.clone();
|
||||
_location.setYaw(UtilMath.r(360));
|
||||
_stand = _location.getWorld().spawn(_location, ArmorStand.class);
|
||||
_stand = _location.getWorld().spawn(_location.clone().add(0, 0.25, 0), ArmorStand.class);
|
||||
_stand.setVisible(false);
|
||||
_stand.setGravity(false);
|
||||
_stand.setHelmet(PRESENT);
|
||||
_stand.setCustomName(C.cGreenB + "Present");
|
||||
_stand.setRemoveWhenFarAway(false);
|
||||
UtilEnt.ghost(_stand, true, false);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(_location, Material.STONE);
|
||||
MapUtil.QuickChangeBlockAt(_location, Material.SNOW_BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
_stand.setCustomNameVisible(true);
|
||||
MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, (byte) (Math.random() < 0.5 ? 14 : 5));
|
||||
}
|
||||
|
||||
@ -67,8 +60,10 @@ public class Present implements Component
|
||||
|
||||
public void updateRotation()
|
||||
{
|
||||
Entity entity = ((CraftEntity) _stand).getHandle();
|
||||
double newY = entity.locY + (_down ? -ROTATION_DELTA_Y : ROTATION_DELTA_Y);
|
||||
Location location = _stand.getLocation();
|
||||
|
||||
location.add(0, _down ? -ROTATION_DELTA_Y : ROTATION_DELTA_Y, 0);
|
||||
location.setYaw(location.getYaw() + ROTATION_DELTA_YAW);
|
||||
|
||||
if (++_iterations == 20)
|
||||
{
|
||||
@ -76,7 +71,7 @@ public class Present implements Component
|
||||
_down = !_down;
|
||||
}
|
||||
|
||||
entity.setPosition(entity.locX, newY, entity.locZ);
|
||||
_stand.teleport(location);
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
@ -86,7 +81,7 @@ public class Present implements Component
|
||||
|
||||
public boolean isColliding(Player player)
|
||||
{
|
||||
return UtilMath.offsetSquared(player, _stand) < 4;
|
||||
return UtilMath.offsetSquared(player, _stand) < 9;
|
||||
}
|
||||
|
||||
public boolean isCollected()
|
||||
|
@ -7,10 +7,12 @@ import java.util.List;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.lifetimes.SimpleLifetime;
|
||||
|
||||
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew;
|
||||
@ -31,12 +33,14 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
|
||||
protected final ChristmasNew _host;
|
||||
protected final WorldData _worldData;
|
||||
|
||||
private final Location _sleighTarget;
|
||||
private final List<SectionChallenge> _challenges;
|
||||
|
||||
public Section(ChristmasNew host)
|
||||
public Section(ChristmasNew host, Location sleighTarget)
|
||||
{
|
||||
_host = host;
|
||||
_worldData = host.WorldData;
|
||||
_sleighTarget = sleighTarget;
|
||||
_challenges = new ArrayList<>(2);
|
||||
_challenges.forEach(this::register);
|
||||
}
|
||||
@ -46,22 +50,15 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
|
||||
{
|
||||
super.start();
|
||||
onRegister();
|
||||
_challenges.forEach(challenge ->
|
||||
{
|
||||
challenge.onRegister();
|
||||
challenge.activate();
|
||||
}); }
|
||||
_challenges.forEach(SectionRegister::onRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() throws IllegalStateException
|
||||
{
|
||||
super.end();
|
||||
onUnregister();
|
||||
_challenges.forEach(challenge ->
|
||||
{
|
||||
challenge.onUnregister();
|
||||
challenge.deactivate();
|
||||
});
|
||||
_challenges.forEach(SectionRegister::onUnregister);
|
||||
}
|
||||
|
||||
protected void registerChallenges(SectionChallenge... challenges)
|
||||
@ -75,7 +72,7 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
|
||||
{
|
||||
for (SectionChallenge challenge : _challenges)
|
||||
{
|
||||
if (challenge.getPresent().isCollected())
|
||||
if (!challenge.getPresent().isCollected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -90,7 +87,7 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
|
||||
|
||||
for (SectionChallenge challenge : _challenges)
|
||||
{
|
||||
Present otherPresent =challenge.getPresent();
|
||||
Present otherPresent = challenge.getPresent();
|
||||
|
||||
if (present.equals(otherPresent))
|
||||
{
|
||||
@ -102,7 +99,18 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
|
||||
}
|
||||
}
|
||||
|
||||
Location location = present.getLocation();
|
||||
|
||||
_host.sendSantaMessage("Well done " + player.getName() + " you found a present!" + (left > 0 ? " Only " + left + " to go!" : ""), null);
|
||||
UtilFirework.launchFirework(present.getLocation(), FIREWORK_EFFECT, null, 2);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
UtilFirework.launchFirework(location, FIREWORK_EFFECT, null, UtilMath.r(3));
|
||||
}
|
||||
}
|
||||
|
||||
public Location getSleighTarget()
|
||||
{
|
||||
return _sleighTarget;
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,15 @@ public abstract class SectionChallenge extends ListenerComponent implements Sect
|
||||
private final Section _section;
|
||||
|
||||
protected final List<Entity> _entities;
|
||||
protected int _mobsPerSecond;
|
||||
protected int _maxMobs;
|
||||
|
||||
public SectionChallenge(ChristmasNew host, Location present, Section section)
|
||||
{
|
||||
_host = host;
|
||||
_worldData = host.WorldData;
|
||||
host.CreatureAllowOverride = true;
|
||||
_present = new Present(present);
|
||||
host.CreatureAllowOverride = false;
|
||||
section.register(_present);
|
||||
_section = section;
|
||||
_entities = new ArrayList<>();
|
||||
}
|
||||
@ -81,7 +82,7 @@ public abstract class SectionChallenge extends ListenerComponent implements Sect
|
||||
{
|
||||
_host.GetPlayers(true).forEach(player ->
|
||||
{
|
||||
if (!_present.isColliding(player))
|
||||
if (_present.isColliding(player))
|
||||
{
|
||||
_section.onPresentCollect(player, _present);
|
||||
_present.deactivate();
|
||||
|
@ -0,0 +1,49 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.four;
|
||||
|
||||
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;
|
||||
|
||||
public class Section4 extends Section
|
||||
{
|
||||
|
||||
public Section4(ChristmasNew host, Location sleighTarget, Location... presents)
|
||||
{
|
||||
super(host, sleighTarget);
|
||||
|
||||
registerChallenges(new SectionChallenge(host, presents[0], this)
|
||||
{
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ public class CaveMaze extends SectionChallenge
|
||||
{
|
||||
|
||||
private static final int MAX_MOBS = 25;
|
||||
private static final int HEALTH = 5;
|
||||
private static final ItemStack[] IN_HAND =
|
||||
{
|
||||
new ItemStack(Material.WOOD_SWORD),
|
||||
@ -32,7 +33,7 @@ public class CaveMaze extends SectionChallenge
|
||||
};
|
||||
|
||||
private final List<Location> _mobSpawns;
|
||||
private final List<Location> _quickOutWood;
|
||||
private final List<Location> _quickOutStone;
|
||||
private final List<Location> _quickOutAir;
|
||||
|
||||
CaveMaze(ChristmasNew host, Location present, Section section)
|
||||
@ -40,24 +41,24 @@ public class CaveMaze extends SectionChallenge
|
||||
super(host, present, section);
|
||||
|
||||
_mobSpawns = _worldData.GetDataLocs("BROWN");
|
||||
_quickOutWood = _worldData.GetCustomLocs(String.valueOf(Material.NETHERRACK.getId()));
|
||||
_quickOutStone = _worldData.GetCustomLocs(String.valueOf(Material.NETHERRACK.getId()));
|
||||
_quickOutAir = _worldData.GetCustomLocs(String.valueOf(Material.SOUL_SAND.getId()));
|
||||
|
||||
_quickOutWood.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
|
||||
_quickOutStone.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.STATIONARY_LAVA));
|
||||
_quickOutAir.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.IRON_FENCE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
_quickOutWood.forEach(location ->
|
||||
_quickOutStone.forEach(location ->
|
||||
{
|
||||
if (Math.random() > 0.95)
|
||||
{
|
||||
location.getWorld().playEffect(location, Effect.STEP_SOUND, Material.WOOD_STEP);
|
||||
location.getWorld().playEffect(location, Effect.STEP_SOUND, Material.COBBLESTONE);
|
||||
}
|
||||
|
||||
MapUtil.QuickChangeBlockAt(location, Material.WOOD_STEP);
|
||||
MapUtil.QuickChangeBlockAt(location, Material.COBBLESTONE);
|
||||
});
|
||||
_quickOutAir.forEach(location ->
|
||||
{
|
||||
@ -92,6 +93,8 @@ public class CaveMaze extends SectionChallenge
|
||||
|
||||
Skeleton skeleton = spawn(UtilAlg.Random(_mobSpawns), Skeleton.class);
|
||||
|
||||
skeleton.setHealth(HEALTH);
|
||||
skeleton.setMaxHealth(HEALTH);
|
||||
skeleton.getEquipment().setItemInHand(UtilMath.randomElement(IN_HAND));
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,37 @@ 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;
|
||||
|
||||
public class Section1 extends Section
|
||||
{
|
||||
|
||||
public Section1(ChristmasNew host, Location... presents)
|
||||
public Section1(ChristmasNew host, Location sleighTarget, Location... presents)
|
||||
{
|
||||
super(host);
|
||||
super(host, sleighTarget);
|
||||
|
||||
registerChallenges(
|
||||
new TreeParkour(host, presents[0], this),
|
||||
new CaveMaze(host, presents[1], this)
|
||||
new CaveMaze(host, presents[0], this),
|
||||
new SectionChallenge(host, presents[1], this)
|
||||
{
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,16 +27,19 @@ class TreeParkour extends SectionChallenge
|
||||
private final Hologram _checkpointHologram;
|
||||
private final List<Location> _checkpoint;
|
||||
|
||||
private boolean _hasCheckpointed;
|
||||
|
||||
TreeParkour(ChristmasNew host, Location present, Section section)
|
||||
{
|
||||
super(host, present, section);
|
||||
|
||||
_checkpointTrigger = _worldData.GetCustomLocs(String.valueOf(Material.LAPIS_BLOCK.getId())).get(0).getBlock().getLocation();
|
||||
_checkpointHologram = new Hologram(host.getArcadeManager().getHologramManager(), _checkpointTrigger, C.cGoldB + "Checkpoint")
|
||||
_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);
|
||||
MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.LEVER, (byte) 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +72,7 @@ class TreeParkour extends SectionChallenge
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (block == null || block.getType() != Material.LEVER || !_checkpointTrigger.equals(block))
|
||||
if (block == null || block.getType() != Material.LEVER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -79,6 +82,13 @@ class TreeParkour extends SectionChallenge
|
||||
|
||||
private void activateCheckpoint()
|
||||
{
|
||||
if (_hasCheckpointed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_hasCheckpointed = true;
|
||||
|
||||
_checkpointTrigger.getWorld().playSound(_checkpointTrigger, Sound.LEVEL_UP, 1, 0.5F);
|
||||
MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.AIR);
|
||||
_checkpointHologram.stop();
|
||||
@ -112,6 +122,6 @@ class TreeParkour extends SectionChallenge
|
||||
y--;
|
||||
}
|
||||
}
|
||||
}, 10, 10);
|
||||
}, 0, 10);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,117 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.three;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
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 CaveIn extends SectionChallenge
|
||||
{
|
||||
|
||||
private static final Material ALLOW_BREAK = Material.COBBLESTONE;
|
||||
|
||||
private final int _triggerZ;
|
||||
private final List<Location> _blocksToExplode;
|
||||
private final List<Location> _blocksToFall;
|
||||
private final List<Location> _blocksToClear;
|
||||
|
||||
private boolean _exploded;
|
||||
|
||||
CaveIn(ChristmasNew host, Location present, Section section)
|
||||
{
|
||||
super(host, present, section);
|
||||
|
||||
_triggerZ = _worldData.GetDataLocs("ORANGE").get(0).getBlockY();
|
||||
_blocksToExplode = _worldData.GetCustomLocs(String.valueOf(Material.GOLD_ORE.getId()));
|
||||
_blocksToFall = _worldData.GetCustomLocs(String.valueOf(Material.MYCEL.getId()));
|
||||
_blocksToClear = _worldData.GetCustomLocs(String.valueOf(Material.RED_SANDSTONE.getId()));
|
||||
|
||||
_blocksToExplode.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
|
||||
_blocksToFall.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.STONE));
|
||||
_blocksToClear.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
_host.BlockBreakAllow.add(ALLOW_BREAK.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
_host.BlockBreakAllow.remove(ALLOW_BREAK.getId());
|
||||
}
|
||||
|
||||
public boolean isCleared()
|
||||
{
|
||||
for (Location location : _blocksToClear)
|
||||
{
|
||||
if (location.getBlock().getType() != Material.AIR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateExplosion(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST || _exploded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().getZ() > _triggerZ)
|
||||
{
|
||||
explodeBlocks();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void explodeBlocks()
|
||||
{
|
||||
_exploded = true;
|
||||
|
||||
_blocksToExplode.forEach(location ->
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG);
|
||||
location.getWorld().playSound(location, Sound.EXPLODE, 3, 0.6F);
|
||||
});
|
||||
|
||||
_blocksToFall.forEach(location ->
|
||||
{
|
||||
MapUtil.QuickChangeBlockAt(location, Material.AIR);
|
||||
|
||||
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0.5, 0, 0.5), Material.STONE, (byte) 0);
|
||||
fallingBlock.setHurtEntities(false);
|
||||
fallingBlock.setDropItem(false);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.three;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew;
|
||||
import nautilus.game.arcade.game.games.christmasnew.section.Section;
|
||||
|
||||
public class Section3 extends Section
|
||||
{
|
||||
|
||||
private final CaveIn _challenge;
|
||||
|
||||
public Section3(ChristmasNew host, Location sleighTarget, Location... presents)
|
||||
{
|
||||
super(host, sleighTarget);
|
||||
|
||||
_challenge = new CaveIn(host, presents[0], this);
|
||||
|
||||
registerChallenges(_challenge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete()
|
||||
{
|
||||
return super.isComplete() && _challenge.isCleared();
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.two;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
|
||||
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 IceMaze extends SectionChallenge
|
||||
{
|
||||
|
||||
private static final Comparator<Location> HEIGHT_COMPATATOR = (o1, o2) ->
|
||||
{
|
||||
int y1 = o1.getBlockY();
|
||||
int y2 = o2.getBlockY();
|
||||
|
||||
if (y1 == y2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return y1 > y2 ? -1 : 1;
|
||||
};
|
||||
|
||||
private final List<Location> _mazeBlocks;
|
||||
|
||||
IceMaze(ChristmasNew host, Location present, Section section)
|
||||
{
|
||||
super(host, present, section);
|
||||
|
||||
List<Location> mazeOne = _worldData.GetCustomLocs(String.valueOf(Material.SLIME_BLOCK.getId()));
|
||||
List<Location> mazeTwo = _worldData.GetCustomLocs(String.valueOf(Material.COMMAND.getId()));
|
||||
boolean state = Math.random() < 0.5;
|
||||
|
||||
mazeOne.forEach(location -> MapUtil.QuickChangeBlockAt(location, state ? Material.ICE : Material.AIR));
|
||||
mazeTwo.forEach(location -> MapUtil.QuickChangeBlockAt(location, state ? Material.AIR : Material.ICE));
|
||||
|
||||
_mazeBlocks = new ArrayList<>(1000);
|
||||
|
||||
List<Location> corners = _worldData.GetDataLocs("LIGHT_BLUE");
|
||||
|
||||
for (Block block : UtilBlock.getInBoundingBox(corners.get(0), corners.get(1)))
|
||||
{
|
||||
if (block.getType() == Material.ICE)
|
||||
{
|
||||
_mazeBlocks.add(block.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
_mazeBlocks.sort(HEIGHT_COMPATATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
int sleighHeight = _host.getSleigh().GetLocation().getBlockY();
|
||||
|
||||
_host.getArcadeManager().runSyncTimer(new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Location location = _mazeBlocks.remove(0);
|
||||
|
||||
if (location.getY() <= sleighHeight)
|
||||
{
|
||||
cancel();
|
||||
|
||||
_host.getArcadeManager().runSyncTimer(new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < 20 && !_mazeBlocks.isEmpty(); i++)
|
||||
{
|
||||
Location location = _mazeBlocks.remove(_mazeBlocks.size() - 1);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(location, Material.ICE);
|
||||
}
|
||||
|
||||
if (_mazeBlocks.isEmpty())
|
||||
{
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapUtil.QuickChangeBlockAt(location, Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.two;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew;
|
||||
import nautilus.game.arcade.game.games.christmasnew.section.Section;
|
||||
|
||||
public class Section2 extends Section
|
||||
{
|
||||
|
||||
public Section2(ChristmasNew host, Location sleighTarget, Location... presents)
|
||||
{
|
||||
super(host, sleighTarget);
|
||||
|
||||
registerChallenges(
|
||||
new IceMaze(host, presents[0], this),
|
||||
new SnowTurrets(host, presents[1], this)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package nautilus.game.arcade.game.games.christmasnew.section.two;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Witch;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
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 SnowTurrets extends SectionChallenge
|
||||
{
|
||||
|
||||
private static final FireworkEffect DEATH_EFFECT = FireworkEffect.builder()
|
||||
.with(Type.BALL_LARGE)
|
||||
.withColor(Color.ORANGE, Color.BLACK)
|
||||
.withFade(Color.WHITE)
|
||||
.withFlicker()
|
||||
.build();
|
||||
private static final FireworkEffect BULLET_EFFECT = FireworkEffect.builder()
|
||||
.with(Type.BALL)
|
||||
.withColor(Color.AQUA, Color.BLUE)
|
||||
.withFade(Color.WHITE)
|
||||
.build();
|
||||
private static final int YAW = 160;
|
||||
private static final int MAX_DIST = 40;
|
||||
private static final int HIT_RADIUS = 4;
|
||||
private static final String HIT_CAUSE = "Snow Witch";
|
||||
private static final Vector HIT_VELOCITY = new Vector(0, 0.7, 1.2);
|
||||
private static final Vector HIT_BLOCK_VELOCITY = new Vector(0, 1.2, 0);
|
||||
|
||||
private final List<Location> _turretSpawns;
|
||||
private final Set<FallingBlock> _bullets;
|
||||
|
||||
SnowTurrets(ChristmasNew host, Location present, Section section)
|
||||
{
|
||||
super(host, present, section);
|
||||
|
||||
_turretSpawns = _worldData.GetDataLocs("YELLOW");
|
||||
_bullets = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPresentCollect()
|
||||
{
|
||||
_entities.forEach(entity ->
|
||||
{
|
||||
UtilFirework.playFirework(entity.getLocation().add(0, 1.8, 0), DEATH_EFFECT);
|
||||
entity.remove();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister()
|
||||
{
|
||||
_turretSpawns.forEach(location ->
|
||||
{
|
||||
location.setYaw(YAW);
|
||||
|
||||
Witch witch = spawn(location, Witch.class);
|
||||
|
||||
UtilEnt.vegetate(witch);
|
||||
UtilEnt.ghost(witch, true, false);
|
||||
UtilEnt.setFakeHead(witch, true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregister()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateShoot(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entity entity : _entities)
|
||||
{
|
||||
if (!entity.isValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = entity.getLocation().add(0, 1, 0);
|
||||
|
||||
UtilPlayer.getInRadius(location, MAX_DIST).forEach((player, scale) ->
|
||||
{
|
||||
if (Math.random() > 0.4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location, Material.PUMPKIN, (byte) 0);
|
||||
fallingBlock.setDropItem(false);
|
||||
|
||||
Vector velocity = UtilAlg.getTrajectory2d(location, player.getLocation());
|
||||
|
||||
velocity.multiply(2 * scale);
|
||||
velocity.setY(0.4);
|
||||
|
||||
UtilAction.velocity(entity, velocity);
|
||||
|
||||
_bullets.add(fallingBlock);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateBullets(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_bullets.removeIf(block ->
|
||||
{
|
||||
if (UtilEnt.isGrounded(block))
|
||||
{
|
||||
explodeBlock(block.getLocation());
|
||||
return true;
|
||||
}
|
||||
|
||||
UtilFirework.playFirework(block.getLocation(), BULLET_EFFECT);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private void explodeBlock(Location location)
|
||||
{
|
||||
location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.8F);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, location, 0, 0, 0, 0.1F, 1, ViewDist.NORMAL);
|
||||
|
||||
DamageManager damageManager = _host.getArcadeManager().GetDamage();
|
||||
|
||||
UtilPlayer.getInRadius(location, HIT_RADIUS).forEach((player, scale) ->
|
||||
{
|
||||
damageManager.NewDamageEvent(player, null, null, DamageCause.CUSTOM, 2, false, true, true, HIT_CAUSE, HIT_CAUSE);
|
||||
UtilAction.velocity(player, HIT_VELOCITY.clone().multiply(scale + 0.3));
|
||||
});
|
||||
|
||||
for (Block block : UtilBlock.getInRadius(location.getBlock(), HIT_RADIUS).keySet())
|
||||
{
|
||||
if (Math.random() > 0.3 || UtilBlock.airFoliage(block) || !UtilBlock.airFoliage(block.getRelative(BlockFace.UP)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 1.5, 0), block.getType(), block.getData());
|
||||
fallingBlock.setDropItem(false);
|
||||
|
||||
UtilAction.velocity(fallingBlock, HIT_BLOCK_VELOCITY.clone().multiply(0.7 + Math.random()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user