diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..9896aeb
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..bba6511
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,26 @@
+cache:
+ directories:
+ - $HOME/.m2/repository/org/
+before_install: | # Wget BuildTools and run if cached folder not found
+ if [ ! -d "$HOME/.m2/repository/org/spigotmc/spigot/1.12.2-R0.1-SNAPSHOT" ]; then
+ wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
+ # grep so that download counts don't appear in log files
+ java -jar BuildTools.jar --rev 1.12.2 # | grep -vE "[^/ ]*/[^/ ]*\s*KB\s*$" | grep -v "^\s*$"
+ fi
+language: java
+jdk:
+ - oraclejdk8
+sudo: required
+deploy:
+ # deploy develop to the staging environment
+ - provider: script
+ script: chmod +x deploy.sh && sh deploy.sh staging
+ on:
+ branch: dev
+ skip_cleanup: true
+ # deploy master to production
+ - provider: script
+ script: chmod +x deploy.sh && sh deploy.sh production
+ on:
+ branch: master
+ skip_cleanup: true
diff --git a/README_ChunkArchive.md b/README_ChunkArchive.md
new file mode 100644
index 0000000..94056ea
--- /dev/null
+++ b/README_ChunkArchive.md
@@ -0,0 +1,2 @@
+# ChunkArchive
+Archives chunks as they're populated
diff --git a/deploy.sh b/deploy.sh
new file mode 100644
index 0000000..5750295
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+FILENAME=$(find target/ ! -name '*original*' -name '*.jar')
+echo Found file: $FILENAME
+
+if [ $1 = 'production' ]; then
+echo Production mode
+echo $UPLOAD_KEY > upload_key
+chmod 400 upload_key
+yes | scp -B -i upload_key -o StrictHostKeyChecking=no $FILENAME travis@server.figytuna.com:/minecraft/main/TBMC/pluginupdates
+fi
+
diff --git a/pom.xml b/pom.xml
index 6f02072..04e47c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,8 +34,8 @@
maven-compiler-plugin
3.0
-
- 1.7
+
+ 1.8
@@ -63,8 +63,8 @@
org.spigotmc
- spigot-api
- 1.11-R0.1-SNAPSHOT
+ spigot
+ 1.12.2-R0.1-SNAPSHOT
com.github.TBMCPlugins.ButtonCore
diff --git a/src/main/java/buttondevteam/presents/ButtonPresents.java b/src/main/java/buttondevteam/presents/ButtonPresents.java
index 9c533ed..65be054 100644
--- a/src/main/java/buttondevteam/presents/ButtonPresents.java
+++ b/src/main/java/buttondevteam/presents/ButtonPresents.java
@@ -1,14 +1,14 @@
package buttondevteam.presents;
-import java.util.logging.Logger;
-
-import org.bukkit.plugin.PluginDescriptionFile;
-import org.bukkit.plugin.java.JavaPlugin;
-
+import buttondevteam.presents.components.chunkarchive.ChunkArchiveComponent;
import buttondevteam.presents.components.magic.MagicComponent;
import buttondevteam.presents.components.research.ResearchComponent;
import buttondevteam.presents.components.research.dictionary.DictionaryComponent;
import buttondevteam.presents.components.spawn.SpawnComponent;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.logging.Logger;
public class ButtonPresents extends JavaPlugin{
@@ -23,6 +23,7 @@ public class ButtonPresents extends JavaPlugin{
new SpawnComponent().register(this);
new MagicComponent().register(this);
new ResearchComponent().register(this);
+ new ChunkArchiveComponent().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
}
diff --git a/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java b/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java
new file mode 100644
index 0000000..19cdff7
--- /dev/null
+++ b/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java
@@ -0,0 +1,58 @@
+package buttondevteam.presents.components.chunkarchive;
+
+import buttondevteam.lib.TBMCCoreAPI;
+import buttondevteam.presents.architecture.Component;
+import net.minecraft.server.v1_12_R1.ChunkRegionLoader;
+import net.minecraft.server.v1_12_R1.ExceptionWorldConflict;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
+import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
+import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.world.ChunkPopulateEvent;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+// @formatter:off
+public class ChunkArchiveComponent extends Component implements Listener {
+ private final File dataFolder = new File("plugins", "ChunkArchive");
+ @Override
+ public void register(JavaPlugin plugin) {
+ try {
+ this.registerListener(plugin, this);
+ File testFolder = new File(dataFolder, "test");
+ testFolder.mkdirs();
+ Logger logger = plugin.getLogger();
+ logger.info("Starting chunk save test...");
+ ChunkRegionLoader testcrl = new ChunkRegionLoader(testFolder,
+ ((CraftServer) Bukkit.getServer()).getServer().dataConverterManager);
+ CraftWorld mainWorld=(CraftWorld) Bukkit.getWorlds().get(0);
+ testcrl.saveChunk(mainWorld.getHandle(),
+ ((CraftChunk) mainWorld.getLoadedChunks()[0]).getHandle(), false);
+ logger.info("Test complete");
+ }
+ catch(Exception e) {
+ TBMCCoreAPI.SendException("ChunkArchive loading/testing failed!", e);
+ }
+ }
+ /*------------------------------------------------------------*/
+
+ private final ChunkRegionLoader chunkRegionLoader =
+
+ new ChunkRegionLoader(dataFolder,
+ ((CraftServer) Bukkit.getServer()).getServer().dataConverterManager);
+
+ /*------------------------------------------------------------*/
+
+ @EventHandler
+ public void onChunkPopulate(ChunkPopulateEvent event) throws IOException, ExceptionWorldConflict
+ {
+ if (event.getWorld().getName().equals("world"))
+ chunkRegionLoader.saveChunk(((CraftWorld) event.getWorld()).getHandle(),
+ ((CraftChunk) event.getChunk()).getHandle(), false);
+ }
+}