From 90655cf76322b98c9d52bd6c2a61bfbacb1e13dc Mon Sep 17 00:00:00 2001 From: Nate Mortensen Date: Wed, 23 Oct 2013 21:29:44 -0600 Subject: [PATCH] Now version 1.0. Fully functional. --- .../structuresaver/StructureSaver.java | 23 ++++--------------- src/main/resources/plugin.yml | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/evilmidget38/structuresaver/StructureSaver.java b/src/main/java/com/evilmidget38/structuresaver/StructureSaver.java index d65f5a7..562e292 100644 --- a/src/main/java/com/evilmidget38/structuresaver/StructureSaver.java +++ b/src/main/java/com/evilmidget38/structuresaver/StructureSaver.java @@ -10,21 +10,17 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; -import org.bukkit.event.EventHandler; -import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; +import net.minecraft.server.v1_6_R3.ChunkProviderServer; import net.minecraft.server.v1_6_R3.IChunkProvider; import net.minecraft.server.v1_6_R3.RegionFile; public class StructureSaver extends JavaPlugin { private static final String[] regionLocations = new String[] {"region", "DIM-1/region", "DIM1/region"}; - - public void onEnable() { - } - + public void saveAllStructures() { - getLogger().info("Saving all structures"); + getLogger().info("Saving all structures..."); for (World world : Bukkit.getWorlds()) { saveStructures(world); } @@ -32,7 +28,7 @@ public void saveAllStructures() { } public void saveStructures(World world) { - getLogger().info("Generating structures for "+world.getName()); + getLogger().info("Generating structures for "+world.getName()+"..."); long start = System.currentTimeMillis(); File regionDir = getRegionsLocation(world); if (regionDir == null) { @@ -52,11 +48,10 @@ public void saveStructures(World world) { getLogger().severe("Unable to handle region: "+file.getName()); continue; } - getLogger().info("Creating structures for region: "+regionX+", "+regionZ); regionX = regionX << 5; regionZ = regionZ << 5; RegionFile region = new RegionFile(file); - IChunkProvider chunkProvider = ((CraftWorld) world).getHandle().chunkProvider; + IChunkProvider chunkProvider = ((ChunkProviderServer) ((CraftWorld) world).getHandle().chunkProvider).chunkProvider; // Iterate over all potential chunks in the region. for (int chunkX = 0; chunkX < 32; chunkX++) { for (int chunkZ = 0; chunkZ < 32; chunkZ++) { @@ -106,12 +101,4 @@ public boolean onCommand(CommandSender sender, Command command, String label, St return false; } } - - @EventHandler - public void onChunkLoad(ChunkLoadEvent e) { - // temporary debug code. - if (e.isNewChunk()) { - e.getChunk().unload(false, false); - } - } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 42ba71c..4a71629 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ main: com.evilmidget38.structuresaver.StructureSaver -version: 0.1 +version: 1.0 name: StructureSaver author: evilmidget38 commands: