current progress
This commit is contained in:
parent
4cf07230cf
commit
b3df1993ca
4 changed files with 128 additions and 0 deletions
8
src/regions/Main.java
Normal file
8
src/regions/Main.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package regions;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin
|
||||
{
|
||||
|
||||
}
|
88
src/regions/Octree.java
Normal file
88
src/regions/Octree.java
Normal file
|
@ -0,0 +1,88 @@
|
|||
package regions;
|
||||
|
||||
public class Octree
|
||||
{
|
||||
//STATIC
|
||||
//==================================================================
|
||||
|
||||
public static class Node
|
||||
{
|
||||
public final boolean full;
|
||||
public final Node[] nodes;
|
||||
|
||||
public Node(boolean full)
|
||||
{
|
||||
this.full = full;
|
||||
this.nodes = new Node[0];
|
||||
}
|
||||
|
||||
public Node(Node[] nodes)
|
||||
{
|
||||
this.full = false;
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class IntReference
|
||||
{
|
||||
int ref;
|
||||
|
||||
IntReference(int i)
|
||||
{
|
||||
this.ref = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Node parseBytes(IntReference index, byte[] bytes, int parentByte)
|
||||
{
|
||||
if (parentByte == 0b00000010) return new Node(true);
|
||||
if (parentByte == 0b00000001) return new Node(false);
|
||||
|
||||
byte a = bytes[index.ref++],
|
||||
b = bytes[index.ref++];
|
||||
|
||||
return
|
||||
new Node
|
||||
(
|
||||
new Node[]
|
||||
{
|
||||
parseBytes(index, bytes, (a >> 6 & 3)),
|
||||
parseBytes(index, bytes, (a >> 4 & 3)),
|
||||
parseBytes(index, bytes, (a >> 2 & 3)),
|
||||
parseBytes(index, bytes, (a & 3)),
|
||||
|
||||
parseBytes(index, bytes, (b >> 6 & 3)),
|
||||
parseBytes(index, bytes, (b >> 4 & 3)),
|
||||
parseBytes(index, bytes, (b >> 2 & 3)),
|
||||
parseBytes(index, bytes, (b & 3))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Node parseBytes(int startAtIndex, byte[] bytes)
|
||||
{
|
||||
return parseBytes ( new IntReference(startAtIndex), bytes, 0 );
|
||||
}
|
||||
public static Node parseBytes(byte[] bytes)
|
||||
{
|
||||
return parseBytes ( new IntReference(0), bytes, 0 );
|
||||
}
|
||||
|
||||
//INSTANCE
|
||||
//==================================================================
|
||||
|
||||
public final Owner owner;
|
||||
public final Node root;
|
||||
|
||||
public Octree(Owner owner, byte[] bytes)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.root = parseBytes(bytes);
|
||||
}
|
||||
}
|
17
src/regions/Owner.java
Normal file
17
src/regions/Owner.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package regions;
|
||||
|
||||
public class Owner
|
||||
{
|
||||
public final String name;
|
||||
public final Owner parent;
|
||||
public final Owner[] children;
|
||||
public final Octree[] trees;
|
||||
|
||||
public Owner(String name, Owner parent, Owner[] children, Octree[] trees)
|
||||
{
|
||||
this.name = name;
|
||||
this.parent = parent;
|
||||
this.children = children;
|
||||
this.trees = trees;
|
||||
}
|
||||
}
|
15
src/regions/RegionEvent.java
Normal file
15
src/regions/RegionEvent.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package regions;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class RegionEvent<T extends Event>
|
||||
{
|
||||
public final T bukkitEvent;
|
||||
public final Owner region;
|
||||
|
||||
public RegionEvent(T bukkitEvent, Owner region)
|
||||
{
|
||||
this.bukkitEvent = bukkitEvent;
|
||||
this.region = region;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue