From 22be7410fccd9dac1ec04a66cea96643e1b1b5ff Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 6 May 2021 11:54:22 +0200 Subject: [PATCH] Add Pattern#applyBlock in favor of Pattern#apply As Fawe extends into its own Filter class, this will need a Fawe-suitable solution at some point when removing the deprecated method. This is a compatibility-layer workaround for plugins calling the WorldEdit method `Pattern#applyBlock`. --- .../worldedit/function/pattern/Pattern.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index 6826f7474..754494d77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -23,21 +23,25 @@ import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockStateHolder; /** - * Returns a {@link BlockStateHolder} for a given position. + * Returns a {@link BaseBlock} for a given position. */ +// FAWE Start public interface Pattern extends Filter { /** - * Return a {@link BlockStateHolder} for the given position. + * Return a {@link BaseBlock} for the given position. * * @param position the position * @return a block + * @deprecated use {@link Pattern#applyBlock(BlockVector3)} */ + @Deprecated BaseBlock apply(BlockVector3 position); default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { @@ -48,4 +52,24 @@ public interface Pattern extends Filter { default void applyBlock(final FilterBlock block) { apply(block, block, block); } + + // FAWE End + + /** + * Return a {@link BaseBlock} for the given position. + * + * @param position the position + * @return a block + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility( + delegateName = "apply", + delegateParams = { BlockVector3.class } + ) + default BaseBlock applyBlock(BlockVector3 position) { + DeprecationUtil.checkDelegatingOverride(getClass()); + + return apply(position); + } }