SteamWar/BauSystem2.0
Archiviert
12
0

FAWEMaskParser_GENERIC.java
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-12-18 10:14:08 +01:00
Ursprung 0a11fca681
Commit a9d06fbe84
12 geänderte Dateien mit 168 neuen und 92 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,41 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import javax.lang.model.element.TypeElement;
public class FAWEMaskParser_GENERIC implements LinkageType {
@Override
public String method() {
return "link";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
methodBuilder.addLine("if (org.bukkit.Bukkit.getPluginManager().getPlugin(\"FastAsyncWorldEdit\") != null) {");
methodBuilder.addLine(" " + s + ";");
methodBuilder.addLine("}");
}
}

Datei anzeigen

@ -0,0 +1,41 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import javax.lang.model.element.TypeElement;
public class FAWEPatternParser_GENERIC implements LinkageType {
@Override
public String method() {
return "link";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
methodBuilder.addLine("if (org.bukkit.Bukkit.getPluginManager().getPlugin(\"FastAsyncWorldEdit\") != null) {");
methodBuilder.addLine(" " + s + ";");
methodBuilder.addLine("}");
}
}

Datei anzeigen

@ -19,27 +19,23 @@
package de.steamwar.bausystem.features.worldedit.mask.above;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEAboveMaskParser extends RichParser<Mask> implements Plain {
public class FAWEAboveMaskParser extends FAWEMaskParser {
public FAWEAboveMaskParser() {
super(WorldEdit.getInstance(), "#above");
WorldEditUtils.addMaskParser(this);
super("#above");
}
@Override

Datei anzeigen

@ -19,27 +19,23 @@
package de.steamwar.bausystem.features.worldedit.mask.below;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEBelowMaskParser extends RichParser<Mask> implements Plain {
public class FAWEBelowMaskParser extends FAWEMaskParser {
public FAWEBelowMaskParser() {
super(WorldEdit.getInstance(), "#below");
WorldEditUtils.addMaskParser(this);
super("#below");
}
@Override

Datei anzeigen

@ -32,6 +32,7 @@ public class CheckerboardMask implements Mask {
@Override
public boolean test(BlockVector3 vector) {
if (size == 0) return true;
return (vector.getBlockX() / size + vector.getBlockZ() / size) % 2 == 0;
}

Datei anzeigen

@ -19,27 +19,22 @@
package de.steamwar.bausystem.features.worldedit.mask.checkerboard;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWECheckerboardMaskParser extends RichParser<Mask> implements Plain {
public class FAWECheckerboardMaskParser extends FAWEMaskParser {
public FAWECheckerboardMaskParser() {
super(WorldEdit.getInstance(), "#checkerboard");
WorldEditUtils.addMaskParser(this);
super("#checkerboard");
}
@Override

Datei anzeigen

@ -32,6 +32,7 @@ public class Checkerboard3DMask implements Mask {
@Override
public boolean test(BlockVector3 vector) {
if (size == 0) return true;
return (vector.getBlockX() / size + vector.getBlockY() / size + vector.getBlockZ() / size) % 2 == 0;
}

Datei anzeigen

@ -19,27 +19,22 @@
package de.steamwar.bausystem.features.worldedit.mask.checkerboard3d;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWECheckerboard3DMaskParser extends RichParser<Mask> implements Plain {
public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
public FAWECheckerboard3DMaskParser() {
super(WorldEdit.getInstance(), "#checkerboard3d");
WorldEditUtils.addMaskParser(this);
super("#checkerboard3d");
}
@Override

Datei anzeigen

@ -19,27 +19,22 @@
package de.steamwar.bausystem.features.worldedit.mask.grid;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEGridMaskParser extends RichParser<Mask> implements Plain {
public class FAWEGridMaskParser extends FAWEMaskParser {
public FAWEGridMaskParser() {
super(WorldEdit.getInstance(), "#grid");
WorldEditUtils.addMaskParser(this);
super("#grid");
}
@Override

Datei anzeigen

@ -19,77 +19,26 @@
package de.steamwar.bausystem.features.worldedit.pattern.gradient;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.Region;
import de.steamwar.bausystem.features.worldedit.utils.FAWEPatternParser;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import org.bukkit.Axis;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEGradientPatternParser extends RichParser<Pattern> implements Plain {
public class FAWEGradientPatternParser extends FAWEPatternParser {
public FAWEGradientPatternParser() {
super(WorldEdit.getInstance(), "#gradient");
WorldEditUtils.addPatternParser(this);
super("#gradient");
}
/*
@Override
public Pattern parseFromInput(String s, ParserContext parserContext) throws InputParseException {
System.out.println("parse " + s);
if (!s.startsWith("#gradient")) return null;
Extent extent = parserContext.requireExtent();
Axis axis = null;
if (s.startsWith("#gradientx")) {
axis = Axis.X;
} else if (s.startsWith("#gradienty")) {
axis = Axis.Y;
} else if (s.startsWith("#gradientz")) {
axis = Axis.Z;
}
if (axis == null) {
throw new InputParseException("No axis given for gradient pattern");
}
s = s.substring(10);
if (!s.startsWith("[") && s.endsWith("]")) {
throw new InputParseException("No pattern given for gradient pattern");
}
s = s.substring(1, s.length() - 1);
String[] patterns = s.split("]\\[");
if (patterns.length < 2) {
throw new InputParseException("Not enough patterns given for gradient pattern");
}
if (patterns.length > 2) {
throw new InputParseException("Too many patterns given for gradient pattern");
}
Pattern from = WorldEditUtils.getPatternFactory().parseFromInput(patterns[0], parserContext);
Pattern to = WorldEditUtils.getPatternFactory().parseFromInput(patterns[1], parserContext);
int size = 0;
switch (axis) {
case X:
size = extent.getMaximumPoint().getBlockX() - extent.getMinimumPoint().getBlockX();
break;
case Y:
size = extent.getMaximumPoint().getBlockY() - extent.getMinimumPoint().getBlockY();
break;
case Z:
size = extent.getMaximumPoint().getBlockZ() - extent.getMinimumPoint().getBlockZ();
break;
}
return new GradientPattern(axis, from, to, extent.getMinimumPoint(), size);
}
*/
@Override
protected Stream<String> getSuggestions(String input, int index) {
if (index == 0) {

Datei anzeigen

@ -0,0 +1,33 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.worldedit.utils;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.function.mask.Mask;
import de.steamwar.bausystem.utils.WorldEditUtils;
public abstract class FAWEMaskParser extends RichParser<Mask> {
protected FAWEMaskParser(String... aliases) {
super(WorldEdit.getInstance(), aliases);
WorldEditUtils.addMaskParser(this);
}
}

Datei anzeigen

@ -0,0 +1,33 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.worldedit.utils;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.function.pattern.Pattern;
import de.steamwar.bausystem.utils.WorldEditUtils;
public abstract class FAWEPatternParser extends RichParser<Pattern> {
protected FAWEPatternParser(String... aliases) {
super(WorldEdit.getInstance(), aliases);
WorldEditUtils.addPatternParser(this);
}
}