Skip to content

Commit

Permalink
Now version 1.0. Fully functional.
Browse files Browse the repository at this point in the history
  • Loading branch information
natemort committed Oct 24, 2013
1 parent 7e5a372 commit 90655cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
23 changes: 5 additions & 18 deletions src/main/java/com/evilmidget38/structuresaver/StructureSaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,25 @@
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);
}
getLogger().info("Done saving structures!");
}

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) {
Expand All @@ -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++) {
Expand Down Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main: com.evilmidget38.structuresaver.StructureSaver
version: 0.1
version: 1.0
name: StructureSaver
author: evilmidget38
commands:
Expand Down

0 comments on commit 90655cf

Please sign in to comment.