From 30a1e4505ee95d9ae87ac70afa12d56a932d0dc8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Jul 2015 02:54:06 +1000 Subject: [PATCH] Schematic stuff --- .../plot/database/SQLManager.java | 8 +++-- .../plot/util/SchematicHandler.java | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index d71a1ea9f..32d8f5e5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -144,8 +144,10 @@ public class SQLManager implements AbstractDB { @Override public void run() { try { - connection.setAutoCommit(false); - + try { + connection.setAutoCommit(false); + } + catch (SQLException e) {} // Create the plots createPlots(myList, new Runnable() { @Override @@ -229,7 +231,7 @@ public class SQLManager implements AbstractDB { } } }); - } catch (SQLException e) { + } catch (Exception e) { e.printStackTrace(); PS.log("&7[WARN] " + "Failed to set all helpers for plots"); try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 971a65438..4443ab87e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -16,6 +16,7 @@ import java.net.URLConnection; import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -33,6 +34,7 @@ import com.intellectualcrafters.jnbt.ListTag; import com.intellectualcrafters.jnbt.NBTInputStream; import com.intellectualcrafters.jnbt.NBTOutputStream; import com.intellectualcrafters.jnbt.ShortTag; +import com.intellectualcrafters.jnbt.StringTag; import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; @@ -375,6 +377,33 @@ public abstract class SchematicHandler { return true; } + /** + * Create a compound tag from blocks + * - Untested + * @param blocks + * @param blockdata + * @param d + * @return + */ + public CompoundTag createTag(byte[] blocks, byte[] blockdata, Dimension d) { + final HashMap schematic = new HashMap<>(); + schematic.put("Width", new ShortTag("Width", (short) d.getX())); + schematic.put("Length", new ShortTag("Length", (short) d.getZ())); + schematic.put("Height", new ShortTag("Height", (short) d.getY())); + schematic.put("Materials", new StringTag("Materials", "Alpha")); + schematic.put("WEOriginX", new IntTag("WEOriginX", 0)); + schematic.put("WEOriginY", new IntTag("WEOriginY", 0)); + schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0)); + schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0)); + schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0)); + schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0)); + schematic.put("Blocks", new ByteArrayTag("Blocks", blocks)); + schematic.put("Data", new ByteArrayTag("Data", blockdata)); + schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList())); + schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList())); + return new CompoundTag("Schematic", schematic); + } + /** * Gets the schematic of a plot *