Re-shuffle regen methods to fix deprecation order

Everything delegates to the original EditSession signature. The new
RegenOptions + EditSession variant is removed, as it was never
officially published. A delegation check was installed in the
NAFC-marked method.
This commit is contained in:
Octavia Togami 2020-07-25 19:53:00 -07:00 committed by Matthew Miller
parent c3f533e893
commit 288ed7fa9f
3 changed files with 26 additions and 31 deletions

View File

@ -27,6 +27,7 @@
import com.sk89q.worldedit.cli.CLIWorld;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
@ -106,7 +107,7 @@ public void simulateBlockMine(BlockVector3 position) {
}
@Override
public boolean regenerate(Region region, EditSession editSession, RegenOptions options) {
public boolean regenerate(Region region, Extent extent, RegenOptions options) {
return false;
}

View File

@ -26,6 +26,7 @@
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
@ -113,7 +114,7 @@ public void simulateBlockMine(BlockVector3 position) {
}
@Override
public boolean regenerate(Region region, EditSession editSession, RegenOptions options) {
public boolean regenerate(Region region, Extent extent, RegenOptions options) {
return false;
}

View File

@ -27,6 +27,7 @@
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
@ -204,6 +205,17 @@ default boolean notifyAndLightBlock(BlockVector3 position, BlockState previousTy
*/
void simulateBlockMine(BlockVector3 position);
/**
* Regenerate an area.
*
* @param region the region
* @param editSession the {@link EditSession}
* @return true if re-generation was successful
*/
default boolean regenerate(Region region, EditSession editSession) {
return regenerate(region, editSession, RegenOptions.builder().build());
}
/**
* Regenerate an area.
*
@ -215,17 +227,6 @@ default boolean regenerate(Region region, Extent extent) {
return regenerate(region, extent, RegenOptions.builder().build());
}
/**
* Regenerate an area.
*
* @param region the region
* @param editSession the {@link EditSession}
* @return true if re-generation was successful
*/
default boolean regenerate(Region region, EditSession editSession) {
return regenerate(region, (Extent) editSession, RegenOptions.builder().build());
}
/**
* Regenerate an area.
*
@ -233,29 +234,21 @@ default boolean regenerate(Region region, EditSession editSession) {
* @param extent the {@link Extent}
* @param options the regeneration options
* @return true if regeneration was successful
*/
@NonAbstractForCompatibility(
delegateName = "regenerate",
delegateParams = { Region.class, Extent.class }
)
default boolean regenerate(Region region, Extent extent, RegenOptions options) {
return regenerate(region, extent);
}
/**
* Regenerate an area.
*
* @param region the region
* @param editSession the {@link EditSession}
* @param options the regeneration options
* @return true if regeneration was successful
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(
delegateName = "regenerate",
delegateParams = { Region.class, EditSession.class }
)
default boolean regenerate(Region region, EditSession editSession, RegenOptions options) {
return regenerate(region, (Extent) editSession);
default boolean regenerate(Region region, Extent extent, RegenOptions options) {
DeprecationUtil.checkDelegatingOverride(getClass());
if (extent instanceof EditSession) {
return regenerate(region, (EditSession) extent);
}
throw new UnsupportedOperationException("This World class ("
+ getClass().getName()
+ ") does not implement the general Extent variant of this method");
}
/**