3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Various changes

the most notable change is that PlotSquared is being moved to the Bukkit module again to allow for future compatibility with version 5 of the plugin.
Dieser Commit ist enthalten in:
MattBDev 2020-02-12 16:18:36 -05:00
Ursprung 0047f20d5d
Commit 6dd85e48ba
19 geänderte Dateien mit 178 neuen und 86 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,7 @@ import com.boydti.fawe.IFawe;
import com.boydti.fawe.beta.implementation.cache.preloader.AsyncPreloader; import com.boydti.fawe.beta.implementation.cache.preloader.AsyncPreloader;
import com.boydti.fawe.beta.implementation.cache.preloader.Preloader; import com.boydti.fawe.beta.implementation.cache.preloader.Preloader;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.regions.plotsquared.PlotSquaredFeature;
import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler;
import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.listener.BukkitImageListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener;
@ -26,6 +27,7 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.Jars; import com.boydti.fawe.util.Jars;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
@ -37,7 +39,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -228,11 +229,6 @@ public class FaweBukkit implements IFawe, Listener {
return plugin; return plugin;
} }
@Override
public String getWorldName(World world) {
return world.getName();
}
/** /**
* A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions * A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions
*/ */
@ -347,4 +343,10 @@ public class FaweBukkit implements IFawe, Listener {
} }
return null; return null;
} }
@Override
public void setupPlotSquared() {
WEManager.IMP.managers.add(new com.boydti.fawe.bukkit.regions.plotsquared.PlotSquaredFeature());
log.debug("Plugin 'PlotSquared' found. Using it now.");
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;

Datei anzeigen

@ -1,4 +1,6 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import static org.bukkit.Bukkit.getWorld;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -7,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -14,6 +18,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import org.bukkit.Bukkit;
public class FaweChunkManager extends ChunkManager { public class FaweChunkManager extends ChunkManager {
@ -47,8 +52,13 @@ public class FaweChunkManager extends ChunkManager {
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweChunkManager.class) {
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); //todo because of the following code this should proably be in the Bukkit module
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
WorldEdit.getInstance().getEditSessionFactory().getEditSession(
pos1World,-1);
EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ())); CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ()));
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint()); ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
@ -70,8 +80,10 @@ public class FaweChunkManager extends ChunkManager {
public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweChunkManager.class) {
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession to = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ())); ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
try { try {
@ -90,11 +102,15 @@ public class FaweChunkManager extends ChunkManager {
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) { public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweChunkManager.class) {
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World world = editSession.getWorld(); try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false)
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); .fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
editSession.regenerate(region); CuboidRegion region = new CuboidRegion(
editSession.flushQueue(); BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
editSession.regenerate(region);
editSession.flushQueue();
}
TaskManager.IMP.task(whenDone); TaskManager.IMP.task(whenDone);
} }
}); });

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;

Datei anzeigen

@ -1,4 +1,6 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import static org.bukkit.Bukkit.getWorld;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
@ -19,12 +21,14 @@ import com.sk89q.jnbt.CompressedSchematicTag;
import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; 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.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter; import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -53,8 +57,9 @@ public class FaweSchematicHandler extends SchematicHandler {
Location[] corners = MainUtil.getCorners(world, regions); Location[] corners = MainUtil.getCorners(world, regions);
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
World adaptedWorld = BukkitAdapter.adapt(getWorld(world));
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); final EditSession editSession = new EditSessionBuilder(adaptedWorld).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region); ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory; import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
@ -17,7 +17,6 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;

Datei anzeigen

@ -3,7 +3,6 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.object.brush.visualization.VisualQueue;
import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature;
import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.CleanTextureUtil; import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FaweTimer; import com.boydti.fawe.util.FaweTimer;
@ -188,8 +187,7 @@ public class Fawe {
// transformParser = new DefaultTransformParser(getWorldEdit()); // transformParser = new DefaultTransformParser(getWorldEdit());
visualQueue = new VisualQueue(3); visualQueue = new VisualQueue(3);
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers()); WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
WEManager.IMP.managers.add(new PlotSquaredFeature()); IMP.setupPlotSquared();
log.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable ignored) {} } catch (Throwable ignored) {}
}, 0); }, 0);

Datei anzeigen

@ -299,7 +299,7 @@ public class FaweAPI {
throw new IllegalArgumentException("Origin is not a valid world"); throw new IllegalArgumentException("Origin is not a valid world");
} }
World world = (World) extent; World world = (World) extent;
File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world)); File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName());
if (!history.exists()) { if (!history.exists()) {
return new ArrayList<>(); return new ArrayList<>();
} }

Datei anzeigen

@ -23,8 +23,6 @@ public interface IFawe {
TaskManager getTaskManager(); TaskManager getTaskManager();
String getWorldName(World world);
Collection<FaweMaskManager> getMaskManagers(); Collection<FaweMaskManager> getMaskManagers();
default ImageViewer getImageViewer(Player player) { default ImageViewer getImageViewer(Player player) {
@ -49,4 +47,5 @@ public interface IFawe {
Preloader getPreloader(); Preloader getPreloader();
void setupPlotSquared();
} }

Datei anzeigen

@ -627,7 +627,7 @@ public class AnvilCommands {
// int oX = offset.getBlockX(); // int oX = offset.getBlockX();
// int oZ = offset.getBlockZ(); // int oZ = offset.getBlockZ();
// RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ); // RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ);
// String pasteWorldName = Fawe.imp().getWorldName(editSession.getWorld()); // String pasteWorldName = editSession.getWorld().getName();
// IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false); // IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false);
// MCAQueue copyQueue = clipboard.getQueue(); // MCAQueue copyQueue = clipboard.getQueue();
// MCAQueue pasteQueue = new MCAQueue(tmpTo); // MCAQueue pasteQueue = new MCAQueue(tmpTo);

Datei anzeigen

@ -43,9 +43,9 @@ public abstract class CuboidRegionFilter implements RegionFilter {
int cz1 = pos1.getBlockZ() >> 4; int cz1 = pos1.getBlockZ() >> 4;
int cx2 = pos2.getBlockX() >> 4; int cx2 = pos2.getBlockX() >> 4;
int cz2 = pos2.getBlockZ() >> 4; int cz2 = pos2.getBlockZ() >> 4;
for (int cz = cz1; cz <= cz2; cz++) { for (int chunkZ = cz1; chunkZ <= cz2; chunkZ++) {
for (int cx = cx1; cx <= cx2; cx++) { for (int chunkX = cx1; chunkX <= cx2; chunkX++) {
unoccupiedChunks.remove(cx, cz); unoccupiedChunks.remove(chunkX, chunkZ);
} }
} }
} }

Datei anzeigen

@ -144,7 +144,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY; import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;
/** /**
@ -215,30 +214,23 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
private final int maxY; private final int maxY;
@Deprecated @Deprecated
public EditSession(@NotNull World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { public EditSession(EventBus bus, World world, @Nullable Player player,
this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event); @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet,
@Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue,
@Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages,
@Nullable BlockBag blockBag, @Nullable EditSessionEvent event) {
this(bus, world, null, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag,
event);
} }
public EditSession(@Nullable String worldName, @Nullable World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { public EditSession(EventBus bus, World world, String worldName,
@Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet,
@Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode,
@Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag,
@Nullable EditSessionEvent event) {
this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event)); this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event));
} }
public EditSession(EditSessionBuilder builder) {
super(builder.compile().getExtent());
this.world = builder.getWorld();
this.worldName = builder.getWorldName();
this.wrapped = builder.isWrapped();
this.bypassHistory = builder.getBypassHistory();
this.bypassAll = builder.getBypassAll();
this.originalLimit = builder.getLimit();
this.limit = builder.getLimit().copy();
this.player = builder.getPlayer();
this.changeSet = builder.getChangeTask();
this.maxY = builder.getMaxY();
this.blockBag = builder.getBlockBag();
this.history = changeSet != null;
}
/** /**
* Construct the object with a maximum number of blocks and a block bag. * Construct the object with a maximum number of blocks and a block bag.
* *
@ -248,8 +240,24 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param blockBag an optional {@link BlockBag} to use, otherwise null * @param blockBag an optional {@link BlockBag} to use, otherwise null
* @param event the event to call with the extent * @param event the event to call with the extent
*/ */
public EditSession(EventBus eventBus, @NotNull World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) { public EditSession(EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) {
this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event); this(eventBus, world, null, null, null, null, true, null, null, null, blockBag, event);
}
public EditSession(EditSessionBuilder builder) {
super(builder.compile().getExtent());
this.world = builder.getWorld();
this.worldName = world.getName();
this.wrapped = builder.isWrapped();
this.bypassHistory = builder.getBypassHistory();
this.bypassAll = builder.getBypassAll();
this.originalLimit = builder.getLimit();
this.limit = builder.getLimit().copy();
this.player = builder.getPlayer();
this.changeSet = builder.getChangeTask();
this.maxY = builder.getMaxY();
this.blockBag = builder.getBlockBag();
this.history = changeSet != null;
} }
/** /**
@ -575,6 +583,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* *
* @param enabled true to enable * @param enabled true to enable
*/ */
@Deprecated
public void setFastMode(boolean enabled) { public void setFastMode(boolean enabled) {
disableHistory(enabled); disableHistory(enabled);
} }
@ -584,12 +593,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* *
* @param disableHistory * @param disableHistory
*/ */
@Deprecated
public void disableHistory(boolean disableHistory) { public void disableHistory(boolean disableHistory) {
if (disableHistory) { if (disableHistory) {
if (this.history) { if (this.history) {
disableHistory(); disableHistory();
this.history = false; this.history = false;
return;
} }
} else { } else {
if (this.history) { if (this.history) {
@ -609,6 +618,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* *
* @return true if enabled * @return true if enabled
*/ */
@Deprecated
public boolean hasFastMode() { public boolean hasFastMode() {
return getChangeSet() == null; return getChangeSet() == null;
} }
@ -2498,6 +2508,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* *
* @return number of blocks affected * @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*
* @see #drawLine(Pattern, List, double, boolean)
*/ */
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat) public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
@ -2515,7 +2527,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
notdrawn = false; notdrawn = false;
} }
if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) { int dMax = Math.max(Math.max(dx, dy), dz);
if (dMax == dx && notdrawn) {
for (int domstep = 0; domstep <= dx; domstep++) { for (int domstep = 0; domstep <= dx; domstep++) {
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1); tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1)); tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1));
@ -2523,10 +2536,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
vset.add(BlockVector3.at(tipx, tipy, tipz)); vset.add(BlockVector3.at(tipx, tipy, tipz));
} }
notdrawn = false; } else if (dMax == dy && notdrawn) {
}
if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) {
for (int domstep = 0; domstep <= dy; domstep++) { for (int domstep = 0; domstep <= dy; domstep++) {
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1); tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1)); tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1));
@ -2534,10 +2544,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
vset.add(BlockVector3.at(tipx, tipy, tipz)); vset.add(BlockVector3.at(tipx, tipy, tipz));
} }
notdrawn = false; } else if (dMax == dz && notdrawn) {
}
if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) {
for (int domstep = 0; domstep <= dz; domstep++) { for (int domstep = 0; domstep <= dz; domstep++) {
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1); tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2-y1>0 ? 1 : -1)); tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2-y1>0 ? 1 : -1));
@ -2545,7 +2552,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
vset.add(BlockVector3.at(tipx, tipy, tipz)); vset.add(BlockVector3.at(tipx, tipy, tipz));
} }
notdrawn = false;
} }
Set<BlockVector3> newVset; Set<BlockVector3> newVset;
if (flat) { if (flat) {
@ -2562,6 +2568,71 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return setBlocks(newVset, pattern); return setBlocks(newVset, pattern);
} }
/**
* Draws a line (out of blocks) between two or more vectors.
*
* @param pattern The block pattern used to draw the line.
* @param vectors the list of vectors to draw the line between
* @param radius The radius (thickness) of the line.
* @param filled If false, only a shell will be generated.
*
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drawLine(Pattern pattern, List<BlockVector3> vectors, double radius, boolean filled)
throws MaxChangedBlocksException {
Set<BlockVector3> vset = new HashSet<>();
for (int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) {
BlockVector3 pos1 = vectors.get(i);
BlockVector3 pos2 = vectors.get(i + 1);
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ();
int tipx = x1, tipy = y1, tipz = z1;
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
if (dx + dy + dz == 0) {
vset.add(BlockVector3.at(tipx, tipy, tipz));
continue;
}
int dMax = Math.max(Math.max(dx, dy), dz);
if (dMax == dx) {
for (int domstep = 0; domstep <= dx; domstep++) {
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
}
} else if (dMax == dy) {
for (int domstep = 0; domstep <= dy; domstep++) {
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
}
} else /* if (dMax == dz) */ {
for (int domstep = 0; domstep <= dz; domstep++) {
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
vset.add(BlockVector3.at(tipx, tipy, tipz));
}
}
}
vset = getBallooned(vset, radius);
if (!filled) {
vset = getHollowed(vset);
}
return setBlocks(vset, pattern);
}
/** /**
* Draws a spline (out of blocks) between specified vectors. * Draws a spline (out of blocks) between specified vectors.
* *

Datei anzeigen

@ -115,7 +115,7 @@ public class RegionCommands {
System.out.println("TODO FIXME TIPS"); System.out.println("TODO FIXME TIPS");
// TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor); // TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor);
} }
return 0; return affected;
} }
@Command( @Command(
@ -313,7 +313,7 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public int overlay(Actor actor, EditSession editSession, @Selection Region region, public int overlay(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to overlay") @Arg(desc = "The pattern of blocks to overlay")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
int affected = editSession.overlayCuboidBlocks(region, pattern); int affected = editSession.overlayCuboidBlocks(region, pattern);
actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected))); actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected)));
return affected; return affected;
@ -470,9 +470,9 @@ public class RegionCommands {
@Command( @Command(
name = "/move", name = "/move",
aliases = {"/mv"}, aliases = {"/mv"},
desc = "Move the contents of the selection" desc = "Move the contents of the selection"
) )
@CommandPermissions("worldedit.region.move") @CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
@ -480,25 +480,25 @@ public class RegionCommands {
public int move(Actor actor, World world, EditSession editSession, LocalSession session, public int move(Actor actor, World world, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(desc = "# of blocks to move", def = "1") @Arg(desc = "# of blocks to move", def = "1")
int count, int count,
@Arg(desc = "The direction to move", def = Direction.AIM) @Arg(desc = "The direction to move", def = Direction.AIM)
@Direction(includeDiagonals = true) @Direction(includeDiagonals = true)
BlockVector3 direction, BlockVector3 direction,
@Arg(desc = "The pattern of blocks to leave", def = "air") @Arg(desc = "The pattern of blocks to leave", def = "air")
Pattern replace, Pattern replace,
@Switch(name = 's', desc = "Shift the selection to the target location") @Switch(name = 's', desc = "Shift the selection to the target location")
boolean moveSelection, boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks") @Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks, boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Also copy entities") @Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException { Mask mask) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1"); checkCommandArgument(count >= 1, "Count must be >= 1");
Mask combinedMask; Mask combinedMask;
if (ignoreAirBlocks) { if (ignoreAirBlocks) {
if (mask == null) { if (mask == null) {
combinedMask = new ExistingBlockMask(editSession); combinedMask = new ExistingBlockMask(editSession);
@ -568,7 +568,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException { Mask mask) throws WorldEditException {
Mask combinedMask; Mask combinedMask;
if (ignoreAirBlocks) { if (ignoreAirBlocks) {
if (mask == null) { if (mask == null) {
combinedMask = new ExistingBlockMask(editSession); combinedMask = new ExistingBlockMask(editSession);
@ -583,9 +583,9 @@ public class RegionCommands {
if (moveSelection) { if (moveSelection) {
try { try {
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
final BlockVector3 shiftVector = direction.multiply(size).multiply(count); final BlockVector3 shiftVector = direction.multiply(size).multiply(count);
region.shift(shiftVector); region.shift(shiftVector);
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
@ -623,7 +623,7 @@ public class RegionCommands {
session.setSourceMask(mask); session.setSourceMask(mask);
} }
if (success) { if (success) {
actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated")); actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
} else { } else {
actor.printError(TranslatableComponent.of("worldedit.regen.failed")); actor.printError(TranslatableComponent.of("worldedit.regen.failed"));
} }

Datei anzeigen

@ -43,7 +43,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;