From 7b3be4ae1ef98d689bcd183af32bb0f284968cff Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Apr 2021 19:57:56 +0200 Subject: [PATCH 1/4] Add CommandTestblock.genericTestblockCommand --- .../src/de/steamwar/bausystem/world/regions/Region_15.java | 6 ++++++ .../de/steamwar/bausystem/world/regions/PasteOptions.java | 5 +++++ .../de/steamwar/bausystem/commands/CommandTestblock.java | 5 ----- .../src/de/steamwar/bausystem/world/regions/Prototype.java | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 1c622f8..825e358 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.world.regions; +import com.google.common.collect.Sets; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -40,6 +41,8 @@ import org.bukkit.Bukkit; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; import java.util.Objects; class Region_15 { @@ -77,6 +80,9 @@ class Region_15 { e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), BlockTypes.AIR.getDefaultState().toBaseBlock()); } Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build()); + if (pasteOptions.isReset() && pasteOptions.getWaterLevel() != 0) { + e.replaceBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), new HashSet<>(Arrays.asList(BlockTypes.AIR.getDefaultState().toBaseBlock())), BlockTypes.WATER.getDefaultState().toBaseBlock()); + } return e; } catch (WorldEditException e) { throw new SecurityException(e.getMessage(), e); diff --git a/BauSystem_API/src/de/steamwar/bausystem/world/regions/PasteOptions.java b/BauSystem_API/src/de/steamwar/bausystem/world/regions/PasteOptions.java index 52e58ff..2dfbea0 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/world/regions/PasteOptions.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/regions/PasteOptions.java @@ -59,6 +59,11 @@ public class PasteOptions { */ private Point maxPoint = null; + /** + * Used in 1.15 + */ + private int waterLevel = 0; + public PasteOptions(boolean rotate) { this.rotate = rotate; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index 5ee1967..902c054 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -69,11 +69,6 @@ public class CommandTestblock extends SWCommand { schematicTestblockCommand(p, s, RegionExtensionType.NORMAL); } - @Register - public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) { - schematicTestblockCommand(p, s, regionExtensionType); - } - @Register public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 481e024..813fd1c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -151,7 +151,7 @@ public class Prototype { public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException { PasteOptions pasteOptions; if (reset) { - pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION)); + pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION), waterLevel); } else { pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color); } From 63cce8aaeb720eddc942d2a3b57e74eff6194cad Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 10 Apr 2021 20:10:50 +0200 Subject: [PATCH 2/4] Added debug out --- .../src/de/steamwar/bausystem/world/regions/Region_15.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 825e358..22b0048 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -81,7 +81,7 @@ class Region_15 { } Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build()); if (pasteOptions.isReset() && pasteOptions.getWaterLevel() != 0) { - e.replaceBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), new HashSet<>(Arrays.asList(BlockTypes.AIR.getDefaultState().toBaseBlock())), BlockTypes.WATER.getDefaultState().toBaseBlock()); + System.out.println(e.replaceBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), new HashSet<>(Arrays.asList(BlockTypes.AIR.getDefaultState().toBaseBlock())), BlockTypes.WATER.getDefaultState().toBaseBlock())); } return e; } catch (WorldEditException e) { From fbb0cd3f4eead11bd82fb28fad8187ed21d886a5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Apr 2021 20:17:20 +0200 Subject: [PATCH 3/4] Add CommandTestblock.genericTestblockCommand --- .../de/steamwar/bausystem/world/regions/Region_15.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 22b0048..6c6406f 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.world.regions; -import com.google.common.collect.Sets; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -64,7 +63,7 @@ class Region_15 { static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { changeColor(clipboard, pasteOptions.getColor()); - + ClipboardHolder ch = new ClipboardHolder(clipboard); BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 v = BlockVector3.at(x, y, z); @@ -78,11 +77,11 @@ class Region_15 { if (pasteOptions.isReset()) { e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), BlockTypes.AIR.getDefaultState().toBaseBlock()); + if (pasteOptions.getWaterLevel() != 0) { + System.out.println(e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), BlockTypes.WATER.getDefaultState().toBaseBlock())); + } } Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build()); - if (pasteOptions.isReset() && pasteOptions.getWaterLevel() != 0) { - System.out.println(e.replaceBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), new HashSet<>(Arrays.asList(BlockTypes.AIR.getDefaultState().toBaseBlock())), BlockTypes.WATER.getDefaultState().toBaseBlock())); - } return e; } catch (WorldEditException e) { throw new SecurityException(e.getMessage(), e); From 51e9617ae153601132fa65de028e99a4685e796d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 10 Apr 2021 20:39:25 +0200 Subject: [PATCH 4/4] Add CommandTestblock.genericTestblockCommand --- .../src/de/steamwar/bausystem/world/regions/Region_15.java | 4 +--- .../src/de/steamwar/bausystem/commands/CommandTestblock.java | 4 ++-- .../src/de/steamwar/bausystem/world/regions/Prototype.java | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 6c6406f..6bebb7f 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -40,8 +40,6 @@ import org.bukkit.Bukkit; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; import java.util.Objects; class Region_15 { @@ -78,7 +76,7 @@ class Region_15 { if (pasteOptions.isReset()) { e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), BlockTypes.AIR.getDefaultState().toBaseBlock()); if (pasteOptions.getWaterLevel() != 0) { - System.out.println(e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), BlockTypes.WATER.getDefaultState().toBaseBlock())); + e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint()).withY(pasteOptions.getWaterLevel())), BlockTypes.WATER.getDefaultState().toBaseBlock()); } } Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index 902c054..bd96756 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -64,12 +64,12 @@ public class CommandTestblock extends SWCommand { } - @Register + @Register({"schem"}) public void schematicTestblockCommand(Player p, String s) { schematicTestblockCommand(p, s, RegionExtensionType.NORMAL); } - @Register + @Register({"schem"}) public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) { if (!permissionCheck(p)) return; Region region = regionCheck(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 813fd1c..f3ab0d0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.world.regions; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Color; import de.steamwar.core.VersionedCallable; import de.steamwar.sql.NoClipboardException; @@ -186,7 +187,7 @@ public class Prototype { } public EditSession resetTestblock(Region region, Schematic schem, Color color, boolean reset) throws IOException, NoClipboardException { - return testblock.reset(region, schem, false, color, reset); + return testblock.reset(region, schem, false, color, reset && waterLevel == 0); } private static boolean inRange(double l, int min, int size) {