Add and apply .editorconfig from P2 (#1195)

* Consistenty use javax annotations.
 - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax
 - Cleaning up of import order in #1195
 - Must be merged before #1195

* Add and apply .editorconfig from P2
 - Does not rearrange entries

* Address some comments

* add back some javadoc comments

* Address final comments

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -51,7 +51,7 @@ public class BlockFactory extends AbstractFactory<BaseBlock> {
/**
* Return a set of blocks from a comma-delimited list of blocks.
*
* @param input the input
* @param input the input
* @param context the context
* @return a set of blocks
* @throws InputParseException thrown in error with the input
@ -61,7 +61,7 @@ public class BlockFactory extends AbstractFactory<BaseBlock> {
//FAWE start
// String[] splits = input.split(",");
for (String token : StringUtil.split(input, ',', '[', ']')) {
//FAWE end
//FAWE end
blocks.add(parseFromInput(token, context));
}
return blocks;

View File

@ -20,34 +20,34 @@
package com.sk89q.worldedit.extension.factory;
import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.worldedit.WorldEdit;
import com.fastasyncworldedit.core.extension.factory.parser.mask.AdjacentMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.AngleMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ExtremaMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.FalseMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.LiquidMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ROCAngleMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.RichOffsetMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.SimplexMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.SurfaceMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.TrueMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.WallMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.XAxisMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.YAxisMaskParser;
import com.fastasyncworldedit.core.extension.factory.parser.mask.ZAxisMaskParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
@ -117,7 +117,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
final String[] split = input.split(" ");
if (split.length > 1) {
String prev = input.substring(0, input.lastIndexOf(" ")) + " ";
return super.getSuggestions(split[split.length -1]).stream().map(s -> prev + s).collect(Collectors.toList());
return super.getSuggestions(split[split.length - 1]).stream().map(s -> prev + s).collect(Collectors.toList());
}
return super.getSuggestions(input);
}

View File

@ -19,22 +19,22 @@
package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.WorldEdit;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.BiomePatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.BufferedPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.ExistingPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear2DPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.Linear3DPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.PerlinPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RandomPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.RidgedMultiFractalPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.SimplexPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.VoronoiPatternParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.TypeOrStateApplyingPatternParser;
import com.fastasyncworldedit.core.extension.factory.parser.pattern.VoronoiPatternParser;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.registry.AbstractFactory;

View File

@ -20,10 +20,12 @@
package com.sk89q.worldedit.extension.factory.parser;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.fastasyncworldedit.core.jnbt.JSON2NBT;
import com.fastasyncworldedit.core.jnbt.NBTException;
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.world.block.BlanketBaseBlock;
import com.google.common.collect.Maps;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.IncompleteRegionException;
@ -43,7 +45,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
@ -57,7 +58,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.fastasyncworldedit.core.world.block.BlanketBaseBlock;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
@ -171,7 +171,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
}
private static Map<Property<?>, Object> parseProperties(BlockType type, String[] stateProperties, ParserContext context) throws NoMatchException {
private static Map<Property<?>, Object> parseProperties(
BlockType type,
String[] stateProperties,
ParserContext context
) throws NoMatchException {
Map<Property<?>, Object> blockStates = new HashMap<>();
if (stateProperties.length > 0) { // Block data not yet detected
@ -181,8 +185,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
String[] parts = parseableData.split("=");
if (parts.length != 2) {
throw new InputParseException(
Caption.of("worldedit.error.parser.bad-state-format",
TextComponent.of(parseableData))
Caption.of(
"worldedit.error.parser.bad-state-format",
TextComponent.of(parseableData)
)
);
}
@ -302,7 +308,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} else {
typeString = blockAndExtraData[0].substring(0, stateStart);
if (stateStart + 1 >= blockAndExtraData[0].length()) {
throw new InputParseException(Caption.of("worldedit.error.parser.hanging-lbracket", TextComponent.of(stateStart)));
throw new InputParseException(Caption.of(
"worldedit.error.parser.hanging-lbracket",
TextComponent.of(stateStart)
));
}
int stateEnd = blockAndExtraData[0].lastIndexOf(']');
if (stateEnd < 0) {
@ -477,7 +486,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (context.isRestricted()) {
Actor actor = context.requireActor();
if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(String.valueOf(holder))));
throw new DisallowedUsageException(Caption.of(
"worldedit.error.disallowed-block",
TextComponent.of(String.valueOf(holder))
));
}
CompoundTag nbt = holder.getNbtData();
if (nbt != null) {

View File

@ -71,7 +71,10 @@ public class DefaultItemParser extends InputParser<BaseItem> {
} else if (split.length == 1) {
itemType = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]));
} else {
itemType = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
itemType = LegacyMapper.getInstance().getItemFromLegacy(
Integer.parseInt(split[0]),
Integer.parseInt(split[1])
);
}
if (itemType != null) {
item = new BaseItem(itemType);
@ -90,7 +93,10 @@ public class DefaultItemParser extends InputParser<BaseItem> {
} else {
typeString = input.substring(0, nbtStart);
if (nbtStart + 1 >= input.length()) {
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.hanging-lbracket", TextComponent.of(nbtStart)));
throw new InputParseException(TranslatableComponent.of(
"worldedit.error.parser.hanging-lbracket",
TextComponent.of(nbtStart)
));
}
int stateEnd = input.lastIndexOf('}');
if (stateEnd < 0) {
@ -132,9 +138,9 @@ public class DefaultItemParser extends InputParser<BaseItem> {
}
} catch (IOException e) {
throw new NoMatchException(TranslatableComponent.of(
"worldedit.error.invalid-nbt",
TextComponent.of(input),
TextComponent.of(e.getMessage())
"worldedit.error.invalid-nbt",
TextComponent.of(input),
TextComponent.of(e.getMessage())
));
}
}

View File

@ -47,4 +47,5 @@ public class AirMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return Masks.negate(new ExistingBlockMask(context.requireExtent()));
}
}

View File

@ -81,4 +81,5 @@ public class BiomeMaskParser extends InputParser<Mask> {
return new BiomeMask(context.requireExtent(), biomes);
}
}

View File

@ -53,9 +53,14 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
// This means it's a tag mask.
BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase(Locale.ROOT));
if (category == null) {
throw new InputParseException(Caption.of("fawe.error.unrecognised-tag", TextComponent.of(input.substring(2)), TextComponent.of("\\")));
throw new InputParseException(Caption.of(
"fawe.error.unrecognised-tag",
TextComponent.of(input.substring(2)),
TextComponent.of("\\")
));
} else {
return new BlockCategoryMask(context.requireExtent(), category);
}
}
}

View File

@ -54,11 +54,17 @@ public class BlockStateMaskParser extends InputParser<Mask> {
boolean strict = input.charAt(1) == '=';
String states = input.substring(2 + (strict ? 1 : 0), input.length() - 1);
try {
return new BlockStateMask(context.requireExtent(),
return new BlockStateMask(
context.requireExtent(),
Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states),
strict);
strict
);
} catch (Exception e) {
throw new InputParseException(Caption.of("worldedit.error.parser.bad-state-format", TextComponent.of(String.valueOf(e))));
throw new InputParseException(Caption.of(
"worldedit.error.parser.bad-state-format",
TextComponent.of(String.valueOf(e))
));
}
}
}

View File

@ -46,4 +46,5 @@ public class ExistingMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new ExistingBlockMask(context.requireExtent());
}
}

View File

@ -68,7 +68,11 @@ public class ExpressionMaskParser extends InputParser<Mask> {
}
return new ExpressionMask(exp);
} catch (ExpressionException e) {
throw new InputParseException(Caption.of("worldedit.error.parser.invalid-expression", TextComponent.of(e.getMessage())));
throw new InputParseException(Caption.of(
"worldedit.error.parser.invalid-expression",
TextComponent.of(e.getMessage())
));
}
}
}

View File

@ -46,4 +46,5 @@ public class LazyRegionMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new RegionMask(new RequestSelection());
}
}

View File

@ -58,4 +58,5 @@ public class NegateMaskParser extends InputParser<Mask> {
throw new InputParseException(Caption.of("worldedit.error.parser.negate-nothing"));
}
}
}

View File

@ -54,4 +54,5 @@ public class NoiseMaskParser extends InputParser<Mask> {
int i = Integer.parseInt(input.substring(1));
return new NoiseFilter(new RandomNoise(), ((double) i) / 100);
}
}

View File

@ -66,4 +66,5 @@ public class OffsetMaskParser extends InputParser<Mask> {
OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0));
return new MaskIntersection(offsetMask, Masks.negate(submask));
}
}

View File

@ -52,4 +52,5 @@ public class RegionMaskParser extends SimpleInputParser<Mask> {
throw new InputParseException(Caption.of("worldedit.error.incomplete-region"));
}
}
}

View File

@ -46,4 +46,5 @@ public class SolidMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new SolidBlockMask(context.requireExtent());
}
}

View File

@ -71,7 +71,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
if (anyState) {
blocks.stream().flatMap(blockType -> blockType.getAllStates().stream()).forEach(state ->
randomPattern.add(state, 1.0));
randomPattern.add(state, 1.0));
} else {
for (BlockType blockType : blocks) {
randomPattern.add(blockType.getDefaultState(), 1.0);
@ -80,4 +80,5 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
return randomPattern;
}
}

View File

@ -31,7 +31,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.Locale;
import java.util.stream.Stream;
@ -79,7 +78,7 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
if (offsetParts.length == 2) {
String coords = offsetParts[1];
if (coords.length() < 7 // min length of `[x,y,z]`
|| coords.charAt(0) != '[' || coords.charAt(coords.length() - 1) != ']') {
|| coords.charAt(0) != '[' || coords.charAt(coords.length() - 1) != ']') {
throw new InputParseException(Caption.of("worldedit.error.parser.clipboard.missing-offset"));
}
String[] offsetSplit = coords.substring(1, coords.length() - 1).split(",");

View File

@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
import java.util.stream.Stream;
public class RandomStatePatternParser extends InputParser<Pattern> {
public RandomStatePatternParser(WorldEdit worldEdit) {
super(worldEdit);
}
@ -66,4 +67,5 @@ public class RandomStatePatternParser extends InputParser<Pattern> {
return null; // only should happen if parseLogic changes
}
}
}

View File

@ -80,8 +80,10 @@ public class TypeOrStateApplyingPatternParser extends InputParser<Pattern> {
String type = parts[0];
if (parts.length == 1) {
return new TypeApplyingPattern(extent,
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState());
return new TypeApplyingPattern(
extent,
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState()
);
} else {
// states given
if (!parts[1].endsWith("]")) {
@ -106,15 +108,20 @@ public class TypeOrStateApplyingPatternParser extends InputParser<Pattern> {
throw new InputParseException(Caption.of("worldedit.error.parser.empty-value"));
}
if (statesToSet.put(prop, value) != null) {
throw new InputParseException(Caption.of("worldedit.error.parser.duplicate-property", TextComponent.of(prop)));
throw new InputParseException(Caption.of(
"worldedit.error.parser.duplicate-property",
TextComponent.of(prop)
));
}
}
if (type.isEmpty()) {
return new StateApplyingPattern(extent, statesToSet);
} else {
Extent buffer = new ExtentBuffer(extent);
Pattern typeApplier = new TypeApplyingPattern(buffer,
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState());
Pattern typeApplier = new TypeApplyingPattern(
buffer,
worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState()
);
Pattern stateApplier = new StateApplyingPattern(buffer, statesToSet);
return new ExtentBufferedCompositePattern(buffer, typeApplier, stateApplier);
}