com.aranai.dungeonator.dungeonchunk
Class DungeonChunk

java.lang.Object
  extended by com.aranai.dungeonator.dungeonchunk.DungeonChunk
All Implemented Interfaces:
IDungeonChunk

public class DungeonChunk
extends java.lang.Object
implements IDungeonChunk

Stores and manipulates Dungeonator chunk information, including type, neighbors, and doorways.


Field Summary
private  org.bukkit.Chunk chunk
          The handle for the chunk data
private  DungeonChunkDoorway[] doorways
          Doorways
private  DungeonChunk[] neighbors
          Neighboring chunks (NESW)
private  long seed
          Random seed used for procedural chunks.
private  DungeonChunkType type
          Chunk type
private  java.lang.String world
          The world name.
private  int x
          X coordinate for the chunk.
private  int z
          Z coordinate for the chunk.
 
Constructor Summary
DungeonChunk()
          Instantiates a new dungeon chunk.
DungeonChunk(org.bukkit.Chunk chunk)
          Instantiates a new dungeon chunk from an existing chunk
DungeonChunk(DungeonChunkType type)
          Instantiates a new dungeon chunk with a specified DungeonChunkType.
DungeonChunk(DungeonChunkType type, java.lang.String world, int x, int z, org.bukkit.Chunk chunk)
           
 
Method Summary
 DungeonChunkDoorway getDoorway(byte direction)
          Gets the doorway matching the specified direction.
 java.util.Vector<DungeonChunkDoorway> getDoorwaysOnSide(byte[] side)
          Gets all of the doorways on the specified side.
 org.bukkit.Chunk getHandle()
          Gets the handle for the DungeonChunk's chunk data.
 IDungeonChunk getNeighbor(byte direction)
          Gets the neighboring chunk matching the specified direction.
 long getSeed()
          Gets the seed.
 DungeonChunkType getType()
          Gets the DungeonChunkType for the chunk.
 java.lang.String getWorld()
          Gets the world name.
 int getX()
          Gets the x coordinate for the chunk.
 int getZ()
          Gets the z coordinate for the chunk.
 boolean hasDoorway(byte d)
          Checks for a doorway matching the specified direction.
 boolean hasNeighbor(byte direction)
          Checks for a neighboring chunk matching the specified direction.
 boolean isValidChunkDirection(byte direction)
          Checks if the specified direction is a valid chunk direction (NESW)
 void setDoorway(DungeonChunkDoorway doorway)
          Sets a doorway.
 void setHandle(org.bukkit.Chunk handle)
          Sets the handle for the DungeonChunk's chunk data.
 void setNeighbor(byte direction, IDungeonChunk neighbor)
          Sets the neighboring chunk for the specified direction.
 void setSeed(long seed)
          Sets the seed.
 void setType(DungeonChunkType type)
          Sets the DungeonChunkType for the chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

world

private java.lang.String world
The world name.


x

private int x
X coordinate for the chunk.


z

private int z
Z coordinate for the chunk.


chunk

private org.bukkit.Chunk chunk
The handle for the chunk data


seed

private long seed
Random seed used for procedural chunks.


type

private DungeonChunkType type
Chunk type


neighbors

private DungeonChunk[] neighbors
Neighboring chunks (NESW)


doorways

private DungeonChunkDoorway[] doorways
Doorways

Constructor Detail

DungeonChunk

public DungeonChunk()
Instantiates a new dungeon chunk.


DungeonChunk

public DungeonChunk(DungeonChunkType type)
Instantiates a new dungeon chunk with a specified DungeonChunkType.

Parameters:
type - the type

DungeonChunk

public DungeonChunk(org.bukkit.Chunk chunk)
Instantiates a new dungeon chunk from an existing chunk

Parameters:
chunk - the chunk

DungeonChunk

public DungeonChunk(DungeonChunkType type,
                    java.lang.String world,
                    int x,
                    int z,
                    org.bukkit.Chunk chunk)
Method Detail

getWorld

public java.lang.String getWorld()
Description copied from interface: IDungeonChunk
Gets the world name.

Specified by:
getWorld in interface IDungeonChunk
Returns:
the world name

getX

public int getX()
Description copied from interface: IDungeonChunk
Gets the x coordinate for the chunk.

Specified by:
getX in interface IDungeonChunk
Returns:
the x coordinate for the chunk

getZ

public int getZ()
Description copied from interface: IDungeonChunk
Gets the z coordinate for the chunk.

Specified by:
getZ in interface IDungeonChunk
Returns:
the z coordinate for the chunk

getSeed

public long getSeed()
Description copied from interface: IDungeonChunk
Gets the seed.

Specified by:
getSeed in interface IDungeonChunk
Returns:
the seed

setSeed

public void setSeed(long seed)
Description copied from interface: IDungeonChunk
Sets the seed.

Specified by:
setSeed in interface IDungeonChunk
Parameters:
seed - the new seed

getType

public DungeonChunkType getType()
Description copied from interface: IDungeonChunk
Gets the DungeonChunkType for the chunk.

Specified by:
getType in interface IDungeonChunk
Returns:
the type

setType

public void setType(DungeonChunkType type)
Description copied from interface: IDungeonChunk
Sets the DungeonChunkType for the chunk.

Specified by:
setType in interface IDungeonChunk
Parameters:
type - the new type

hasDoorway

public boolean hasDoorway(byte d)
Description copied from interface: IDungeonChunk
Checks for a doorway matching the specified direction.

Specified by:
hasDoorway in interface IDungeonChunk
Returns:
true, if the chunk has a matching doorway

getDoorway

public DungeonChunkDoorway getDoorway(byte direction)
Description copied from interface: IDungeonChunk
Gets the doorway matching the specified direction.

Specified by:
getDoorway in interface IDungeonChunk
Parameters:
direction - the direction of the doorway to get
Returns:
the doorway, or null if no doorway exists at the specified direction

getDoorwaysOnSide

public java.util.Vector<DungeonChunkDoorway> getDoorwaysOnSide(byte[] side)
Description copied from interface: IDungeonChunk
Gets all of the doorways on the specified side.

Specified by:
getDoorwaysOnSide in interface IDungeonChunk
Returns:
the doorways on the specified side

setDoorway

public void setDoorway(DungeonChunkDoorway doorway)
Description copied from interface: IDungeonChunk
Sets a doorway. The direction will be inferred from the doorway instance itself.

Specified by:
setDoorway in interface IDungeonChunk
Parameters:
doorway - the DungeonChunkDoorway to set

hasNeighbor

public boolean hasNeighbor(byte direction)
Description copied from interface: IDungeonChunk
Checks for a neighboring chunk matching the specified direction.

Specified by:
hasNeighbor in interface IDungeonChunk
Returns:
true, if the chunk has a matching neighbor

getNeighbor

public IDungeonChunk getNeighbor(byte direction)
Description copied from interface: IDungeonChunk
Gets the neighboring chunk matching the specified direction.

Specified by:
getNeighbor in interface IDungeonChunk
Parameters:
direction - the direction of the chunk to get
Returns:
the neighboring chunk, or null if no neighbor exists at the specified direction

setNeighbor

public void setNeighbor(byte direction,
                        IDungeonChunk neighbor)
Description copied from interface: IDungeonChunk
Sets the neighboring chunk for the specified direction.

Specified by:
setNeighbor in interface IDungeonChunk
Parameters:
direction - the direction of the neighbor to set
neighbor - the chunk to set as a neighbor

getHandle

public org.bukkit.Chunk getHandle()
Description copied from interface: IDungeonChunk
Gets the handle for the DungeonChunk's chunk data.

Specified by:
getHandle in interface IDungeonChunk
Returns:
the chunk

setHandle

public void setHandle(org.bukkit.Chunk handle)
Description copied from interface: IDungeonChunk
Sets the handle for the DungeonChunk's chunk data.

Specified by:
setHandle in interface IDungeonChunk

isValidChunkDirection

public boolean isValidChunkDirection(byte direction)
Checks if the specified direction is a valid chunk direction (NESW)

Parameters:
direction - the direction to check
Returns:
true, if the direction is a valid chunk direction