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; 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.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper; import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask; 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.Linked;
import de.steamwar.linkage.PluginCheck; import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.stream.Stream; import java.util.stream.Stream;
@Linked @Linked
@PluginCheck("FastAsyncWorldEdit") public class FAWEAboveMaskParser extends FAWEMaskParser {
public class FAWEAboveMaskParser extends RichParser<Mask> implements Plain {
public FAWEAboveMaskParser() { public FAWEAboveMaskParser() {
super(WorldEdit.getInstance(), "#above"); super("#above");
WorldEditUtils.addMaskParser(this);
} }
@Override @Override

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -32,6 +32,7 @@ public class Checkerboard3DMask implements Mask {
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(BlockVector3 vector) {
if (size == 0) return true;
return (vector.getBlockX() / size + vector.getBlockY() / size + vector.getBlockZ() / size) % 2 == 0; 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; 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.command.util.SuggestionHelper;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask; 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.Linked;
import de.steamwar.linkage.PluginCheck; import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.stream.Stream; import java.util.stream.Stream;
@Linked @Linked
@PluginCheck("FastAsyncWorldEdit") public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
public class FAWECheckerboard3DMaskParser extends RichParser<Mask> implements Plain {
public FAWECheckerboard3DMaskParser() { public FAWECheckerboard3DMaskParser() {
super(WorldEdit.getInstance(), "#checkerboard3d"); super("#checkerboard3d");
WorldEditUtils.addMaskParser(this);
} }
@Override @Override

Datei anzeigen

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

Datei anzeigen

@ -19,77 +19,26 @@
package de.steamwar.bausystem.features.worldedit.pattern.gradient; 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.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import de.steamwar.bausystem.features.worldedit.utils.FAWEPatternParser;
import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.PluginCheck;
import de.steamwar.linkage.api.Plain;
import org.bukkit.Axis; import org.bukkit.Axis;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.stream.Stream; import java.util.stream.Stream;
@Linked @Linked
@PluginCheck("FastAsyncWorldEdit") public class FAWEGradientPatternParser extends FAWEPatternParser {
public class FAWEGradientPatternParser extends RichParser<Pattern> implements Plain {
public FAWEGradientPatternParser() { public FAWEGradientPatternParser() {
super(WorldEdit.getInstance(), "#gradient"); super("#gradient");
WorldEditUtils.addPatternParser(this);
} }
/*
@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 @Override
protected Stream<String> getSuggestions(String input, int index) { protected Stream<String> getSuggestions(String input, int index) {
if (index == 0) { 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);
}
}