mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00: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.
This commit is contained in:
parent
0047f20d5d
commit
6dd85e48ba
@ -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.Preloader;
|
||||
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.listener.BrushListener;
|
||||
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.util.Jars;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
@ -37,7 +39,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -228,11 +229,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName(World world) {
|
||||
return world.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions
|
||||
*/
|
||||
@ -347,4 +343,10 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
@ -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.CommandDeclaration;
|
@ -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.TaskManager;
|
||||
@ -7,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.Operations;
|
||||
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.world.World;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
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) {
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
//todo because of the following code this should proably be in the Bukkit module
|
||||
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 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());
|
||||
@ -70,8 +80,10 @@ public class FaweChunkManager extends ChunkManager {
|
||||
public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
EditSession to = 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()));
|
||||
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()));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
|
||||
try {
|
||||
@ -90,11 +102,15 @@ public class FaweChunkManager extends ChunkManager {
|
||||
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweChunkManager.class) {
|
||||
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
World world = editSession.getWorld();
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
|
||||
editSession.regenerate(region);
|
||||
editSession.flushQueue();
|
||||
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
|
||||
try (EditSession editSession = new EditSessionBuilder(pos1World).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()));
|
||||
editSession.regenerate(region);
|
||||
editSession.flushQueue();
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
@ -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.FaweAPI;
|
@ -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.FaweCache;
|
||||
@ -19,12 +21,14 @@ import com.sk89q.jnbt.CompressedSchematicTag;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -53,8 +57,9 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
Location pos1 = corners[0];
|
||||
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 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);
|
||||
|
@ -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.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
@ -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.plot.commands.CommandCategory;
|
@ -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;
|
||||
|
@ -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.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.Permissions;
|
||||
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.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
@ -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.object.RegionWrapper;
|
@ -3,7 +3,6 @@ package com.boydti.fawe;
|
||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
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.CleanTextureUtil;
|
||||
import com.boydti.fawe.util.FaweTimer;
|
||||
@ -188,8 +187,7 @@ public class Fawe {
|
||||
// transformParser = new DefaultTransformParser(getWorldEdit());
|
||||
visualQueue = new VisualQueue(3);
|
||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
||||
log.debug("Plugin 'PlotSquared' found. Using it now.");
|
||||
IMP.setupPlotSquared();
|
||||
} catch (Throwable ignored) {}
|
||||
}, 0);
|
||||
|
||||
|
@ -299,7 +299,7 @@ public class FaweAPI {
|
||||
throw new IllegalArgumentException("Origin is not a valid world");
|
||||
}
|
||||
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()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ public interface IFawe {
|
||||
|
||||
TaskManager getTaskManager();
|
||||
|
||||
String getWorldName(World world);
|
||||
|
||||
Collection<FaweMaskManager> getMaskManagers();
|
||||
|
||||
default ImageViewer getImageViewer(Player player) {
|
||||
@ -49,4 +47,5 @@ public interface IFawe {
|
||||
|
||||
Preloader getPreloader();
|
||||
|
||||
void setupPlotSquared();
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ public class AnvilCommands {
|
||||
// int oX = offset.getBlockX();
|
||||
// int oZ = offset.getBlockZ();
|
||||
// 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);
|
||||
// MCAQueue copyQueue = clipboard.getQueue();
|
||||
// MCAQueue pasteQueue = new MCAQueue(tmpTo);
|
||||
|
@ -43,9 +43,9 @@ public abstract class CuboidRegionFilter implements RegionFilter {
|
||||
int cz1 = pos1.getBlockZ() >> 4;
|
||||
int cx2 = pos2.getBlockX() >> 4;
|
||||
int cz2 = pos2.getBlockZ() >> 4;
|
||||
for (int cz = cz1; cz <= cz2; cz++) {
|
||||
for (int cx = cx1; cx <= cx2; cx++) {
|
||||
unoccupiedChunks.remove(cx, cz);
|
||||
for (int chunkZ = cz1; chunkZ <= cz2; chunkZ++) {
|
||||
for (int chunkX = cx1; chunkX <= cx2; chunkX++) {
|
||||
unoccupiedChunks.remove(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.minimumBlockY;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
@ -215,30 +214,23 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
private final int maxY;
|
||||
|
||||
@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) {
|
||||
this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
|
||||
public EditSession(EventBus bus, 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 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));
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
@ -248,8 +240,24 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
||||
* @param event the event to call with the extent
|
||||
*/
|
||||
public EditSession(EventBus eventBus, @NotNull World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) {
|
||||
this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
|
||||
public EditSession(EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent 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
|
||||
*/
|
||||
@Deprecated
|
||||
public void setFastMode(boolean enabled) {
|
||||
disableHistory(enabled);
|
||||
}
|
||||
@ -584,12 +593,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*
|
||||
* @param disableHistory
|
||||
*/
|
||||
@Deprecated
|
||||
public void disableHistory(boolean disableHistory) {
|
||||
if (disableHistory) {
|
||||
if (this.history) {
|
||||
disableHistory();
|
||||
this.history = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (this.history) {
|
||||
@ -609,6 +618,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasFastMode() {
|
||||
return getChangeSet() == null;
|
||||
}
|
||||
@ -2498,6 +2508,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*
|
||||
* @return number of blocks affected
|
||||
* @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)
|
||||
throws MaxChangedBlocksException {
|
||||
@ -2515,7 +2527,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
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++) {
|
||||
tipx = x1 + domstep * (x2 - x1 > 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));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
|
||||
if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) {
|
||||
} else if (dMax == dy && notdrawn) {
|
||||
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));
|
||||
@ -2534,10 +2544,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
|
||||
if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) {
|
||||
} else if (dMax == dz && notdrawn) {
|
||||
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));
|
||||
@ -2545,7 +2552,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
Set<BlockVector3> newVset;
|
||||
if (flat) {
|
||||
@ -2562,6 +2568,71 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
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.
|
||||
*
|
||||
|
@ -115,7 +115,7 @@ public class RegionCommands {
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -313,7 +313,7 @@ public class RegionCommands {
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public int overlay(Actor actor, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to overlay")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected)));
|
||||
return affected;
|
||||
@ -470,9 +470,9 @@ public class RegionCommands {
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/move",
|
||||
aliases = {"/mv"},
|
||||
desc = "Move the contents of the selection"
|
||||
name = "/move",
|
||||
aliases = {"/mv"},
|
||||
desc = "Move the contents of the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.move")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
@ -480,25 +480,25 @@ public class RegionCommands {
|
||||
public int move(Actor actor, World world, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of blocks to move", def = "1")
|
||||
int count,
|
||||
int count,
|
||||
@Arg(desc = "The direction to move", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
BlockVector3 direction,
|
||||
@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")
|
||||
boolean moveSelection,
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'e', desc = "Also copy entities")
|
||||
boolean copyEntities,
|
||||
@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 = "")
|
||||
Mask mask) throws WorldEditException {
|
||||
Mask mask) throws WorldEditException {
|
||||
checkCommandArgument(count >= 1, "Count must be >= 1");
|
||||
|
||||
Mask combinedMask;
|
||||
Mask combinedMask;
|
||||
if (ignoreAirBlocks) {
|
||||
if (mask == null) {
|
||||
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 = "")
|
||||
Mask mask) throws WorldEditException {
|
||||
|
||||
Mask combinedMask;
|
||||
Mask combinedMask;
|
||||
if (ignoreAirBlocks) {
|
||||
if (mask == null) {
|
||||
combinedMask = new ExistingBlockMask(editSession);
|
||||
@ -583,9 +583,9 @@ public class RegionCommands {
|
||||
|
||||
if (moveSelection) {
|
||||
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);
|
||||
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
@ -623,7 +623,7 @@ public class RegionCommands {
|
||||
session.setSourceMask(mask);
|
||||
}
|
||||
if (success) {
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
|
||||
} else {
|
||||
actor.printError(TranslatableComponent.of("worldedit.regen.failed"));
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user