From 5b275e41704a2568986a921f1ecd76883e7dba44 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Mon, 6 Jan 2020 20:57:21 -0500 Subject: [PATCH] ffs --- .../iris/schematic/Schematic.java~HEAD | 207 ++++++++++++++++++ ...tic.java~parent of cdddf03... 1.15 Support | 207 ++++++++++++++++++ ...ticGroup.java => SchematicGroup.java~HEAD} | 0 ...oup.java~parent of cdddf03... 1.15 Support | 64 ++++++ 4 files changed, 478 insertions(+) create mode 100644 src/main/java/ninja/bytecode/iris/schematic/Schematic.java~HEAD create mode 100644 src/main/java/ninja/bytecode/iris/schematic/Schematic.java~parent of cdddf03... 1.15 Support rename src/main/java/ninja/bytecode/iris/schematic/{SchematicGroup.java => SchematicGroup.java~HEAD} (100%) create mode 100644 src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~parent of cdddf03... 1.15 Support diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~HEAD b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~HEAD new file mode 100644 index 000000000..4695a0e54 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~HEAD @@ -0,0 +1,207 @@ +package ninja.bytecode.iris.schematic; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPInputStream; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.util.BlockVector; + +import ninja.bytecode.iris.util.Catalyst12; +import ninja.bytecode.iris.util.MB; +import ninja.bytecode.shuriken.collections.GMap; +import ninja.bytecode.shuriken.io.CustomOutputStream; +import ninja.bytecode.shuriken.logging.L; + +public class Schematic +{ + private boolean centeredHeight; + private int w; + private int h; + private int d; + private int x; + private int y; + private int z; + private final GMap s; + + public Schematic(int w, int h, int d, int x, int y, int z) + { + this.w = w; + this.h = h; + this.d = d; + this.x = x; + this.y = y; + this.z = z; + s = new GMap<>(); + centeredHeight = false; + } + + public void setCenteredHeight() + { + this.centeredHeight = true; + } + + public int getW() + { + return w; + } + + public int getH() + { + return h; + } + + public int getD() + { + return d; + } + + public int getX() + { + return x; + } + + public int getY() + { + return y; + } + + public int getZ() + { + return z; + } + + public GMap getSchematic() + { + return s; + } + + @SuppressWarnings("deprecation") + public void read(InputStream in) throws IOException + { + GZIPInputStream gzi = new GZIPInputStream(in); + DataInputStream din = new DataInputStream(gzi); + w = din.readInt(); + h = din.readInt(); + d = din.readInt(); + x = din.readInt(); + y = din.readInt(); + z = din.readInt(); + int l = din.readInt(); + clear(); + + for(int i = 0; i < l; i++) + { + s.put(new BlockVector(din.readInt(), din.readInt(), din.readInt()), new MB(Material.getMaterial((int) din.readInt()), din.readInt())); + } + + din.close(); + } + + @SuppressWarnings("deprecation") + public void write(OutputStream out) throws IOException + { + CustomOutputStream cos = new CustomOutputStream(out, 9); + DataOutputStream dos = new DataOutputStream(cos); + dos.writeInt(w); + dos.writeInt(h); + dos.writeInt(d); + dos.writeInt(x); + dos.writeInt(y); + dos.writeInt(z); + dos.writeInt(s.size()); + + for(BlockVector i : s.keySet()) + { + dos.writeInt(i.getBlockX()); + dos.writeInt(i.getBlockY()); + dos.writeInt(i.getBlockZ()); + dos.writeInt(s.get(i).material.getId()); + dos.writeInt(s.get(i).data); + } + + dos.close(); + } + + public BlockVector getOffset() + { + return new BlockVector(x, y, z); + } + + public MB get(int x, int y, int z) + { + return s.get(new BlockVector(x, y, z)); + } + + public boolean has(int x, int y, int z) + { + return s.contains(new BlockVector(x, y, z)); + } + + public void put(int x, int y, int z, MB mb) + { + s.put(new BlockVector(x, y, z), mb); + } + + public Schematic copy() + { + Schematic s = new Schematic(w, h, d, x, y, z); + s.fill(this.s); + s.centeredHeight = centeredHeight; + return s; + } + + public void clear() + { + s.clear(); + } + + public void fill(GMap b) + { + clear(); + s.put(b); + } + + public void place(World source, int wx, int wy, int wz) + { + Location start = new Location(source, wx, wy, wz).clone().subtract(0, centeredHeight ? h / 2 : 0, 0); + + for(BlockVector i : getSchematic().k()) + { + MB b = getSchematic().get(i); + Location f = start.clone().add(i); + + if(b.material.equals(Material.SKULL)) + { + continue; + } + + try + { + Catalyst12.setBlock(source, f.getBlockX(), f.getBlockY(), f.getBlockZ(), b); + } + + catch(Throwable e) + { + e.printStackTrace(); + } + } + } + + public static Schematic load(File f) throws IOException + { + Schematic s = new Schematic(1, 1, 1, 1, 1, 1); + FileInputStream fin = new FileInputStream(f); + s.read(fin); + + L.i("Loaded Schematic: " + f.getPath() + " Size: " + s.getSchematic().size()); + return s; + } +} diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~parent of cdddf03... 1.15 Support b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~parent of cdddf03... 1.15 Support new file mode 100644 index 000000000..4695a0e54 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java~parent of cdddf03... 1.15 Support @@ -0,0 +1,207 @@ +package ninja.bytecode.iris.schematic; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPInputStream; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.util.BlockVector; + +import ninja.bytecode.iris.util.Catalyst12; +import ninja.bytecode.iris.util.MB; +import ninja.bytecode.shuriken.collections.GMap; +import ninja.bytecode.shuriken.io.CustomOutputStream; +import ninja.bytecode.shuriken.logging.L; + +public class Schematic +{ + private boolean centeredHeight; + private int w; + private int h; + private int d; + private int x; + private int y; + private int z; + private final GMap s; + + public Schematic(int w, int h, int d, int x, int y, int z) + { + this.w = w; + this.h = h; + this.d = d; + this.x = x; + this.y = y; + this.z = z; + s = new GMap<>(); + centeredHeight = false; + } + + public void setCenteredHeight() + { + this.centeredHeight = true; + } + + public int getW() + { + return w; + } + + public int getH() + { + return h; + } + + public int getD() + { + return d; + } + + public int getX() + { + return x; + } + + public int getY() + { + return y; + } + + public int getZ() + { + return z; + } + + public GMap getSchematic() + { + return s; + } + + @SuppressWarnings("deprecation") + public void read(InputStream in) throws IOException + { + GZIPInputStream gzi = new GZIPInputStream(in); + DataInputStream din = new DataInputStream(gzi); + w = din.readInt(); + h = din.readInt(); + d = din.readInt(); + x = din.readInt(); + y = din.readInt(); + z = din.readInt(); + int l = din.readInt(); + clear(); + + for(int i = 0; i < l; i++) + { + s.put(new BlockVector(din.readInt(), din.readInt(), din.readInt()), new MB(Material.getMaterial((int) din.readInt()), din.readInt())); + } + + din.close(); + } + + @SuppressWarnings("deprecation") + public void write(OutputStream out) throws IOException + { + CustomOutputStream cos = new CustomOutputStream(out, 9); + DataOutputStream dos = new DataOutputStream(cos); + dos.writeInt(w); + dos.writeInt(h); + dos.writeInt(d); + dos.writeInt(x); + dos.writeInt(y); + dos.writeInt(z); + dos.writeInt(s.size()); + + for(BlockVector i : s.keySet()) + { + dos.writeInt(i.getBlockX()); + dos.writeInt(i.getBlockY()); + dos.writeInt(i.getBlockZ()); + dos.writeInt(s.get(i).material.getId()); + dos.writeInt(s.get(i).data); + } + + dos.close(); + } + + public BlockVector getOffset() + { + return new BlockVector(x, y, z); + } + + public MB get(int x, int y, int z) + { + return s.get(new BlockVector(x, y, z)); + } + + public boolean has(int x, int y, int z) + { + return s.contains(new BlockVector(x, y, z)); + } + + public void put(int x, int y, int z, MB mb) + { + s.put(new BlockVector(x, y, z), mb); + } + + public Schematic copy() + { + Schematic s = new Schematic(w, h, d, x, y, z); + s.fill(this.s); + s.centeredHeight = centeredHeight; + return s; + } + + public void clear() + { + s.clear(); + } + + public void fill(GMap b) + { + clear(); + s.put(b); + } + + public void place(World source, int wx, int wy, int wz) + { + Location start = new Location(source, wx, wy, wz).clone().subtract(0, centeredHeight ? h / 2 : 0, 0); + + for(BlockVector i : getSchematic().k()) + { + MB b = getSchematic().get(i); + Location f = start.clone().add(i); + + if(b.material.equals(Material.SKULL)) + { + continue; + } + + try + { + Catalyst12.setBlock(source, f.getBlockX(), f.getBlockY(), f.getBlockZ(), b); + } + + catch(Throwable e) + { + e.printStackTrace(); + } + } + } + + public static Schematic load(File f) throws IOException + { + Schematic s = new Schematic(1, 1, 1, 1, 1, 1); + FileInputStream fin = new FileInputStream(f); + s.read(fin); + + L.i("Loaded Schematic: " + f.getPath() + " Size: " + s.getSchematic().size()); + return s; + } +} diff --git a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~HEAD similarity index 100% rename from src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java rename to src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~HEAD diff --git a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~parent of cdddf03... 1.15 Support b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~parent of cdddf03... 1.15 Support new file mode 100644 index 000000000..8bd24a1bf --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java~parent of cdddf03... 1.15 Support @@ -0,0 +1,64 @@ +package ninja.bytecode.iris.schematic; + +import ninja.bytecode.shuriken.collections.GList; + +public class SchematicGroup +{ + private GList schematics; + private GList flags; + private String name; + private int priority; + + public SchematicGroup(String name) + { + this.schematics = new GList<>(); + this.flags = new GList<>(); + priority = 0; + this.name = name; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public GList getSchematics() + { + return schematics; + } + + public void setSchematics(GList schematics) + { + this.schematics = schematics; + } + + public GList getFlags() + { + return flags; + } + + public void setFlags(GList flags) + { + this.flags = flags; + } + + public int getPriority() + { + return priority; + } + + public void setPriority(int priority) + { + this.priority = priority; + } + + public int size() + { + return getSchematics().size(); + } +}