mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 20:16:41 +00:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
This commit is contained in:
@ -286,7 +286,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
||||
}
|
||||
String[] stateProperties = EMPTY_STRING_ARRAY;
|
||||
if(stateString != null) {
|
||||
if (stateString != null) {
|
||||
stateProperties = stateString.split(",");
|
||||
}
|
||||
if (typeString.isEmpty()) {
|
||||
|
@ -55,8 +55,12 @@ public abstract class RichParser<E> extends InputParser<E> {
|
||||
|
||||
@Override
|
||||
public E parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||
if (!input.startsWith(this.prefix)) return null;
|
||||
if (input.length() < this.prefix.length()) return null;
|
||||
if (!input.startsWith(this.prefix)) {
|
||||
return null;
|
||||
}
|
||||
if (input.length() < this.prefix.length()) {
|
||||
return null;
|
||||
}
|
||||
String[] arguments = extractArguments(input.substring(prefix.length()), true);
|
||||
return parseFromInput(arguments, context);
|
||||
}
|
||||
|
@ -29,14 +29,18 @@ public class AdjacentMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length == 0) return null;
|
||||
if (arguments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
Mask subMask = worldEdit.getMaskFactory().parseFromInput(arguments[0], context);
|
||||
int min = arguments.length > 1 ? Integer.parseInt(arguments[1]) : -1;
|
||||
int max = arguments.length > 2 ? Integer.parseInt(arguments[2]) : -1;
|
||||
if (min == -1 && max == -1) {
|
||||
min = 1;
|
||||
max = 8;
|
||||
} else if (max == -1) max = min;
|
||||
} else if (max == -1) {
|
||||
max = min;
|
||||
}
|
||||
if (max >= 8 && min == 1) {
|
||||
return new AdjacentAnyMask(subMask);
|
||||
}
|
||||
|
@ -30,14 +30,15 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
@ -49,6 +50,8 @@ public class AngleMaskParser extends RichParser<Mask> {
|
||||
}
|
||||
}
|
||||
}
|
||||
double min;
|
||||
double max;
|
||||
if (degree) {
|
||||
double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1));
|
||||
double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1));
|
||||
|
@ -118,7 +118,7 @@
|
||||
//// () -> {
|
||||
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||
//// return dispatcher.getAliases().stream().filter(
|
||||
//// s -> s.startsWith(command.toLowerCase())
|
||||
//// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
||||
//// ).collect(Collectors.toList());
|
||||
//// }
|
||||
//// );
|
||||
@ -147,7 +147,7 @@
|
||||
// input = input.substring(input.indexOf(char0) + 1);
|
||||
// mask = parseFromInput(char0 + "[" + input + "]", context);
|
||||
// if (actor != null) {
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
|
||||
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket", char0 + "[" + input + "]"));
|
||||
// }
|
||||
// return mask;
|
||||
// }
|
||||
@ -164,7 +164,7 @@
|
||||
// {
|
||||
// try {
|
||||
// builder.addRegex(full);
|
||||
// } catch (InputParseException ignore) {}
|
||||
// } catch (InputParseException ignored) {}
|
||||
// }
|
||||
// if (mask == null) {
|
||||
// context.setPreferringWildcard(false);
|
||||
|
@ -30,14 +30,17 @@ public class ExtremaMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -30,14 +30,17 @@ public class ROCAngleMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) return null;
|
||||
if (arguments.length < 2 || arguments.length > 2 + flags.length) {
|
||||
return null;
|
||||
}
|
||||
String minArg = arguments[0];
|
||||
String maxArg = arguments[1];
|
||||
boolean degree = minArg.endsWith("d");
|
||||
if (degree ^ maxArg.endsWith("d")) {
|
||||
throw new InputParseException("Cannot combine degree with block-step");
|
||||
}
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
boolean overlay = false;
|
||||
if (arguments.length > 2) {
|
||||
for (int index = 2; index < 2 + flags.length; index++) {
|
||||
|
@ -26,7 +26,9 @@ public class RadiusMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length < 2) return null;
|
||||
if (arguments.length < 2) {
|
||||
return null;
|
||||
}
|
||||
int min = Integer.parseInt(arguments[0]);
|
||||
int max = Integer.parseInt(arguments[1]);
|
||||
return new RadiusMask(min, max);
|
||||
|
@ -27,7 +27,9 @@ public class SimplexMaskParser extends RichParser<Mask> {
|
||||
|
||||
@Override
|
||||
protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 3) return null;
|
||||
if (arguments.length != 3) {
|
||||
return null;
|
||||
}
|
||||
double scale = Double.parseDouble(arguments[0]);
|
||||
double min = Double.parseDouble(arguments[1]);
|
||||
double max = Double.parseDouble(arguments[2]);
|
||||
|
@ -5,7 +5,10 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@ -79,7 +81,7 @@ public class RandomPatternParser extends InputParser<Pattern> {
|
||||
String[] p = token.split("%", 2);
|
||||
|
||||
if (p.length < 2) {
|
||||
throw new InputParseException("Missing the type after the % symbol for '" + input + "'");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-random-type", TextComponent.of(input)));
|
||||
} else {
|
||||
chance = Double.parseDouble(p[0]);
|
||||
innerPattern = worldEdit.getPatternFactory().parseFromInput(p[1], context);
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.StateApplyingPattern;
|
||||
import com.sk89q.worldedit.function.pattern.TypeApplyingPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -82,19 +84,29 @@ public class TypeOrStateApplyingPatternParser extends InputParser<Pattern> {
|
||||
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState());
|
||||
} else {
|
||||
// states given
|
||||
if (!parts[1].endsWith("]")) throw new InputParseException("State is missing trailing ']'");
|
||||
if (!parts[1].endsWith("]")) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-rbracket"));
|
||||
}
|
||||
final String[] states = parts[1].substring(0, parts[1].length() - 1).split(",");
|
||||
Map<String, String> statesToSet = new HashMap<>();
|
||||
for (String state : states) {
|
||||
if (state.isEmpty()) throw new InputParseException("Empty part in state");
|
||||
if (state.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-state"));
|
||||
}
|
||||
String[] propVal = state.split("=", 2);
|
||||
if (propVal.length != 2) throw new InputParseException("Missing '=' separator");
|
||||
if (propVal.length != 2) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-equals-separator"));
|
||||
}
|
||||
final String prop = propVal[0];
|
||||
if (prop.isEmpty()) throw new InputParseException("Empty property in state");
|
||||
if (prop.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-property"));
|
||||
}
|
||||
final String value = propVal[1];
|
||||
if (value.isEmpty()) throw new InputParseException("Empty value in state");
|
||||
if (value.isEmpty()) {
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.empty-value"));
|
||||
}
|
||||
if (statesToSet.put(prop, value) != null) {
|
||||
throw new InputParseException("Duplicate properties in state");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.duplicate-property", TextComponent.of(prop)));
|
||||
}
|
||||
}
|
||||
if (type.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user