summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.classpath36
-rw-r--r--.project23
-rw-r--r--dependency-reduced-pom.xml104
-rw-r--r--pom.xml117
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Commander.java40
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Direction.java10
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Dungeon.java48
-rw-r--r--src/main/java/com/encrox/instanceddungeons/DungeonWorld.java59
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Exit.java23
-rw-r--r--src/main/java/com/encrox/instanceddungeons/InstancedDungeons.java262
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Schematic.java90
-rw-r--r--src/main/java/com/encrox/instanceddungeons/Section.java499
-rw-r--r--src/main/resources/config.json22
-rw-r--r--src/main/resources/descriptor.json72
-rw-r--r--src/main/resources/lang/de-DE.properties1
-rw-r--r--src/main/resources/lang/en-GB.properties1
-rw-r--r--src/main/resources/plugin.yml9
-rw-r--r--src/main/resources/schematics/endBottom.schematicbin0 -> 270 bytes
-rw-r--r--src/main/resources/schematics/endSide.schematicbin0 -> 317 bytes
-rw-r--r--src/main/resources/schematics/endTop.schematicbin0 -> 358 bytes
-rw-r--r--src/main/resources/schematics/startBottom.schematicbin0 -> 423 bytes
-rw-r--r--src/main/resources/schematics/startSide.schematicbin0 -> 252 bytes
-rw-r--r--src/main/resources/schematics/startTop.schematicbin0 -> 278 bytes
-rw-r--r--src/main/resources/schematics/test.schematicbin0 -> 345 bytes
-rw-r--r--target/classes/config.json22
-rw-r--r--target/classes/descriptor.json72
-rw-r--r--target/classes/lang/de-DE.properties1
-rw-r--r--target/classes/lang/en-GB.properties1
-rw-r--r--target/classes/plugin.yml9
-rw-r--r--target/classes/schematics/endBottom.schematicbin0 -> 270 bytes
-rw-r--r--target/classes/schematics/endSide.schematicbin0 -> 317 bytes
-rw-r--r--target/classes/schematics/endTop.schematicbin0 -> 358 bytes
-rw-r--r--target/classes/schematics/startBottom.schematicbin0 -> 423 bytes
-rw-r--r--target/classes/schematics/startSide.schematicbin0 -> 252 bytes
-rw-r--r--target/classes/schematics/startTop.schematicbin0 -> 278 bytes
-rw-r--r--target/classes/schematics/test.schematicbin0 -> 345 bytes
-rw-r--r--target/maven-archiver/pom.properties5
-rw-r--r--target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst0
-rw-r--r--target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst8
-rw-r--r--target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst0
40 files changed, 1534 insertions, 0 deletions
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..16c89cc
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/.project b/.project
new file mode 100644
index 0000000..6255c80
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>instanceddungeons</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
new file mode 100644
index 0000000..9eefedd
--- /dev/null
+++ b/dependency-reduced-pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.encrox</groupId>
+ <artifactId>instanceddungeons</artifactId>
+ <name>InstancedDungeons</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>plugin.yml</include>
+ <include>config.json</include>
+ <include>descriptor.json</include>
+ </includes>
+ </resource>
+ <resource>
+ <targetPath>schematics</targetPath>
+ <directory>src/main/resources/schematics</directory>
+ <includes>
+ <include>endBottom.schematic</include>
+ <include>endSide.schematic</include>
+ <include>endTop.schematic</include>
+ <include>startBottom.schematic</include>
+ <include>startSide.schematic</include>
+ <include>startTop.schematic</include>
+ <include>test.schematic</include>
+ </includes>
+ </resource>
+ <resource>
+ <targetPath>lang</targetPath>
+ <directory>src/main/resources/lang</directory>
+ <includes>
+ <include>de-DE.properties</include>
+ <include>en-GB.properties</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <artifactSet>
+ <includes>
+ <include>org.jnbt:jnbt:*</include>
+ <include>org.json:json:*</include>
+ </includes>
+ </artifactSet>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.bukkit</groupId>
+ <artifactId>craftbukkit</artifactId>
+ <version>LATEST</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sk89q</groupId>
+ <artifactId>worledit</artifactId>
+ <version>6.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sk89q</groupId>
+ <artifactId>worldguard</artifactId>
+ <version>6.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.comphenix</groupId>
+ <artifactId>protocollib</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.encrox</groupId>
+ <artifactId>instancedregions</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ebbe33e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,117 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.encrox</groupId>
+ <artifactId>instanceddungeons</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>InstancedDungeons</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.bukkit</groupId>
+ <artifactId>craftbukkit</artifactId>
+ <version>LATEST</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sk89q</groupId>
+ <artifactId>worledit</artifactId>
+ <version>6.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sk89q</groupId>
+ <artifactId>worldguard</artifactId>
+ <version>6.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.comphenix</groupId>
+ <artifactId>protocollib</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.encrox</groupId>
+ <artifactId>instancedregions</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20160810</version>
+ <scope>package</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jnbt</groupId>
+ <artifactId>jnbt</artifactId>
+ <version>1.1</version>
+ <scope>package</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>plugin.yml</include>
+ <include>config.json</include>
+ <include>descriptor.json</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources/schematics</directory>
+ <targetPath>schematics</targetPath>
+ <includes>
+ <include>endBottom.schematic</include>
+ <include>endSide.schematic</include>
+ <include>endTop.schematic</include>
+ <include>startBottom.schematic</include>
+ <include>startSide.schematic</include>
+ <include>startTop.schematic</include>
+ <include>test.schematic</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources/lang</directory>
+ <targetPath>lang</targetPath>
+ <includes>
+ <include>de-DE.properties</include>
+ <include>en-GB.properties</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <artifactSet>
+ <includes>
+ <include>org.jnbt:jnbt:*</include>
+ <include>org.json:json:*</include>
+ </includes>
+ </artifactSet>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/src/main/java/com/encrox/instanceddungeons/Commander.java b/src/main/java/com/encrox/instanceddungeons/Commander.java
new file mode 100644
index 0000000..a9b5f39
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Commander.java
@@ -0,0 +1,40 @@
+package com.encrox.instanceddungeons;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.json.JSONObject;
+
+public class Commander implements CommandExecutor {
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if(sender instanceof Player) {
+ Player player = (Player)sender;
+ try {
+ switch(args[0]) {
+ case "open":
+ break;
+ case "invite":
+ break;
+ case "join":
+ break;
+ case "close":
+ break;
+ case "random":
+ Dungeon dungeon = new Dungeon(player, args[1], Integer.parseInt(args[2]));
+ InstancedDungeons.dungeons.add(dungeon);
+ return true;
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ sender.sendMessage("no player");
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/Direction.java b/src/main/java/com/encrox/instanceddungeons/Direction.java
new file mode 100644
index 0000000..0b360d1
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Direction.java
@@ -0,0 +1,10 @@
+package com.encrox.instanceddungeons;
+
+public class Direction {
+
+ public static final byte NORTH = 0;
+ public static final byte EAST = 1;
+ public static final byte SOUTH = 2;
+ public static final byte WEST = 3;
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/Dungeon.java b/src/main/java/com/encrox/instanceddungeons/Dungeon.java
new file mode 100644
index 0000000..a94ba36
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Dungeon.java
@@ -0,0 +1,48 @@
+package com.encrox.instanceddungeons;
+
+import java.util.ArrayList;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.json.JSONObject;
+
+import com.sk89q.worldedit.BlockVector;
+
+public class Dungeon {
+
+ private Section section;
+ private String id;
+ private int depth;
+ private ArrayList<Player> players;
+
+ public Dungeon(Player player, String id, int depth) {
+ this.id = id;
+ this.depth = depth;
+ section = new Section(InstancedDungeons.startDescriptors.getJSONObject((int)Math.round(Math.random()*(InstancedDungeons.startDescriptors.length()-1))), 0, depth);
+ try {
+ section.load();
+ section.instantiate();
+ BlockVector[] destinations = section.getAbsoluteExits();
+ BlockVector destination = destinations[(int)Math.round(Math.random()*(destinations.length-1))];
+ addPlayer(player);
+ player.teleport(new Location(InstancedDungeons.dungeonWorld.getWorld(), destination.getBlockX(), destination.getBlockY(), destination.getBlockZ()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void addPlayer(Player player) {
+ section.addPlayer(player);
+ }
+
+ public void removePlayer(Player player) {
+ section.removePlayer(player);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/DungeonWorld.java b/src/main/java/com/encrox/instanceddungeons/DungeonWorld.java
new file mode 100644
index 0000000..7d4b99c
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/DungeonWorld.java
@@ -0,0 +1,59 @@
+package com.encrox.instanceddungeons;
+
+import java.util.ArrayList;
+
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.plugin.Plugin;
+
+import com.encrox.instancedregions.InstancedProtectedCuboidRegion;
+import com.sk89q.worldedit.BlockVector;
+import com.sk89q.worldedit.BlockVector2D;
+import com.sk89q.worldedit.regions.CuboidRegion;
+import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+
+public class DungeonWorld {
+
+ private Plugin plugin;
+ private World world;
+ private ArrayList<ProtectedRegion> regions;
+ private int lastX;
+
+ public DungeonWorld(Plugin plugin, World world) {
+ this.world = world;
+ this.plugin = plugin;
+ regions = new ArrayList<ProtectedRegion>();
+ lastX = 0;
+ }
+
+ public InstancedProtectedCuboidRegion allocate(int width, int length) {
+ BlockVector min, max;
+ InstancedProtectedCuboidRegion region;
+ for(int i = 0; true; i+=16) {
+ if(new ProtectedCuboidRegion("current", (min = new BlockVector(lastX+i, 0, 0)), (max = new BlockVector(lastX+i+width, 255, length))).getIntersectingRegions(regions).isEmpty()) {
+ region = new InstancedProtectedCuboidRegion(plugin, world, ""+min.getBlockX(), min, max);
+ regions.add(region);
+ return region;
+ }
+ }
+ }
+
+ //YOU STILL HAVE TO DISPOSE THE INSTANCED REGION MANUALLY!
+ public void deallocate(InstancedProtectedCuboidRegion region) {
+ BlockVector min = region.getMinimumPoint(), max = region.getMaximumPoint();
+ for(int y = min.getBlockY(), ymax = max.getBlockY(); y<ymax; y++) {
+ for(int z = min.getBlockZ(), zmax = max.getBlockZ(); z<zmax; z++) {
+ for(int x = min.getBlockX(), xmax = max.getBlockX(); x<xmax; x++) {
+ world.getBlockAt(x, y, z).setType(Material.AIR);
+ }
+ }
+ }
+ regions.remove(region);
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/Exit.java b/src/main/java/com/encrox/instanceddungeons/Exit.java
new file mode 100644
index 0000000..e5423cd
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Exit.java
@@ -0,0 +1,23 @@
+package com.encrox.instanceddungeons;
+
+import com.sk89q.worldedit.BlockVector;
+
+public class Exit {
+
+ private Section section;
+ private BlockVector relative;
+
+ public Exit(Section section, BlockVector relative) {
+ this.section = section;
+ this.relative = relative;
+ }
+
+ public Section getSection() {
+ return section;
+ }
+
+ public BlockVector getRelativeBlockVector() {
+ return relative;
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/InstancedDungeons.java b/src/main/java/com/encrox/instanceddungeons/InstancedDungeons.java
new file mode 100644
index 0000000..751e252
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/InstancedDungeons.java
@@ -0,0 +1,262 @@
+package com.encrox.instanceddungeons;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.bukkit.WorldEditPlugin;
+
+public class InstancedDungeons extends JavaPlugin {
+
+ public static Plugin plugin;
+ public static Logger logger;
+ public static PluginDescriptionFile pdf;
+ //public static Properties lang;
+ public static JSONObject config;
+ public static JSONArray resetDungeons, schematicDescriptors, startDescriptors, endDescriptors, normalDescriptors;
+ public static DungeonWorld dungeonWorld;
+ public static File schematicsDirectory;
+ public static ArrayList<Dungeon> dungeons;
+ public static WorldEditPlugin we;
+
+ public void onEnable() {
+ pdf = getDescription();
+ logger = Logger.getLogger("Minecraft");
+ if(setupMyself() && setupWorldEdit()) {
+ plugin = this;
+ getCommand("dungeon").setExecutor(new Commander());
+ logger.info(pdf.getName() + " " + pdf.getVersion() + " has been enabled.");
+ } else {
+ logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled.");
+ }
+ }
+
+ public boolean setupWorldEdit() {
+ we = (WorldEditPlugin)Bukkit.getPluginManager().getPlugin("WorldEdit");
+ return (we != null);
+ }
+
+ public boolean setupMyself() {
+ if(!this.getDataFolder().exists())
+ this.getDataFolder().mkdirs();
+ schematicsDirectory = new File(this.getDataFolder(), "schematics");
+ if(!schematicsDirectory.exists())
+ schematicsDirectory.mkdirs();
+ File configFile = new File(this.getDataFolder(), "config.json");
+ if(!configFile.exists()) {
+ BufferedInputStream bis;
+ FileOutputStream out;
+ try {
+ bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("config.json"));
+ out = new FileOutputStream(configFile);
+ int current;
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ BufferedReader br;
+ StringBuilder sb = new StringBuilder();
+ String line;
+ try {
+ br = new BufferedReader(new FileReader(configFile));
+ while((line = br.readLine()) != null)
+ sb.append(line);
+ br.close();
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ return false;
+ }
+ config = new JSONObject(sb.toString());
+ resetDungeons = config.getJSONArray("resetDungeons");
+ File schematicDescriptorFile = new File(schematicsDirectory, "descriptor.json");
+ if(!schematicDescriptorFile.exists()) {
+ int current;
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("descriptor.json"));
+ FileOutputStream out = new FileOutputStream(schematicDescriptorFile);
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/endBottom.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "endBottom.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/endSide.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "endSide.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/endTop.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "endTop.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/startBottom.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "startBottom.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/startSide.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "startSide.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/startTop.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "startTop.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ try {
+ BufferedInputStream bis = new BufferedInputStream(getClass().getClassLoader().getResourceAsStream("schematics/test.schematic"));
+ FileOutputStream out = new FileOutputStream(new File(schematicsDirectory, "test.schematic"));
+ while((current = bis.read()) != -1) {
+ out.write(current);
+ }
+ bis.close();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ sb = new StringBuilder();
+ try {
+ br = new BufferedReader(new FileReader(schematicDescriptorFile));
+ while((line = br.readLine()) != null)
+ sb.append(line);
+ br.close();
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ return false;
+ }
+ schematicDescriptors = new JSONObject(sb.toString()).getJSONArray("schematics");
+ startDescriptors = new JSONArray();
+ endDescriptors = new JSONArray();
+ normalDescriptors = new JSONArray();
+ JSONObject current;
+ for(int i = 0, length = schematicDescriptors.length(); i<length; i++) {
+ switch((current = schematicDescriptors.getJSONObject(i)).getInt("modifier")) {
+ case 0:
+ normalDescriptors.put(current);
+ break;
+ case 1:
+ startDescriptors.put(current);
+ break;
+ case 2:
+ endDescriptors.put(current);
+ break;
+ }
+ }
+ /*lang = new Properties();
+ try {
+ //TODO
+ lang.load(getClass().getClassLoader().getResourceAsStream("lang/" + config.getString("locale")));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ */
+ dungeonWorld = new DungeonWorld(this, Bukkit.getWorld(config.getString("world")));
+ dungeons = new ArrayList<Dungeon>();
+ return true;
+ }
+
+ public void onDisable() {
+ logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled.");
+ }
+
+ private void addClassPath(final URL url) throws IOException {
+ final URLClassLoader sysloader = (URLClassLoader) ClassLoader
+ .getSystemClassLoader();
+ final Class<URLClassLoader> sysclass = URLClassLoader.class;
+ try {
+ final Method method = sysclass.getDeclaredMethod("addURL",
+ new Class[] { URL.class });
+ method.setAccessible(true);
+ method.invoke(sysloader, new Object[] { url });
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ throw new IOException("Error adding " + url
+ + " to system classloader");
+ }
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/Schematic.java b/src/main/java/com/encrox/instanceddungeons/Schematic.java
new file mode 100644
index 0000000..c5aaf9e
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Schematic.java
@@ -0,0 +1,90 @@
+/*
+ * Dynamic Schematic object
+ *
+ * Currently not supporting entities.
+ */
+
+package com.encrox.instanceddungeons;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.bukkit.Material;
+import org.jnbt.ByteArrayTag;
+import org.jnbt.CompoundTag;
+import org.jnbt.ListTag;
+import org.jnbt.NBTInputStream;
+import org.jnbt.ShortTag;
+import org.jnbt.StringTag;
+import org.jnbt.Tag;
+
+public class Schematic {
+
+ public int width, height, length, readIndex, writeIndex;
+ public String materials;
+ public byte[] blocks, data;
+ public List<Tag> entities, tileEntities;
+ public File file;
+
+ public Schematic(int width, int height, int length, String materials, byte[] blocks, byte[] data, List<Tag> entities, List<Tag> tileEntities) {
+ this.width = width;
+ this.height = height;
+ this.length = length;
+ this.materials = materials;
+ this.blocks = blocks;
+ this.data = data;
+ this.entities = entities;
+ this.tileEntities = tileEntities;
+ readIndex = -1;
+ writeIndex = -1;
+ }
+
+ public Schematic(File file) {
+ this.file = file;
+ CompoundTag schematicTag = null;
+ try {
+ NBTInputStream in = new NBTInputStream(new FileInputStream(file));
+ schematicTag = (CompoundTag)in.readTag();
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Map<String,Tag> schematic = schematicTag.getValue();
+ width = ((ShortTag)schematic.get("Width")).getValue();
+ height = ((ShortTag)schematic.get("Height")).getValue();
+ length = ((ShortTag)schematic.get("Length")).getValue();
+ materials = ((StringTag)schematic.get("Materials")).getValue();
+ blocks = ((ByteArrayTag)schematic.get("Blocks")).getValue();
+ data = ((ByteArrayTag)schematic.get("Data")).getValue();
+ entities = ((ListTag)schematic.get("Entities")).getValue();
+ tileEntities = ((ListTag)schematic.get("TileEntities")).getValue();
+ InstancedDungeons.logger.info("blocks: " + blocks.length);
+ InstancedDungeons.logger.info("data: " + data.length);
+ }
+
+ public byte getBlockIdAt(int x, int y, int z) {
+ return blocks[(y*length + z)*width + x];
+ }
+
+ public byte getNextBlock() {
+ return blocks[readIndex++];
+ }
+
+ public void setBlockIdAt(int x, int y, int z, byte blockId) {
+ blocks[(y*length + z)*width + x] = blockId;
+ }
+
+ public void setNextBlock(byte blockId) {
+ blocks[writeIndex++] = blockId;
+ }
+
+ public void write(File file) {
+
+ }
+
+}
diff --git a/src/main/java/com/encrox/instanceddungeons/Section.java b/src/main/java/com/encrox/instanceddungeons/Section.java
new file mode 100644
index 0000000..282a554
--- /dev/null
+++ b/src/main/java/com/encrox/instanceddungeons/Section.java
@@ -0,0 +1,499 @@
+package com.encrox.instanceddungeons;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.plugin.Plugin;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import com.encrox.instancedregions.InstancedProtectedCuboidRegion;
+import com.sk89q.worldedit.BlockVector;
+import com.sk89q.worldedit.CuboidClipboard;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.MaxChangedBlocksException;
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
+import com.sk89q.worldedit.data.DataException;
+import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
+
+public class Section {
+
+ private Schematic schematic;
+ private String schematicFileName;
+ private Map<BlockVector,Exit> exitMap;
+ private ArrayList<Player> players;
+ private BlockVector[] exits;
+ private BlockVector size, nearestPositiveX, nearestNegativeX, nearestPositiveY, nearestNegativeY, nearestPositiveZ, nearestNegativeZ;
+ private int index, depth;
+ private InstancedProtectedCuboidRegion region;
+ private Listener trigger;
+ private volatile boolean justEntered, portal = false;
+ private JSONObject descriptor;
+
+ public Section(JSONObject descriptor, int index, int depth) {
+ this.index = index;
+ this.depth = depth;
+ players = new ArrayList<Player>();
+ exitMap = new HashMap<BlockVector,Exit>();
+ schematicFileName = descriptor.getString("file");
+ JSONArray size = descriptor.getJSONArray("size");
+ this.size = new BlockVector(size.getInt(0), size.getInt(1), size.getInt(2));
+ JSONArray exits = descriptor.getJSONArray("exits");
+ this.exits = new BlockVector[exits.length()];
+ for(int i = 0; i<this.exits.length; i++) {
+ JSONArray current = exits.getJSONArray(i);
+ this.exits[i] = new BlockVector(current.getInt(0), current.getInt(1), current.getInt(2));
+ }
+ this.descriptor = descriptor;
+ }
+
+ public void load() throws Exception {
+ this.schematic = new Schematic(new File(InstancedDungeons.schematicsDirectory, schematicFileName));
+ if(index <= depth) {
+ Section next;
+ for(int i = 0; i<exits.length; i++) {
+ ArrayList<Exit> usable = new ArrayList<Exit>();
+ if(exits[i].getBlockX() == 0.0 || exits[i].getBlockX() == size.getBlockX()-1 || exits[i].getBlockZ() == 0.0 || exits[i].getBlockZ() == size.getBlockZ()-1) {
+ if(index == depth) {
+ for(int c = 0, length = InstancedDungeons.endDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.endDescriptors.getJSONObject(c), index+1, depth)).hasSideExit()) {
+ usable.addAll(next.getSideExits());
+ }
+ }
+ } else {
+ for(int c = 0, length = InstancedDungeons.normalDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.normalDescriptors.getJSONObject(c), index+1, depth)).hasSideExit()) {
+ usable.addAll(next.getSideExits());
+ }
+ }
+ }
+ } else if(exits[i].getBlockY() == 0.0) {
+ if(index == depth) {
+ for(int c = 0, length = InstancedDungeons.endDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.endDescriptors.getJSONObject(c), index+1, depth)).hasTopExit()) {
+ usable.addAll(next.getTopExits());
+ }
+ }
+ } else {
+ for(int c = 0, length = InstancedDungeons.normalDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.normalDescriptors.getJSONObject(c), index+1, depth)).hasTopExit()) {
+ usable.addAll(next.getTopExits());
+ }
+ }
+ }
+ } else if(exits[i].getBlockY() == size.getBlockY()-1) {
+ if(index == depth) {
+ for(int c = 0, length = InstancedDungeons.endDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.endDescriptors.getJSONObject(c), index+1, depth)).hasBottomExit()) {
+ usable.addAll(next.getBottomExits());
+ }
+ }
+ } else {
+ for(int c = 0, length = InstancedDungeons.normalDescriptors.length(); c<length; c++) {
+ if((next = new Section(InstancedDungeons.normalDescriptors.getJSONObject(c), index+1, depth)).hasBottomExit()) {
+ usable.addAll(next.getBottomExits());
+ }
+ }
+ }
+ } else {
+ throw new Exception("No schematic with a valid exit found.");
+ }
+ exitMap.put(exits[i], usable.get((int)Math.round(Math.random()*(usable.size()-1))));
+ }
+ }
+ }
+
+ public BlockVector[] getExits() {
+ return exits;
+ }
+
+ public BlockVector[] getAbsoluteExits() {
+ BlockVector[] out = new BlockVector[exits.length];
+ BlockVector min = region.getMinimumPoint();
+ for(int i = 0; i<exits.length; i++) {
+ out[i] = new BlockVector(min.getBlockX()+exits[i].getBlockX(), 128+exits[i].getBlockY(), min.getBlockZ()+exits[i].getBlockZ());
+ }
+ return out;
+ }
+
+ public BlockVector absoluteToRelativeExit(BlockVector bv) {
+ BlockVector min = region.getMinimumPoint();
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == bv.getBlockX()-min.getBlockX()
+ && exits[i].getBlockY() == bv.getBlockY()-128
+ && exits[i].getBlockZ() == bv.getBlockZ()-min.getBlockZ())
+ return exits[i];
+ }
+ return null;
+ }
+
+ public BlockVector relativeToAbsoluteExit(BlockVector bv) {
+ BlockVector min = region.getMinimumPoint();
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == bv.getBlockX()
+ && exits[i].getBlockY() == bv.getBlockY()
+ && exits[i].getBlockZ() == bv.getBlockZ())
+ return new BlockVector(min.getBlockX()+exits[i].getBlockX(), 128+exits[i].getBlockY(), min.getBlockZ()+exits[i].getBlockZ());
+ }
+ return null;
+ }
+
+ public ArrayList<Exit> getSideExits() {
+ ArrayList<Exit> out = new ArrayList<Exit>();
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == 0.0 || exits[i].getBlockX() == size.getBlockX()-1.0
+ || exits[i].getBlockZ() == .0 || exits[i].getBlockZ() == size.getBlockZ()-1.0) {
+ out.add(new Exit(this, exits[i]));
+ }
+ }
+ return out;
+ }
+
+ public ArrayList<Exit> getTopExits() {
+ ArrayList<Exit> out = new ArrayList<Exit>();
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == size.getBlockY()-1.0) {
+ out.add(new Exit(this, exits[i]));
+ }
+ }
+ return out;
+ }
+
+ public ArrayList<Exit> getBottomExits() {
+ ArrayList<Exit> out = new ArrayList<Exit>();
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == 0.0) {
+ out.add(new Exit(this, exits[i]));;
+ }
+ }
+ return out;
+ }
+
+ public BlockVector getNearestExitPositiveX(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == size.getBlockX()-1) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public BlockVector getNearestExitNegativeX(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == 0.0) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public BlockVector getNearestExitPositiveY(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == size.getBlockY()-1) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public BlockVector getNearestExitNegativeY(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == 0.0) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public BlockVector getNearestExitPositiveZ(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockZ() == size.getBlockZ()-1) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public BlockVector getNearestExitNegativeZ(org.bukkit.util.Vector relative) {
+ BlockVector nearest = null;
+ double dist = 0.0, current;
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockZ() == 0.0) {
+ if((current = exits[i].distance(new Vector(relative.getX(), relative.getY(), relative.getZ()))) > dist) {
+ dist = current;
+ nearest = exits[i];
+ }
+ }
+ }
+ return nearest;
+ }
+
+ public void instantiate() {
+ InstancedDungeons.logger.info("Instantiating section (file: " + descriptor.getString("file") + ", index: " + index + ", depth: " + depth + ")");
+ justEntered = true;
+ portal = false;
+ region = InstancedDungeons.dungeonWorld.allocate(size.getBlockX(), size.getBlockZ());
+ Iterator<Player> iter = players.iterator();
+ while(iter.hasNext())
+ region.addPlayer(iter.next());
+ //write schematic to map
+ final BlockVector min = region.getMinimumPoint();
+
+ for(int i = 0; i<exits.length; i++) {
+ try {
+ exitMap.get(exits[i]).getSection().load();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ //DEBUG
+ for(int i = 0; i<exits.length; i++) {
+ InstancedDungeons.logger.info("Exit at: (" + (min.getBlockX()+exits[i].getBlockX()) + ", " + (128+exits[i].getBlockY()) + ", " + (min.getBlockZ()+exits[i].getBlockZ()));
+ }
+
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ region.addToChangeWhitelist(new BlockVector(min.getBlockX()+x, 128+y, min.getBlockZ()+z));
+ }
+ }
+ }
+
+ EditSession es = InstancedDungeons.we.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(InstancedDungeons.dungeonWorld.getWorld()), Integer.MAX_VALUE);
+ try {
+ MCEditSchematicFormat.getFormat(schematic.file).load(schematic.file).paste(es, new Vector(min.getBlockX()-1, 128, min.getBlockZ()), false);
+ } catch (MaxChangedBlocksException | DataException | IOException e1) {
+ e1.printStackTrace();
+ }
+
+ /*
+ byte next;
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ next = schematic.getNextBlock();
+ region.addToChangeWhitelist(new BlockVector(min.getBlockX()+x, 128+y, min.getBlockZ()+z));
+ InstancedDungeons.dungeonWorld.getWorld().getBlockAt(min.getBlockX()+x, 128+y, min.getBlockZ()+z).setType(Material.getMaterial(next));
+
+ }
+ }
+ }
+ */
+ Bukkit.getScheduler().scheduleSyncDelayedTask(InstancedDungeons.plugin, new Runnable() {
+ @Override
+ public void run() {
+ InstancedDungeons.logger.info("portal activated");
+ justEntered = false;
+ }
+ }, 120L);
+ trigger = new Listener() {
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onMove(PlayerMoveEvent event) {
+ Location to = event.getTo();
+ Player player = event.getPlayer();
+ org.bukkit.util.Vector tov = to.toVector();
+ BlockVector nearest;
+ //draw x+ if changed
+ if((nearest = getNearestExitPositiveX(tov)) != null) {
+ if(nearest != nearestPositiveX) {
+ nearestPositiveX = nearest;
+ BlockVector exit = exitMap.get(nearest).getRelativeBlockVector(), absolute = relativeToAbsoluteExit(nearest);
+ Section section = exitMap.get(nearest).getSection();
+ Schematic schematic = section.getSchematic();
+ if(exit.getBlockX() == 0.0) {
+ //rotate along y axis by 0 degree
+ InstancedDungeons.logger.info("negative x");
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ region.addToChangeWhitelist(new BlockVector(absolute.getBlockX()+1+x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockZ()+z));
+ player.sendBlockChange(new Location(InstancedDungeons.dungeonWorld.getWorld(), absolute.getBlockX()+1+x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockZ()+z), Material.getMaterial(schematic.getNextBlock()), (byte) 0);
+ }
+ }
+ }
+ } else if(exit.getBlockX() == section.size.getBlockX()-1) { //works
+ InstancedDungeons.logger.info("positive x");
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ region.addToChangeWhitelist(new BlockVector(absolute.getBlockX()+schematic.width-x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockZ()+z));
+ player.sendBlockChange(new Location(InstancedDungeons.dungeonWorld.getWorld(), absolute.getBlockX()+schematic.width-x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockZ()+z), Material.getMaterial(schematic.getNextBlock()), (byte) 0);
+ }
+ }
+ }
+ } else if(exit.getBlockZ() == 0.0) {
+ InstancedDungeons.logger.info("negative z");
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ region.addToChangeWhitelist(new BlockVector(absolute.getBlockX()+1+x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()+1+z));
+ player.sendBlockChange(new Location(InstancedDungeons.dungeonWorld.getWorld(), absolute.getBlockX()+1+x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()+1+z), Material.getMaterial(schematic.getNextBlock()), (byte) 0);
+ }
+ }
+ }
+ } else if(exit.getBlockZ() == section.size.getBlockZ()-1) {
+ InstancedDungeons.logger.info("positive z");
+ for(int y = 0; y<schematic.height; y++) {
+ for(int z = 0; z<schematic.length; z++) {
+ for(int x = 0; x<schematic.width; x++) {
+ region.addToChangeWhitelist(new BlockVector(absolute.getBlockX()+schematic.length-x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockX()+z));
+ player.sendBlockChange(new Location(InstancedDungeons.dungeonWorld.getWorld(), absolute.getBlockX()+schematic.length-x, absolute.getBlockY()-exit.getBlockY()+y, absolute.getBlockZ()-exit.getBlockX()+z), Material.getMaterial(schematic.getNextBlock()), (byte) 0);
+ }
+ }
+ }
+ }
+ }
+ }
+ if(!justEntered) {
+ if(portal) {
+ for(int i = 0; i<exits.length; i++) {
+ if(to.getWorld().equals(InstancedDungeons.dungeonWorld.getWorld())
+ && to.getBlockX() == min.getBlockX() + exits[i].getBlockX()
+ && to.getBlockY() == 128 + exits[i].getBlockY()
+ && to.getBlockZ() == min.getBlockZ() + exits[i].getBlockZ()) {
+ InstancedDungeons.logger.info("Player in loading zone");
+ portal = false;
+ Section next = exitMap.get(exits[i]).getSection();
+ try {
+ region.dispose();
+ for(int c = 0, size = players.size(); c<size; c++) {
+ next.addPlayer(players.get(c));
+ }
+ next.instantiate();
+ BlockVector destination = next.relativeToAbsoluteExit(exitMap.get(exits[i]).getRelativeBlockVector());
+ //next.assignExit(destination, new Section(descriptor, index, depth));
+ event.getPlayer().teleport(new Location(Bukkit.getWorld("world_nether"), -100000, 200, -100000));
+ event.getPlayer().teleport(new Location(InstancedDungeons.dungeonWorld.getWorld(), destination.getBlockX(), destination.getBlockY(), destination.getBlockZ()).add(.5, 0, .5));
+ InstancedDungeons.dungeonWorld.deallocate(region);
+ HandlerList.unregisterAll(this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ } else {
+ for(int i = 0; i<exits.length; i++) {
+ if(to.getWorld().equals(InstancedDungeons.dungeonWorld.getWorld())
+ && to.getBlockX() == min.getBlockX() + exits[i].getBlockX()
+ && to.getBlockY() == 128 + exits[i].getBlockY()
+ && to.getBlockZ() == min.getBlockZ() + exits[i].getBlockZ()) {
+ return;
+ }
+ }
+ portal = true;
+ }
+ }
+ }
+ };
+ Bukkit.getPluginManager().registerEvents(trigger, InstancedDungeons.plugin);
+ region.apply();
+ }
+
+ public Schematic getSchematic() {
+ return schematic;
+ }
+
+ public void activateExits() {
+
+ }
+
+ public void assignExit(BlockVector v, Exit exit) {
+ exitMap.put(v, exit);
+ }
+
+ public boolean hasSideExit() {
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockX() == 0
+ || exits[i].getBlockX() == size.getBlockX()-1
+ || exits[i].getBlockZ() == 0
+ || exits[i].getBlockZ() == size.getBlockZ()-1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasTopExit() {
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == size.getBlockY()-1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasBottomExit() {
+ for(int i = 0; i<exits.length; i++) {
+ if(exits[i].getBlockY() == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void addPlayer(Player player) {
+ players.add(player);
+ if(region != null)
+ region.addPlayer(player);
+ if(exitMap != null) {
+ Iterator<Exit> exits = exitMap.values().iterator();
+ while(exits.hasNext())
+ exits.next().getSection().addPlayer(player);
+ }
+ }
+
+ public void removePlayer(Player player) {
+ players.add(player);
+ if(region != null)
+ region.removePlayer(player);
+ if(exitMap != null) {
+ Iterator<Exit> exits = exitMap.values().iterator();
+ while(exits.hasNext())
+ exits.next().getSection().removePlayer(player);
+ }
+ }
+
+}
diff --git a/src/main/resources/config.json b/src/main/resources/config.json
new file mode 100644
index 0000000..da68812
--- /dev/null
+++ b/src/main/resources/config.json
@@ -0,0 +1,22 @@
+{
+ "locale": "en-GB",
+ "world": "instance",
+ "loadingDepth": 2,
+ "resetDungeons": [
+ {
+ "interval": 2592000,
+ "alias": "monthly",
+ "length": 10
+ },
+ {
+ "interval": 86400,
+ "alias": "daily",
+ "length": 10
+ },
+ {
+ "interval": 3600,
+ "alias": "hourly",
+ "length": 10
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/main/resources/descriptor.json b/src/main/resources/descriptor.json
new file mode 100644
index 0000000..16d8891
--- /dev/null
+++ b/src/main/resources/descriptor.json
@@ -0,0 +1,72 @@
+{
+ "schematics": [
+ {
+ "file": "startSide.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 1, 0 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "startBottom.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 0, 4 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "startTop.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 9, 4 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endSide.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 1, 0 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endBottom.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 0, 4 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endTop.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 9, 4 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "test.schematic",
+ "modifier": 0,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 0, 1, 5 ],
+ [ 4, 1, 0 ],
+ [ 9, 1, 4 ],
+ [ 5, 1, 9 ],
+ [ 2, 0, 7 ],
+ [ 5, 9, 5 ]
+ ],
+ "mobs": []
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/main/resources/lang/de-DE.properties b/src/main/resources/lang/de-DE.properties
new file mode 100644
index 0000000..fe1b047
--- /dev/null
+++ b/src/main/resources/lang/de-DE.properties
@@ -0,0 +1 @@
+no_player=no_player \ No newline at end of file
diff --git a/src/main/resources/lang/en-GB.properties b/src/main/resources/lang/en-GB.properties
new file mode 100644
index 0000000..fe1b047
--- /dev/null
+++ b/src/main/resources/lang/en-GB.properties
@@ -0,0 +1 @@
+no_player=no_player \ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..18510eb
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,9 @@
+main: com.encrox.instanceddungeons.InstancedDungeons
+name: InstancedDungeons
+version: 1.0
+depend: [InstancedRegions]
+
+commands:
+ dungeon:
+ description: Generic dungeon command.
+ usage: /dungeon help \ No newline at end of file
diff --git a/src/main/resources/schematics/endBottom.schematic b/src/main/resources/schematics/endBottom.schematic
new file mode 100644
index 0000000..9db40b2
--- /dev/null
+++ b/src/main/resources/schematics/endBottom.schematic
Binary files differ
diff --git a/src/main/resources/schematics/endSide.schematic b/src/main/resources/schematics/endSide.schematic
new file mode 100644
index 0000000..37b5b2a
--- /dev/null
+++ b/src/main/resources/schematics/endSide.schematic
Binary files differ
diff --git a/src/main/resources/schematics/endTop.schematic b/src/main/resources/schematics/endTop.schematic
new file mode 100644
index 0000000..a13a690
--- /dev/null
+++ b/src/main/resources/schematics/endTop.schematic
Binary files differ
diff --git a/src/main/resources/schematics/startBottom.schematic b/src/main/resources/schematics/startBottom.schematic
new file mode 100644
index 0000000..c03c38d
--- /dev/null
+++ b/src/main/resources/schematics/startBottom.schematic
Binary files differ
diff --git a/src/main/resources/schematics/startSide.schematic b/src/main/resources/schematics/startSide.schematic
new file mode 100644
index 0000000..09c6c66
--- /dev/null
+++ b/src/main/resources/schematics/startSide.schematic
Binary files differ
diff --git a/src/main/resources/schematics/startTop.schematic b/src/main/resources/schematics/startTop.schematic
new file mode 100644
index 0000000..f905219
--- /dev/null
+++ b/src/main/resources/schematics/startTop.schematic
Binary files differ
diff --git a/src/main/resources/schematics/test.schematic b/src/main/resources/schematics/test.schematic
new file mode 100644
index 0000000..624505f
--- /dev/null
+++ b/src/main/resources/schematics/test.schematic
Binary files differ
diff --git a/target/classes/config.json b/target/classes/config.json
new file mode 100644
index 0000000..da68812
--- /dev/null
+++ b/target/classes/config.json
@@ -0,0 +1,22 @@
+{
+ "locale": "en-GB",
+ "world": "instance",
+ "loadingDepth": 2,
+ "resetDungeons": [
+ {
+ "interval": 2592000,
+ "alias": "monthly",
+ "length": 10
+ },
+ {
+ "interval": 86400,
+ "alias": "daily",
+ "length": 10
+ },
+ {
+ "interval": 3600,
+ "alias": "hourly",
+ "length": 10
+ }
+ ]
+} \ No newline at end of file
diff --git a/target/classes/descriptor.json b/target/classes/descriptor.json
new file mode 100644
index 0000000..16d8891
--- /dev/null
+++ b/target/classes/descriptor.json
@@ -0,0 +1,72 @@
+{
+ "schematics": [
+ {
+ "file": "startSide.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 1, 0 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "startBottom.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 0, 4 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "startTop.schematic",
+ "modifier": 1,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 9, 4 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endSide.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 1, 0 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endBottom.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 0, 4 ]
+ ],
+ "mobs": []
+ },
+ {
+ "file": "endTop.schematic",
+ "modifier": 2,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 4, 9, 4 ]
+ ],
+ "mobs": [ ]
+ },
+ {
+ "file": "test.schematic",
+ "modifier": 0,
+ "size": [ 10, 10, 10 ],
+ "exits": [
+ [ 0, 1, 5 ],
+ [ 4, 1, 0 ],
+ [ 9, 1, 4 ],
+ [ 5, 1, 9 ],
+ [ 2, 0, 7 ],
+ [ 5, 9, 5 ]
+ ],
+ "mobs": []
+ }
+ ]
+} \ No newline at end of file
diff --git a/target/classes/lang/de-DE.properties b/target/classes/lang/de-DE.properties
new file mode 100644
index 0000000..fe1b047
--- /dev/null
+++ b/target/classes/lang/de-DE.properties
@@ -0,0 +1 @@
+no_player=no_player \ No newline at end of file
diff --git a/target/classes/lang/en-GB.properties b/target/classes/lang/en-GB.properties
new file mode 100644
index 0000000..fe1b047
--- /dev/null
+++ b/target/classes/lang/en-GB.properties
@@ -0,0 +1 @@
+no_player=no_player \ No newline at end of file
diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml
new file mode 100644
index 0000000..18510eb
--- /dev/null
+++ b/target/classes/plugin.yml
@@ -0,0 +1,9 @@
+main: com.encrox.instanceddungeons.InstancedDungeons
+name: InstancedDungeons
+version: 1.0
+depend: [InstancedRegions]
+
+commands:
+ dungeon:
+ description: Generic dungeon command.
+ usage: /dungeon help \ No newline at end of file
diff --git a/target/classes/schematics/endBottom.schematic b/target/classes/schematics/endBottom.schematic
new file mode 100644
index 0000000..9db40b2
--- /dev/null
+++ b/target/classes/schematics/endBottom.schematic
Binary files differ
diff --git a/target/classes/schematics/endSide.schematic b/target/classes/schematics/endSide.schematic
new file mode 100644
index 0000000..37b5b2a
--- /dev/null
+++ b/target/classes/schematics/endSide.schematic
Binary files differ
diff --git a/target/classes/schematics/endTop.schematic b/target/classes/schematics/endTop.schematic
new file mode 100644
index 0000000..a13a690
--- /dev/null
+++ b/target/classes/schematics/endTop.schematic
Binary files differ
diff --git a/target/classes/schematics/startBottom.schematic b/target/classes/schematics/startBottom.schematic
new file mode 100644
index 0000000..c03c38d
--- /dev/null
+++ b/target/classes/schematics/startBottom.schematic
Binary files differ
diff --git a/target/classes/schematics/startSide.schematic b/target/classes/schematics/startSide.schematic
new file mode 100644
index 0000000..09c6c66
--- /dev/null
+++ b/target/classes/schematics/startSide.schematic
Binary files differ
diff --git a/target/classes/schematics/startTop.schematic b/target/classes/schematics/startTop.schematic
new file mode 100644
index 0000000..f905219
--- /dev/null
+++ b/target/classes/schematics/startTop.schematic
Binary files differ
diff --git a/target/classes/schematics/test.schematic b/target/classes/schematics/test.schematic
new file mode 100644
index 0000000..624505f
--- /dev/null
+++ b/target/classes/schematics/test.schematic
Binary files differ
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
new file mode 100644
index 0000000..8f2b565
--- /dev/null
+++ b/target/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Fri Dec 23 23:15:34 CET 2016
+version=0.0.1-SNAPSHOT
+groupId=com.encrox
+artifactId=instanceddungeons
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..159d9f8
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,8 @@
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Commander.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Exit.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Schematic.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Dungeon.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Direction.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\DungeonWorld.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\Section.java
+C:\Users\Superleo1810\workspace\instanceddungeons\src\main\java\com\encrox\instanceddungeons\InstancedDungeons.java
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst