diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/CheckerboardMask.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/CheckerboardMask.java
deleted file mode 100644
index a4a726a1..00000000
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/CheckerboardMask.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2022 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.bausystem.features.worldedit.mask.checkerboard;
-
-import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.math.BlockVector3;
-
-public class CheckerboardMask implements Mask {
-
- private int size;
-
- public CheckerboardMask(int size) {
- this.size = size;
- }
-
- @Override
- public boolean test(BlockVector3 vector) {
- if (size == 0) return true;
- return (vector.getBlockX() / size + vector.getBlockZ() / size) % 2 == 0;
- }
-
- @Override
- public Mask copy() {
- return new CheckerboardMask(size);
- }
-}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/Checkerboard3DMask.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/Checkerboard3DMask.java
index 41d7573b..cc52b9cc 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/Checkerboard3DMask.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/Checkerboard3DMask.java
@@ -24,20 +24,30 @@ import com.sk89q.worldedit.math.BlockVector3;
public class Checkerboard3DMask implements Mask {
- private int size;
+ private int x;
+ private int y;
+ private int z;
- public Checkerboard3DMask(int size) {
- this.size = size;
+ public Checkerboard3DMask(int x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
}
@Override
public boolean test(BlockVector3 vector) {
- if (size == 0) return true;
- return (vector.getBlockX() / size + vector.getBlockY() / size + vector.getBlockZ() / size) % 2 == 0;
+ if (x == 0 && y == 0 && z == 0) return true;
+ if (x == 0 && y == 0) return (vector.getBlockZ() / z) % 2 == 0;
+ if (x == 0 && z == 0) return (vector.getBlockY() / y) % 2 == 0;
+ if (y == 0 && z == 0) return (vector.getBlockX() / x) % 2 == 0;
+ if (x == 0) return (vector.getBlockY() / y + vector.getBlockZ() / z) % 2 == 0;
+ if (y == 0) return (vector.getBlockX() / x + vector.getBlockZ() / z) % 2 == 0;
+ if (z == 0) return (vector.getBlockX() / x + vector.getBlockY() / y) % 2 == 0;
+ return (vector.getBlockX() / x + vector.getBlockY() / y + vector.getBlockZ() / z) % 2 == 0;
}
@Override
public Mask copy() {
- return new Checkerboard3DMask(size);
+ return new Checkerboard3DMask(x, y, z);
}
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java
index d4303d12..cb943408 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java
@@ -39,7 +39,7 @@ public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
@Override
protected Stream getSuggestions(String argumentInput, int index) {
- if (index == 0) {
+ if (index < 3) {
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
}
return Stream.empty();
@@ -47,13 +47,24 @@ public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
@Override
protected Mask parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
- if (arguments.length != 1) {
- return new Checkerboard3DMask(1);
+ if (arguments.length == 1) {
+ try {
+ int size = Integer.parseInt(arguments[0]);
+ return new Checkerboard3DMask(size, size, size);
+ } catch (NumberFormatException e) {
+ throw new InputParseException("Invalid number: " + arguments[0]);
+ }
}
- try {
- return new Checkerboard3DMask(Integer.parseInt(arguments[0]));
- } catch (NumberFormatException e) {
- throw new InputParseException("Invalid number: " + arguments[0]);
+ if (arguments.length == 3) {
+ try {
+ int sizeX = Integer.parseInt(arguments[0]);
+ int sizeY = Integer.parseInt(arguments[1]);
+ int sizeZ = Integer.parseInt(arguments[2]);
+ return new Checkerboard3DMask(sizeX, sizeY, sizeZ);
+ } catch (NumberFormatException e) {
+ throw new InputParseException("Invalid numbers: " + arguments[0] + ", " + arguments[1] + ", " + arguments[2]);
+ }
}
+ throw new InputParseException("Invalid number of arguments");
}
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/FAWECheckerboardMaskParser.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java
similarity index 90%
rename from BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/FAWECheckerboardMaskParser.java
rename to BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java
index 323a3ba0..1bfa6fb9 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard/FAWECheckerboardMaskParser.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package de.steamwar.bausystem.features.worldedit.mask.checkerboard;
+package de.steamwar.bausystem.features.worldedit.mask.checkerboard3d;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
@@ -25,7 +25,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
-import de.steamwar.linkage.PluginCheck;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@@ -47,11 +46,9 @@ public class FAWECheckerboardMaskParser extends FAWEMaskParser {
@Override
protected Mask parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
- if (arguments.length != 1) {
- return new CheckerboardMask(1);
- }
try {
- return new CheckerboardMask(Integer.parseInt(arguments[0]));
+ int size = Integer.parseInt(arguments[0]);
+ return new Checkerboard3DMask(size, 0, size);
} catch (NumberFormatException e) {
throw new InputParseException("Invalid number: " + arguments[0]);
}