added documentation
This commit is contained in:
parent
2a86656188
commit
9cbfd393ed
@ -8,6 +8,11 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single position in a multiblock.
|
||||||
|
* Can be a single type of block or multiple types.
|
||||||
|
* Custom valid check functions are supported,
|
||||||
|
*/
|
||||||
public class BlockComponent {
|
public class BlockComponent {
|
||||||
private final BlockComponentMode mode;
|
private final BlockComponentMode mode;
|
||||||
private final Set<Material> blocks;
|
private final Set<Material> blocks;
|
||||||
|
@ -2,6 +2,9 @@ package org.kapelle.multiblock;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a custom check function.
|
||||||
|
*/
|
||||||
public interface ICheckFunction {
|
public interface ICheckFunction {
|
||||||
boolean apply(Location location);
|
boolean apply(Location location);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for block placements and checks if it is part of a the multiblock structure.
|
||||||
|
*/
|
||||||
public abstract class MultiblockListener implements Listener {
|
public abstract class MultiblockListener implements Listener {
|
||||||
private final BlockComponent coreBlock;
|
private final BlockComponent coreBlock;
|
||||||
private final BlockVector coreBlockOffset;
|
private final BlockVector coreBlockOffset;
|
||||||
@ -31,6 +34,10 @@ public abstract class MultiblockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void callback(Location coreBlockLocation);
|
/**
|
||||||
|
* Gets called on successfully validating a multiblock
|
||||||
|
* @param coreBlockLocation location of the core block
|
||||||
|
*/
|
||||||
|
protected abstract void callback(Location coreBlockLocation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,20 @@ import org.bukkit.util.BlockVector;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a full multiblock.
|
||||||
|
* Contains the individual block components.
|
||||||
|
*/
|
||||||
public class MultiblockStructure {
|
public class MultiblockStructure {
|
||||||
|
|
||||||
List<List<List<BlockComponent>>> structure;
|
List<List<List<BlockComponent>>> structure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a multiblock structure.
|
||||||
|
* The format is like this: [y][z][x]
|
||||||
|
* So you describe the layers from bottom to top.
|
||||||
|
* @param structure structure in the format: [y][z][x]
|
||||||
|
*/
|
||||||
public MultiblockStructure(List<List<List<BlockComponent>>> structure){
|
public MultiblockStructure(List<List<List<BlockComponent>>> structure){
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
}
|
}
|
||||||
@ -21,6 +31,12 @@ public class MultiblockStructure {
|
|||||||
return structure.get(y).get(z).get(x);
|
return structure.get(y).get(z).get(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the multiblock is valid at the given location.
|
||||||
|
* @param location Location of a block in a multiblock structure.
|
||||||
|
* @param offset the offset of the location from <0,0,0>
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
public boolean isValid(Location location, BlockVector offset){
|
public boolean isValid(Location location, BlockVector offset){
|
||||||
for (int y = 0; y < structure.size(); y++) {
|
for (int y = 0; y < structure.size(); y++) {
|
||||||
for (int z = 0; z < structure.get(y).size(); z++) {
|
for (int z = 0; z < structure.get(y).size(); z++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user