Helicopter
This commit is contained in:
parent
58613fa77f
commit
6bb76db05b
@ -1,23 +1,26 @@
|
||||
package mineplex.gemhunters.supplydrop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.block.schematic.Schematic;
|
||||
import mineplex.core.common.block.schematic.SchematicData;
|
||||
import mineplex.core.common.block.schematic.UtilSchematic;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.gemhunters.world.WorldDataModule;
|
||||
|
||||
/**
|
||||
* Represents an instance of a Supply Drop. <br>
|
||||
* A supply drop consists of a helicopter flying through the map from a one
|
||||
* location to another. Upon reaching it's destination it will drop a loot chest
|
||||
* which players can then fight over. <br>
|
||||
* which players can then fight over. <br>
|
||||
* The helicopter will then fly away towards a despawning location. <br>
|
||||
* <br>
|
||||
* The helicopter will be made up of a collection of blocks that are moved along
|
||||
@ -34,16 +37,19 @@ import mineplex.gemhunters.world.WorldDataModule;
|
||||
public class SupplyDrop
|
||||
{
|
||||
|
||||
private static final String SCHEMATIC_PATH = "../../update/files/Helicopter.schematic";
|
||||
private static final int BLADE_LENGTH = 7;
|
||||
|
||||
private Location _spawn;
|
||||
private Location _destination;
|
||||
private Location _despawn;
|
||||
private Location _current;
|
||||
|
||||
private Location _blade;
|
||||
|
||||
private SupplyDropState _state;
|
||||
|
||||
private Set<Block> _helicopterBlocks;
|
||||
private Schematic _schematic;
|
||||
private Set<Block> _lastHelicopter;
|
||||
private Set<Block> _bladeBlocks;
|
||||
private boolean _diagonal;
|
||||
|
||||
@ -54,16 +60,20 @@ public class SupplyDrop
|
||||
_despawn = despawn;
|
||||
_current = spawn;
|
||||
_state = SupplyDropState.MOVING_TO_DESTINATION;
|
||||
_helicopterBlocks = new HashSet<>();
|
||||
_bladeBlocks = new HashSet<>();
|
||||
_diagonal = false;
|
||||
|
||||
List<Location> helicopterSchematic = Managers.get(WorldDataModule.class).getCustomLocation("SCHEM Helicopter");
|
||||
|
||||
for (Block block : UtilBlock.getInBoundingBox(helicopterSchematic.get(0), helicopterSchematic.get(1)))
|
||||
try
|
||||
{
|
||||
_helicopterBlocks.add(block);
|
||||
_schematic = UtilSchematic.loadSchematic(new File(SCHEMATIC_PATH));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
_lastHelicopter = new HashSet<>(100);
|
||||
_bladeBlocks = new HashSet<>(20);
|
||||
_diagonal = false;
|
||||
}
|
||||
|
||||
public void advancePath()
|
||||
@ -75,20 +85,30 @@ public class SupplyDrop
|
||||
|
||||
rotateBlades();
|
||||
|
||||
_current.add(1, 0, 0);
|
||||
_current.add(0, 0, 1);
|
||||
}
|
||||
|
||||
public void moveHelicopter()
|
||||
{
|
||||
for (Block block : _helicopterBlocks)
|
||||
for (Block block : _lastHelicopter)
|
||||
{
|
||||
Block newBlock = block.getLocation().add(1, 0, 0).getBlock();
|
||||
|
||||
newBlock.setType(block.getType());
|
||||
newBlock.setData(block.getData());
|
||||
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
_lastHelicopter.clear();
|
||||
|
||||
SchematicData data = _schematic.paste(_current, true, true);
|
||||
|
||||
_blade = data.getDataLocationMap().getIronLocations(DyeColor.RED).get(0);
|
||||
|
||||
for (BlockVector vector : data.getBlocks())
|
||||
{
|
||||
Location location = _current.add(vector);
|
||||
|
||||
_lastHelicopter.add(location.getBlock());
|
||||
|
||||
_current.subtract(vector);
|
||||
}
|
||||
}
|
||||
|
||||
public void rotateBlades()
|
||||
@ -108,7 +128,7 @@ public class SupplyDrop
|
||||
{
|
||||
for (int z = -1; z <= 1; z += 2)
|
||||
{
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(x * BLADE_LENGTH, 0, z * BLADE_LENGTH), BLADE_LENGTH))
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_blade, _blade.clone().add(x * BLADE_LENGTH, 0, z * BLADE_LENGTH), BLADE_LENGTH))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
|
||||
@ -122,7 +142,7 @@ public class SupplyDrop
|
||||
{
|
||||
for (int x = -1; x <= 1; x += 2)
|
||||
{
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(x * BLADE_LENGTH, 0, 0), BLADE_LENGTH))
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_blade, _blade.clone().add(x * BLADE_LENGTH, 0, 0), BLADE_LENGTH))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
|
||||
@ -133,7 +153,7 @@ public class SupplyDrop
|
||||
|
||||
for (int z = -1; z <= 1; z += 2)
|
||||
{
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_current, _current.clone().add(0, 0, z * BLADE_LENGTH), BLADE_LENGTH))
|
||||
for (Location location : UtilShapes.getLinesLimitedPoints(_blade, _blade.clone().add(0, 0, z * BLADE_LENGTH), BLADE_LENGTH))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package mineplex.gemhunters.supplydrop;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
@ -37,6 +39,15 @@ public class SupplyDropModule extends MiniPlugin
|
||||
_current.advancePath();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void itemSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
if (event.getEntity().getItemStack().getType() == Material.IRON_DOOR)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void startHelicopter(Player player)
|
||||
{
|
||||
_current = new SupplyDrop(player.getLocation(), player.getLocation(), player.getLocation());
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.gemhunters.world;
|
||||
package mineplex.gemhunters.w orld;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
@ -26,7 +26,9 @@ import mineplex.core.common.util.worldgen.WorldGenCleanRoom;
|
||||
public class WorldDataModule extends MiniPlugin
|
||||
{
|
||||
|
||||
public String Folder = null;
|
||||
private static final String MAP_PATH = "../../update/maps/Gem-Hunters/None_Moppletop City Testing.zip";
|
||||
|
||||
private String folder = null;
|
||||
|
||||
public World World;
|
||||
public int MinX = 0;
|
||||
@ -80,12 +82,12 @@ public class WorldDataModule extends MiniPlugin
|
||||
|
||||
public String getFolder()
|
||||
{
|
||||
if (Folder == null)
|
||||
if (folder == null)
|
||||
{
|
||||
Folder = "world";
|
||||
folder = "world";
|
||||
}
|
||||
|
||||
return Folder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
protected void unzipWorld()
|
||||
@ -98,7 +100,7 @@ public class WorldDataModule extends MiniPlugin
|
||||
TimingManager.stop("UnzipWorld creating folders");
|
||||
|
||||
TimingManager.start("UnzipWorld UnzipToDirectory");
|
||||
ZipUtil.UnzipToDirectory("../../update/maps/Gem-Hunters/None_Moppletop City Testing.zip", folder);
|
||||
ZipUtil.UnzipToDirectory(MAP_PATH, folder);
|
||||
TimingManager.stop("UnzipWorld UnzipToDirectory");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user