Feature/propagate diff and object cleanup (#1190)

* Feature/main/propagate diff annotations (#1187)

* 25% done

* More work

* More work

* 50%

* More work

* 75%

* 100% & cleanup

* Update adapters

* Squish squash, applesauce

commit 275ba9bd84
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:10:20 2021 +0200

    Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 9fd8984804
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:09:29 2021 +0200

    Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 861fb45e5c
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 19:07:02 2021 +0100

    Fix #1075

commit 420c45a29a
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 18:48:21 2021 +0100

    Entity removal should be on the main thread as we're just passing through rather than doing chunk operations
     - Fixes #1164
     - Not working: butcher/remove history

commit 4d4db7dcd0
Author: SirYwell <hannesgreule@outlook.de>
Date:   Fri Jul 16 17:52:44 2021 +0200

    Make sure leaves category is loaded for heightmaps (fixes #1176)

commit c98f6e4f37
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:44:52 2021 +0100

    Do not allow generation commands to generate outside selection

commit 2485f5eccc
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:43:15 2021 +0100

    EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents
    Fixes #1152

commit d9418ec8ae
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 09:52:44 2021 +0100

    Undo part of 41073bb1a0
    Fixes #1178

* Update Upstream

fb1fb84 Fixed typo and grammar

* We don't support custom heights yet

* Casing inconsistency

* Address a few comments

* Address comments

* Don't refactor to AP classpath

* Document annotation style

* Refactoring & shade cleanup

* Address a few comments

* More work

* Resolve comments not being resolved yet

* Feature/main/propagate diff annotations (#1187) (#1194)

* Remove beta package, fix history packages, move classes out of object package

* Resolve comments not being resolved yet

* Remove beta package, fix history packages, move classes out of object package

Co-authored-by: NotMyFault <mc.cache@web.de>

* brushes should be under brush

* More refactoring
 - Filters/processors should be in the same place and are related to extents
 - Transforms are in `extent.transform` in upstream

* Move history classes under history

* Update adapters

Co-authored-by: dordsor21 <dordsor21@gmail.com>
This commit is contained in:
NotMyFault
2021-07-23 17:48:51 +02:00
committed by GitHub
parent ad102ab7a9
commit 50ab8ad5c7
799 changed files with 4916 additions and 10589 deletions

View File

@ -1,16 +0,0 @@
package com.sk89q.worldedit.internal.annotation;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import org.enginehub.piston.inject.InjectAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD})
@InjectAnnotation
public @interface AllowedRegion {
FaweMaskManager.MaskType value() default FaweMaskManager.MaskType.OWNER;
}

View File

@ -1,36 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.internal.annotation;
import org.enginehub.piston.inject.InjectAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotates a {@code List<BlockState>} parameter to inject a list of BlockStates.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@InjectAnnotation
public @interface PatternList {
}

View File

@ -1,14 +0,0 @@
package com.sk89q.worldedit.internal.annotation;
import org.enginehub.piston.inject.InjectAnnotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD})
@InjectAnnotation
public @interface Time {
}

View File

@ -52,7 +52,7 @@ import java.util.stream.Stream;
public final class ChunkDeleter {
public static final String DELCHUNKS_FILE_NAME = "delete_chunks.json";
private static final Logger LOGGER = LogManagerCompat.getLogger();;
private static final Logger LOGGER = LogManagerCompat.getLogger();
private static final Comparator<BlockVector2> chunkSorter = Comparator.comparing(
pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32
@ -64,7 +64,7 @@ public final class ChunkDeleter {
.create();
public static ChunkDeletionInfo readInfo(Path chunkFile) throws IOException, JsonSyntaxException {
String json = new String(Files.readAllBytes(chunkFile), StandardCharsets.UTF_8);
String json = Files.readString(chunkFile);
return chunkDeleterGson.fromJson(json, ChunkDeletionInfo.class);
}

View File

@ -30,7 +30,7 @@ import java.nio.file.Path;
*/
class RegionAccess implements AutoCloseable {
private RandomAccessFile raf;
private final RandomAccessFile raf;
private int[] offsets;
private int[] timestamps;

View File

@ -25,6 +25,7 @@ import javax.annotation.Nullable;
public final class BlockStateIdAccess {
//FAWE start - Register via ordinal ID
private static final int INVALID_ID = -1;
/**
@ -50,5 +51,6 @@ public final class BlockStateIdAccess {
private BlockStateIdAccess() {
}
//FAWE end
}

View File

@ -1,58 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.internal.command;
import com.fastasyncworldedit.core.configuration.Settings;
import com.sk89q.worldedit.command.util.annotation.Confirm;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.exception.StopExecutionException;
import org.enginehub.piston.gen.CommandCallListener;
import org.enginehub.piston.inject.Key;
import java.lang.reflect.Method;
import java.util.Optional;
/**
* Logs called commands to a logger.
*/
public class ConfirmHandler implements CommandCallListener {
@Override
public void beforeCall(Method method, CommandParameters parameters) {
Confirm confirmAnnotation = method.getAnnotation(Confirm.class);
if (confirmAnnotation == null) {
return;
}
Optional<Actor> actorOpt = parameters.injectedValue(Key.of(Actor.class));
if (!actorOpt.isPresent()) {
return;
}
Actor actor = actorOpt.get();
// don't check confirmation if actor doesn't need to confirm
if (!Settings.IMP.getLimit(actor).CONFIRM_LARGE) {
return;
}
if (!confirmAnnotation.value().passes(actor, parameters, 1)) {
throw new StopExecutionException(TextComponent.empty());
}
}
}

View File

@ -1,17 +0,0 @@
package com.sk89q.worldedit.internal.command;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.gen.CommandCallListener;
import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.util.ValueProvider;
import java.lang.reflect.Method;
public class MethodInjector implements CommandCallListener {
@Override
public void beforeCall(Method commandMethod, CommandParameters parameters) {
InjectedValueStore store = parameters.injectedValue(Key.of(InjectedValueStore.class)).get();
store.injectValue(Key.of(Method.class), ValueProvider.constant(commandMethod));
}
}

View File

@ -97,6 +97,7 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
throw newCommandException(Caption.of("worldedit.error.unknown-block", TextComponent.of(e.getID())), e);
}
@Deprecated
@ExceptionMatch
public void convert(InvalidItemException e) throws CommandException {
throw newCommandException(e.getMessage(), e);

View File

@ -42,11 +42,11 @@ public class SelectionCylinderEvent implements CUIEvent {
@Override
public String[] getParameters() {
return new String[] {
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ()),
String.valueOf(radius.getX()),
String.valueOf(radius.getZ())
};
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ()),
String.valueOf(radius.getX()),
String.valueOf(radius.getZ())
};
}
}

View File

@ -39,11 +39,11 @@ public class SelectionEllipsoidPointEvent implements CUIEvent {
@Override
public String[] getParameters() {
return new String[] {
String.valueOf(id),
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ())
};
String.valueOf(id),
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ())
};
}
}

View File

@ -37,9 +37,9 @@ public class SelectionMinMaxEvent implements CUIEvent {
@Override
public String[] getParameters() {
return new String[] {
String.valueOf(min),
String.valueOf(max),
};
String.valueOf(min),
String.valueOf(max),
};
}
}

View File

@ -67,11 +67,11 @@ public class SelectionPoint2DEvent implements CUIEvent {
@Override
public String[] getParameters() {
return new String[] {
String.valueOf(id),
String.valueOf(blockX),
String.valueOf(blockZ),
String.valueOf(area)
};
String.valueOf(id),
String.valueOf(blockX),
String.valueOf(blockZ),
String.valueOf(area)
};
}
}

View File

@ -48,12 +48,12 @@ public class SelectionPointEvent implements CUIEvent {
@Override
public String[] getParameters() {
return new String[] {
String.valueOf(id),
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ()),
String.valueOf(area)
};
String.valueOf(id),
String.valueOf(pos.getBlockX()),
String.valueOf(pos.getBlockY()),
String.valueOf(pos.getBlockZ()),
String.valueOf(area)
};
}
}

View File

@ -40,9 +40,18 @@ import javax.annotation.Nullable;
*/
public class ServerCUIHandler {
private static final int MAX_DISTANCE = 32;
private ServerCUIHandler() {
}
public static int getMaxServerCuiSize() {
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion();
// 1.16 increased maxSize to 48.
return dataVersion >= 2566 ? 48 : 32;
}
/**
* Creates a structure block that shows the region.
*
@ -58,8 +67,6 @@ public class ServerCUIHandler {
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
RegionSelector regionSelector = session.getRegionSelector(player.getWorld());
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
int posX;
int posY;
int posZ;
@ -109,16 +116,11 @@ public class ServerCUIHandler {
return null;
}
if (dataVersion >= 2526) {
if (width > 48 || length > 48 || height > 48) {
// 20w16a+ allows structure blocks up to 48 per axis
return null;
} else {
if (width > 32 || length > 32 || height > 32) {
// Structure blocks on versions <= 20w16a have a limit of 32x32x32
return null;
}
}
int maxSize = getMaxServerCuiSize();
if (width > maxSize || length > maxSize || height > maxSize) {
// Structure blocks have a limit of maxSize^3
return null;
}
// Borrowed this math from FAWE
@ -128,26 +130,24 @@ public class ServerCUIHandler {
double xz = Math.cos(Math.toRadians(rotY));
int x = (int) (location.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12);
int z = (int) (location.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12);
int y = Math.max(0, Math.min(Math.min(255, posY + 32), posY + 3));
int y = Math.max(
player.getWorld().getMinY(),
Math.min(Math.min(player.getWorld().getMaxY(), posY + MAX_DISTANCE), posY + 3)
);
//FAWE start - CBT > Map<String, Tag>
CompoundBinaryTag.Builder structureTag = CompoundBinaryTag.builder();
posX -= x;
posY -= y;
posZ -= z;
if (dataVersion >= 2526) {
if (Math.abs(posX) > 48 || Math.abs(posY) > 48 || Math.abs(posZ) > 48) {
// 20w16a+ allows structure blocks up to 48 per axis
return null;
} else {
if (Math.abs(posX) > 32 || Math.abs(posY) > 32 || Math.abs(posZ) > 32) {
// Structure blocks on versions <= 20w16a have a limit of 32x32x32
return null;
}
}
if (Math.abs(posX) > MAX_DISTANCE || Math.abs(posY) > MAX_DISTANCE || Math.abs(posZ) > MAX_DISTANCE) {
// Structure blocks have a limit
return null;
}
//FAWE start - see comment of CBT
structureTag.putString("name", "worldedit:" + player.getName());
structureTag.putString("author", player.getName());
structureTag.putString("metadata", "");
@ -168,5 +168,6 @@ public class ServerCUIHandler {
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.getId());
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
//FAWE end
}
}

View File

@ -62,21 +62,27 @@ import java.util.Set;
* pass values for all slots specified while compiling.
* To query slots after evaluation, you can use the {@linkplain #getSlots() slot table}.
*/
//FAWE start - implements Cloneable
public class Expression implements Cloneable {
//FAWE end
private final SlotTable slots = new SlotTable();
private final List<String> providedSlots;
private final ExpressionParser.AllStatementsContext root;
private final Functions functions = Functions.create();
private final CompiledExpression compiledExpression;
//FAWE start
private final String initialExpression;
//FAWE end
public static Expression compile(String expression, String... variableNames) throws ExpressionException {
return new Expression(expression, variableNames);
}
private Expression(String expression, String... variableNames) throws ExpressionException {
//FAWE start
this.initialExpression = expression;
//FAWE end
slots.putSlot("e", new LocalSlot.Constant(Math.E));
slots.putSlot("pi", new LocalSlot.Constant(Math.PI));
@ -185,8 +191,10 @@ public class Expression implements Cloneable {
functions.setEnvironment(environment);
}
//FAWE start
public Expression clone() {
return new Expression(initialExpression, new HashSet<>(providedSlots));
}
//FAWE end
}

View File

@ -39,7 +39,7 @@ public abstract class SimpleInputParser<E> extends InputParser<E> {
}
/**
* The strings this parser matches
* The strings this parser matches.
*
* @return the matching aliases
*/
@ -57,7 +57,7 @@ public abstract class SimpleInputParser<E> extends InputParser<E> {
public abstract E parseFromSimpleInput(String input, ParserContext context) throws InputParseException;
/**
* Gets the primary name of this matcher
* Gets the primary name of this matcher.
*
* @return the primary match
*/

View File

@ -33,7 +33,7 @@ public class BiomeMath {
}
/**
* Compute the index into the MC biome array.
* Compute the index into the MC biome array, for non-extended-height worlds.
*
* @param x the block x coordinate
* @param y the block y coordinate
@ -45,7 +45,26 @@ public class BiomeMath {
int m = MathHelper.clamp(y >> 2, 0, VERTICAL_BIT_MASK);
int n = (z >> 2) & HORIZONTAL_BIT_MASK;
return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l;
| n << HORIZONTAL_SECTION_COUNT
| l;
}
/**
* Compute the index into the MC biome array, for extended-height worlds.
*
* @param x the block x coordinate
* @param y the block y coordinate
* @param z the block z coordinate
* @param minY minimum y of the world
* @param maxY maximum y of the world
* @return the index into the standard MC biome array
*/
public static int computeBiomeIndex(int x, int y, int z, int minY, int maxY) {
int l = (x >> 2) & HORIZONTAL_BIT_MASK;
int m = MathHelper.clamp((y >> 2) - minY, 0, maxY);
int n = (z >> 2) & HORIZONTAL_BIT_MASK;
return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l;
}
}

View File

@ -69,6 +69,7 @@ public interface WorldNativeAccess<NC, NBS, NP> {
if (successful || old == newState) {
if (block instanceof BaseBlock) {
BaseBlock baseBlock = (BaseBlock) block;
//FAWE start - use CompoundBinaryTag over CompoundTag
CompoundBinaryTag tag = baseBlock.getNbt();
if (tag != null) {
tag = tag.put(ImmutableMap.of(
@ -81,6 +82,7 @@ public interface WorldNativeAccess<NC, NBS, NP> {
// update if TE changed as well
successful = updateTileEntity(pos, tag);
}
//FAWE end
}
}
@ -190,6 +192,8 @@ public interface WorldNativeAccess<NC, NBS, NP> {
onBlockStateChange(pos, oldState, newState);
}
//FAWE start
void flush();
//FAWE end
}