fix: fix plot swap (#2360)

- deprecate and note for internal use only Clipboard#create as it's funky
 - fixes #2076
This commit is contained in:
Jordan 2024-01-21 12:42:24 +01:00 committed by GitHub
parent a7c5f66a45
commit e815071134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 13 deletions

View File

@ -16,6 +16,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.FlatRegionFunction;
@ -217,7 +218,6 @@ public class FaweDelegateRegionManager {
) { ) {
TaskManager.taskManager().async(() -> { TaskManager.taskManager().async(() -> {
synchronized (FaweDelegateRegionManager.class) { synchronized (FaweDelegateRegionManager.class) {
//todo because of the following code this should probably be in the Bukkit module
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName())); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName()));
World pos3World = BukkitAdapter.adapt(getWorld(swapPos.getWorldName())); World pos3World = BukkitAdapter.adapt(getWorld(swapPos.getWorldName()));
EditSession sessionA = WorldEdit.getInstance().newEditSessionBuilder().world(pos1World) EditSession sessionA = WorldEdit.getInstance().newEditSessionBuilder().world(pos1World)
@ -236,14 +236,16 @@ public class FaweDelegateRegionManager {
CuboidRegion regionB = new CuboidRegion( CuboidRegion regionB = new CuboidRegion(
pos3World, pos3World,
swapPos.getBlockVector3(), swapPos.getBlockVector3(),
swapPos.getBlockVector3().add(pos2.getBlockVector3()).subtract(pos1.getBlockVector3()) swapPos.getBlockVector3().add(pos2.getBlockVector3().subtract(pos1.getBlockVector3())).withY(pos2.getY())
); );
Clipboard clipA = Clipboard.create(regionA, UUID.randomUUID()); Clipboard clipA = new BlockArrayClipboard(regionA, UUID.randomUUID());
Clipboard clipB = Clipboard.create(regionB, UUID.randomUUID()); Clipboard clipB = new BlockArrayClipboard(regionB, UUID.randomUUID());
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, clipA, clipA.getMinimumPoint()); ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, clipA, clipA.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, clipB, clipB.getMinimumPoint()); ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, clipB, clipB.getMinimumPoint());
copyA.setCopyingBiomes(true); copyA.setCopyingBiomes(true);
copyB.setCopyingBiomes(true); copyB.setCopyingBiomes(true);
copyA.setCopyingEntities(true);
copyB.setCopyingEntities(true);
try { try {
Operations.completeLegacy(copyA); Operations.completeLegacy(copyA);
Operations.completeLegacy(copyB); Operations.completeLegacy(copyB);
@ -257,17 +259,16 @@ public class FaweDelegateRegionManager {
sessionA.close(); sessionA.close();
sessionB.close(); sessionB.close();
} }
FaweAPI.fixLighting(pos1World, new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()), null, FaweAPI.fixLighting(
pos1World,
regionA,
null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
); );
FaweAPI.fixLighting(pos1World, new CuboidRegion( FaweAPI.fixLighting(
swapPos.getBlockVector3(), pos1World,
BlockVector3.at( regionB,
swapPos.getX() + pos2.getX() - pos1.getX(), null,
0,
swapPos.getZ() + pos2.getZ() - pos1.getZ()
)
), null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE) RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
); );
if (whenDone != null) { if (whenDone != null) {

View File

@ -73,7 +73,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
/** /**
* Creates a new {@link ReadOnlyClipboard}. * Creates a new {@link ReadOnlyClipboard}.
*
* @deprecated Internal use only. Use {@link BlockArrayClipboard#BlockArrayClipboard(Region)}
*/ */
@Deprecated
static Clipboard create(Region region) { static Clipboard create(Region region) {
checkNotNull(region); checkNotNull(region);
checkNotNull( checkNotNull(
@ -95,7 +98,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
* - {@link DiskOptimizedClipboard} * - {@link DiskOptimizedClipboard}
* - {@link CPUOptimizedClipboard} * - {@link CPUOptimizedClipboard}
* - {@link MemoryOptimizedClipboard} * - {@link MemoryOptimizedClipboard}
*
* @deprecated Internal use only. Use {@link BlockArrayClipboard#BlockArrayClipboard(Region, UUID)}
*/ */
@Deprecated
static Clipboard create(Region region, UUID uuid) { static Clipboard create(Region region, UUID uuid) {
if (Settings.settings().CLIPBOARD.USE_DISK) { if (Settings.settings().CLIPBOARD.USE_DISK) {
return new DiskOptimizedClipboard(region, uuid); return new DiskOptimizedClipboard(region, uuid);