Get the game into a functional state

This commit is contained in:
Sam 2017-11-15 21:47:28 +00:00 committed by Alexander Meech
parent f00b774056
commit c0d530404e
12 changed files with 98 additions and 78 deletions

View File

@ -102,8 +102,8 @@ public class Christmas extends ChristmasCommon
{ {
PacketPlayOutEntityDestroy destroyPacket = (PacketPlayOutEntityDestroy) packetInfo.getPacket(); PacketPlayOutEntityDestroy destroyPacket = (PacketPlayOutEntityDestroy) packetInfo.getPacket();
int[] entityIds = destroyPacket.a; int[] entityIds = destroyPacket.a;
int origLength = entityIds.length; int origLength = entityIds.length;
for (int a = 0; a < entityIds.length; a++) for (int a = 0; a < entityIds.length; a++)
{ {
for (SleighHorse horse : _sleigh.getHorses()) for (SleighHorse horse : _sleigh.getHorses())
{ {

View File

@ -12,7 +12,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,10 +24,12 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -52,12 +53,19 @@ import nautilus.game.arcade.kit.Kit;
public class ChristmasCommon extends SoloGame public class ChristmasCommon extends SoloGame
{ {
private static final int BARRIER_BREAK_SQUARED = 400; public enum Perm implements Permission
private static final int MIN_Y = 50; {
DEBUG_COMMANDS
}
private static final int BARRIER_BREAK_SQUARED = 600;
private static final int MIN_Y = 40;
protected final List<Section> _sections; protected final List<Section> _sections;
private Section _currentSection; private Section _currentSection;
private boolean _forceSkip;
private GameTeam _badGuys; private GameTeam _badGuys;
private List<Location> _barrier; private List<Location> _barrier;
@ -140,6 +148,12 @@ public class ChristmasCommon extends SoloGame
new CompassModule() new CompassModule()
.register(this); .register(this);
registerDebugCommand("skip", Perm.DEBUG_COMMANDS, PermissionGroup.ADMIN, (player, args) ->
{
_forceSkip = true;
player.sendMessage(F.main("Debug", "Skipping current challenge."));
});
} }
@Override @Override
@ -171,7 +185,7 @@ public class ChristmasCommon extends SoloGame
return; return;
} }
if (_currentSection == null || _currentSection.isComplete()) if (_currentSection == null || _currentSection.isComplete() || _forceSkip)
{ {
if (_currentSection != null) if (_currentSection != null)
{ {
@ -179,6 +193,7 @@ public class ChristmasCommon extends SoloGame
_currentSection.end(); _currentSection.end();
} }
_forceSkip = false;
_currentSection = getNext(); _currentSection = getNext();
if (_currentSection == null) if (_currentSection == null)
@ -331,36 +346,16 @@ public class ChristmasCommon extends SoloGame
return; return;
} }
Location breakAt = null; _barrier.removeIf(location ->
for (Location loc : _barrier)
{ {
if (UtilMath.offsetSquared(getSleigh().GetLocation(), loc) > BARRIER_BREAK_SQUARED) if (UtilMath.offsetSquared(getSleigh().GetLocation(), location) > BARRIER_BREAK_SQUARED)
{ {
continue; return false;
} }
breakAt = loc; MapUtil.QuickChangeBlockAt(location, Material.AIR);
} return true;
});
if (breakAt != null)
{
_barrier.remove(breakAt);
barrierBreak(breakAt);
}
}
private void barrierBreak(Location location)
{
MapUtil.QuickChangeBlockAt(location, Material.AIR);
for (Block block : UtilBlock.getSurrounding(location.getBlock(), false))
{
if (_barrier.remove(block.getLocation()))
{
barrierBreak(block.getLocation());
}
}
} }
@EventHandler @EventHandler

View File

@ -4,24 +4,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Chicken; import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -252,10 +245,6 @@ public class Sleigh
public void AddPresent(Location loc) public void AddPresent(Location loc)
{ {
PresentsCollected.add(loc); PresentsCollected.add(loc);
loc.getBlock().setType(Material.AIR);
loc.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.GLASS);
UtilFirework.launchFirework(loc.clone().add(0.5, 0.5, 0.5), FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(true).build(), new Vector(0, 1, 0), 0);
SleighPart part = PresentSlots.remove(0); SleighPart part = PresentSlots.remove(0);
if (part == null) if (part == null)

View File

@ -53,7 +53,7 @@ public class ChristmasNew extends ChristmasCommon
} }
// Take the parse at the purple bridge // Take the parse at the purple bridge
// /parse600 129 88 137 165 14 110 179 21 22 121 // /parse600 129 88 137 165 14 110 179 21 22 153 103 121
@Override @Override
public void ParseData() public void ParseData()
{ {
@ -70,7 +70,7 @@ public class ChristmasNew extends ChristmasCommon
_sections.add(new Section3(this, targets.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), 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 Section5(this, targets.remove(0), presents.remove(0), presents.remove(0)));
_sections.add(new Section6(this, targets.remove(0), presents.remove(0))); //_sections.add(new Section6(this, targets.remove(0), presents.remove(0)));
} }
@EventHandler @EventHandler

View File

@ -81,7 +81,7 @@ public class Present implements Component
public boolean isColliding(Player player) public boolean isColliding(Player player)
{ {
return UtilMath.offsetSquared(player, _stand) < 9; return UtilMath.offsetSquared(player, _stand) < 4;
} }
public boolean isCollected() public boolean isCollected()

View File

@ -103,10 +103,12 @@ public abstract class Section extends SimpleLifetime implements Listener, Sectio
_host.sendSantaMessage("Well done " + player.getName() + " you found a present!" + (left > 0 ? " Only " + left + " to go!" : ""), null); _host.sendSantaMessage("Well done " + player.getName() + " you found a present!" + (left > 0 ? " Only " + left + " to go!" : ""), null);
for (int i = 0; i < 5; i++) for (int i = 0; i < 3; i++)
{ {
UtilFirework.launchFirework(location, FIREWORK_EFFECT, null, UtilMath.r(3)); UtilFirework.launchFirework(location, FIREWORK_EFFECT, null, UtilMath.r(3));
} }
_host.getSleigh().AddPresent(location);
} }
public Location getSleighTarget() public Location getSleighTarget()

View File

@ -18,7 +18,6 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.christmasnew.ChristmasNew; 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.Section;
import nautilus.game.arcade.game.games.christmasnew.section.SectionChallenge;
public class Section5 extends Section public class Section5 extends Section
{ {
@ -40,6 +39,7 @@ public class Section5 extends Section
_solidifyAt = _bridgeBlocks.get(0).getBlockY(); _solidifyAt = _bridgeBlocks.get(0).getBlockY();
registerChallenges( registerChallenges(
new SwitchParkour(host, presents[0], this),
new SnowmenKong(host, presents[1], this) new SnowmenKong(host, presents[1], this)
); );
} }
@ -78,6 +78,8 @@ public class Section5 extends Section
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0, 8, 0), Material.WOOL, colour); FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0, 8, 0), Material.WOOL, colour);
fallingBlock.setDropItem(false); fallingBlock.setDropItem(false);
fallingBlock.setHurtEntities(false); fallingBlock.setHurtEntities(false);
_fallingBlocks.add(fallingBlock);
return true; return true;
} }
@ -112,6 +114,8 @@ public class Section5 extends Section
if (location.getBlockY() <= _solidifyAt) if (location.getBlockY() <= _solidifyAt)
{ {
block.remove();
location.setY(_solidifyAt);
MapUtil.QuickChangeBlockAt(location, block.getMaterial(), block.getBlockData()); MapUtil.QuickChangeBlockAt(location, block.getMaterial(), block.getBlockData());
if (Math.random() > 0.8) if (Math.random() > 0.8)

View File

@ -68,6 +68,9 @@ class SwitchParkour extends SectionChallenge
@Override @Override
public void onUnregister() public void onUnregister()
{ {
_white.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
_black.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
_checkpointHologram.stop(); _checkpointHologram.stop();
} }
@ -136,7 +139,7 @@ class SwitchParkour extends SectionChallenge
_hasCheckpointed = true; _hasCheckpointed = true;
_checkpointTrigger.getWorld().playSound(_checkpointTrigger, Sound.LEVEL_UP, 1, 0.5F); _checkpointTrigger.getWorld().playSound(_checkpointTrigger, Sound.LEVEL_UP, 2, 0.5F);
MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.AIR); MapUtil.QuickChangeBlockAt(_checkpointTrigger, Material.AIR);
_checkpointHologram.stop(); _checkpointHologram.stop();
@ -152,7 +155,7 @@ class SwitchParkour extends SectionChallenge
{ {
if (location.getY() > y) if (location.getY() > y)
{ {
location.getWorld().playSound(location, Sound.PISTON_RETRACT, 1, 0.6F); location.getWorld().playSound(location, Sound.PISTON_RETRACT, 2, 0.6F);
MapUtil.QuickChangeBlockAt(location, Material.COBBLESTONE_STAIRS, (byte) 1); MapUtil.QuickChangeBlockAt(location, Material.COBBLESTONE_STAIRS, (byte) 1);
return true; return true;
} }
@ -169,6 +172,6 @@ class SwitchParkour extends SectionChallenge
y--; y--;
} }
} }
}, 0, 10); }, 0, 6);
} }
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.entity.Blaze;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Golem; import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
@ -130,7 +130,7 @@ class MobDefense extends SectionChallenge
spawnMob(Skeleton.class, skeletons); spawnMob(Skeleton.class, skeletons);
spawnMob(Creeper.class, creepers); spawnMob(Creeper.class, creepers);
spawnMob(Blaze.class, blazes); spawnMob(Blaze.class, blazes);
spawnMob(Golem.class, golems); spawnMob(IronGolem.class, golems);
} }
@EventHandler @EventHandler

View File

@ -36,13 +36,13 @@ class CaveIn extends SectionChallenge
{ {
super(host, present, section); super(host, present, section);
_triggerZ = _worldData.GetDataLocs("ORANGE").get(0).getBlockY(); _triggerZ = _worldData.GetDataLocs("ORANGE").get(0).getBlockZ();
_blocksToExplode = _worldData.GetCustomLocs(String.valueOf(Material.GOLD_ORE.getId())); _blocksToExplode = _worldData.GetCustomLocs(String.valueOf(Material.GOLD_ORE.getId()));
_blocksToFall = _worldData.GetCustomLocs(String.valueOf(Material.MYCEL.getId())); _blocksToFall = _worldData.GetCustomLocs(String.valueOf(Material.MYCEL.getId()));
_blocksToClear = _worldData.GetCustomLocs(String.valueOf(Material.RED_SANDSTONE.getId())); _blocksToClear = _worldData.GetCustomLocs(String.valueOf(Material.RED_SANDSTONE.getId()));
_blocksToExplode.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); _blocksToExplode.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
_blocksToFall.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.STONE)); _blocksToFall.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.COBBLESTONE));
_blocksToClear.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR)); _blocksToClear.forEach(location -> MapUtil.QuickChangeBlockAt(location, Material.AIR));
} }
@ -109,7 +109,7 @@ class CaveIn extends SectionChallenge
{ {
MapUtil.QuickChangeBlockAt(location, Material.AIR); MapUtil.QuickChangeBlockAt(location, Material.AIR);
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0.5, 0, 0.5), Material.STONE, (byte) 0); FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location.add(0.5, 0, 0.5), ALLOW_BREAK, (byte) 0);
fallingBlock.setHurtEntities(false); fallingBlock.setHurtEntities(false);
fallingBlock.setDropItem(false); fallingBlock.setDropItem(false);
}); });

View File

@ -65,6 +65,37 @@ class IceMaze extends SectionChallenge
{ {
int sleighHeight = _host.getSleigh().GetLocation().getBlockY(); int sleighHeight = _host.getSleigh().GetLocation().getBlockY();
removeMaze(sleighHeight);
fillMaze(sleighHeight);
}
private void removeMaze(int sleighHeight)
{
_host.getArcadeManager().runSyncTimer(new BukkitRunnable()
{
@Override
public void run()
{
for (int i = 0; i < 30; i++)
{
Location location = _mazeBlocks.remove(0);
if (location.getY() < sleighHeight)
{
cancel();
return;
}
else
{
MapUtil.QuickChangeBlockAt(location, Material.AIR);
}
}
}
}, 0, 1);
}
private void fillMaze(int sleighHeight)
{
_host.getArcadeManager().runSyncTimer(new BukkitRunnable() _host.getArcadeManager().runSyncTimer(new BukkitRunnable()
{ {
@Override @Override
@ -72,34 +103,22 @@ class IceMaze extends SectionChallenge
{ {
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
{ {
Location location = _mazeBlocks.remove(0); if (_mazeBlocks.isEmpty())
if (location.getY() <= sleighHeight)
{ {
cancel(); cancel();
return;
}
_host.getArcadeManager().runSyncTimer(new BukkitRunnable() Location location = _mazeBlocks.remove(_mazeBlocks.size() - 1);
{
@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 (location.getY() > sleighHeight)
} {
cancel();
if (_mazeBlocks.isEmpty()) return;
{
cancel();
}
}
}, 0, 1);
} }
else else
{ {
MapUtil.QuickChangeBlockAt(location, Material.AIR); MapUtil.QuickChangeBlockAt(location, Material.ICE);
} }
} }
} }

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
@ -19,6 +20,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
@ -87,9 +89,15 @@ class SnowTurrets extends SectionChallenge
Witch witch = spawn(location, Witch.class); Witch witch = spawn(location, Witch.class);
witch.setCustomName(C.cAquaB + "Snow Witch");
witch.setCustomNameVisible(true);
witch.setRemoveWhenFarAway(false);
UtilEnt.vegetate(witch); UtilEnt.vegetate(witch);
UtilEnt.ghost(witch, true, false); UtilEnt.ghost(witch, true, false);
UtilEnt.setFakeHead(witch, true); UtilEnt.setFakeHead(witch, true);
Bukkit.broadcastMessage("Test");
}); });
} }