From 628294f148d1d2fbc61e04c97edd33bf067ab921 Mon Sep 17 00:00:00 2001 From: abhiram Date: Fri, 26 Mar 2021 23:37:30 +0530 Subject: [PATCH 1/3] Update on Structure --- .../simplexcore/structures/PasteType.java | 7 +++ .../simplexcore/structures/Structure.java | 44 ++++++++++++++++++- .../exception/SchematicNotLoaded.java | 8 ++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java create mode 100644 src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java b/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java new file mode 100644 index 0000000..1ec4955 --- /dev/null +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/PasteType.java @@ -0,0 +1,7 @@ +package io.github.simplexdev.simplexcore.structures; + + +public enum PasteType { + BLOCKBYBLOCKASYNC, + INSTANTASYNC +} diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java index 07c07df..c5528d7 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java @@ -1,5 +1,45 @@ package io.github.simplexdev.simplexcore.structures; -public class Structure { - // TODO: Write this +import io.github.simplexdev.simplexcore.module.SimplexModule; +import io.github.simplexdev.simplexcore.structures.block.NBTBlock; +import io.github.simplexdev.simplexcore.structures.exception.InvalidSchematic; +import io.github.simplexdev.simplexcore.structures.exception.SchematicNotLoaded; +import org.bukkit.Location; +import org.bukkit.block.data.BlockData; +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.util.HashMap; +import java.util.Vector; + +public final class Structure { + public Plugin plugin; + private File schematic; + private short width = 0; + private short height = 0; + private short length = 0; + private byte[] blockdatacontainer; + + private HashMap nbtBlocks = new HashMap<>(); + private HashMap blocks = new HashMap<>(); + + public Structure(SimplexModule plugin,File schematic) + { + this.plugin = plugin.getPlugin(); + this.schematic = schematic; + } + + public void load() throws InvalidSchematic + { + + } + + public void paste(Location loc,PasteType pasteType) throws SchematicNotLoaded + { + if (width == 0 || height == 0 || length == 0 || blocks.isEmpty()) { + throw new SchematicNotLoaded("Schematic not loaded please load schematic first..."); + } + + + } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java b/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java new file mode 100644 index 0000000..1612a28 --- /dev/null +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/exception/SchematicNotLoaded.java @@ -0,0 +1,8 @@ +package io.github.simplexdev.simplexcore.structures.exception; + +public class SchematicNotLoaded extends Exception { + + public SchematicNotLoaded(String msg) { + super(msg); + } +} From 3b151dfa8e538a7cbd3e076daed5cb76a7a5366d Mon Sep 17 00:00:00 2001 From: abhiram Date: Fri, 26 Mar 2021 23:40:38 +0530 Subject: [PATCH 2/3] Code style change to K&r! --- .../simplexdev/simplexcore/structures/Structure.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java index c5528d7..deb59c8 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java @@ -23,23 +23,19 @@ public final class Structure { private HashMap nbtBlocks = new HashMap<>(); private HashMap blocks = new HashMap<>(); - public Structure(SimplexModule plugin,File schematic) - { + public Structure(SimplexModule plugin,File schematic) { this.plugin = plugin.getPlugin(); this.schematic = schematic; } - public void load() throws InvalidSchematic - { + public void load() throws InvalidSchematic { } - public void paste(Location loc,PasteType pasteType) throws SchematicNotLoaded - { + public void paste(Location loc,PasteType pasteType) throws SchematicNotLoaded { if (width == 0 || height == 0 || length == 0 || blocks.isEmpty()) { throw new SchematicNotLoaded("Schematic not loaded please load schematic first..."); } - } } From 11a6cdd29ef50a32128b1da646a02bf3e4f983a1 Mon Sep 17 00:00:00 2001 From: abhiram Date: Fri, 26 Mar 2021 23:42:18 +0530 Subject: [PATCH 3/3] field access change! --- .../io/github/simplexdev/simplexcore/structures/Structure.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java index deb59c8..a238ab9 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/Structure.java @@ -13,7 +13,7 @@ import java.util.HashMap; import java.util.Vector; public final class Structure { - public Plugin plugin; + private Plugin plugin; private File schematic; private short width = 0; private short height = 0;