mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +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:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "cfi",
|
||||
permission = "plots.createfromimage",
|
||||
aliases = {"createfromheightmap", "createfromimage", "cfhm"},
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Generate a world from an image heightmap: [More info](https://goo.gl/friFbV)",
|
||||
usage = "/plots cfi [url or dimensions]"
|
||||
)
|
||||
public class CFIRedirect extends Command {
|
||||
private final WorldEdit we;
|
||||
|
||||
public CFIRedirect() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.we = WorldEdit.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length >= 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()), Captions.NOW_OWNER);
|
||||
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
||||
final PlotArea area = plot.getArea();
|
||||
if (area instanceof SinglePlotArea) {
|
||||
player.sendMessage("The command has been changed to: //cfi");
|
||||
} else {
|
||||
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
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.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class FaweChunkManager extends ChunkManager {
|
||||
|
||||
private ChunkManager parent;
|
||||
|
||||
public FaweChunkManager(ChunkManager parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] countEntities(Plot plot) {
|
||||
return parent.countEntities(plot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture loadChunk(String world, BlockVector2 loc, boolean force) {
|
||||
return parent.loadChunk(world, loc, force);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunk(String world, BlockVector2 loc, boolean save) {
|
||||
parent.unloadChunk(world, loc, save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(Location pos1, Location pos2) {
|
||||
parent.clearAllEntities(pos1, pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
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());
|
||||
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
|
||||
try {
|
||||
Operations.completeLegacy(copyA);
|
||||
Operations.completeLegacy(copyB);
|
||||
sessionA.flushQueue();
|
||||
sessionB.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
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 {
|
||||
Operations.completeLegacy(copy);
|
||||
to.flushQueue();
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
TaskManager.IMP.task(whenDone);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IQueueChunk;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
// TODO FIXME
|
||||
public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||
|
||||
public final IQueueExtent<IQueueChunk> IMP;
|
||||
private final World world;
|
||||
private BlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public FaweLocalBlockQueue(String worldName) {
|
||||
super(worldName);
|
||||
this.world = FaweAPI.getWorld(worldName);
|
||||
IMP = Fawe.get().getQueueHandler().getQueue(world);
|
||||
Fawe.get().getQueueHandler().unCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() {
|
||||
if (!IMP.isEmpty()) {
|
||||
IMP.flush();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSet(boolean parallel) {
|
||||
Fawe.get().getQueueHandler().startSet(parallel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endSet(boolean parallel) {
|
||||
Fawe.get().getQueueHandler().endSet(parallel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IMP.isEmpty() ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optimize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModified(long l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModified() {
|
||||
return IMP.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(final int x, final int y, final int z, final BlockState id) {
|
||||
return IMP.setBlock(x, y, z, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||
mutable.setComponents(x, y, z);
|
||||
return pattern.apply(IMP, mutable, mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(final int x, final int y, final int z, final BaseBlock id) {
|
||||
return IMP.setBlock(x, y, z, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return IMP.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||
return IMP.setBiome(x, 0, z, biomeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorld() {
|
||||
return world.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
IMP.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enqueue() {
|
||||
boolean val = super.enqueue();
|
||||
IMP.enableQueue();
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshChunk(int x, int z) {
|
||||
world.refreshChunk(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixChunkLighting(int x, int z) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void regenChunk(int x, int z) {
|
||||
IMP.regenerateChunk(x, z, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||
IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompressedCompoundTag;
|
||||
import com.sk89q.jnbt.CompressedSchematicTag;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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 java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
public class FaweSchematicHandler extends SchematicHandler {
|
||||
@Override
|
||||
public boolean restoreTile(LocalBlockQueue queue, CompoundTag compoundTag, int x, int y, int z) {
|
||||
if (queue instanceof FaweLocalBlockQueue) {
|
||||
queue.setTile(x, y, z, compoundTag);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Set<CuboidRegion> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
TaskManager.IMP.async(() -> {
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
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();
|
||||
|
||||
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
|
||||
|
||||
Clipboard holder = new BlockArrayClipboard(region, clipboard);
|
||||
CompressedSchematicTag tag = new CompressedSchematicTag(holder);
|
||||
whenDone.run(tag);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(CompoundTag tag, String path) {
|
||||
if (tag == null) {
|
||||
PlotSquared.debug("&cCannot save empty tag");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
File tmp = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), path);
|
||||
tmp.getParentFile().mkdirs();
|
||||
if (tag instanceof CompressedCompoundTag) {
|
||||
CompressedCompoundTag cTag = (CompressedCompoundTag) tag;
|
||||
if (cTag instanceof CompressedSchematicTag) {
|
||||
Clipboard clipboard = (Clipboard) cTag.getSource();
|
||||
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new BufferedOutputStream(new PGZIPOutputStream(stream)))) {
|
||||
new FastSchematicWriter(output).write(clipboard);
|
||||
}
|
||||
} else {
|
||||
try (OutputStream stream = new FileOutputStream(tmp); BufferedOutputStream output = new BufferedOutputStream(new PGZIPOutputStream(stream))) {
|
||||
LZ4BlockInputStream is = cTag.adapt(cTag.getSource());
|
||||
IOUtil.copy(is, stream);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) {
|
||||
Map<String, Tag> map = tag.getValue();
|
||||
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
|
||||
if (tag == null) {
|
||||
PlotSquared.debug("&cCannot save empty tag");
|
||||
com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);
|
||||
if (weTag instanceof CompressedSchematicTag) {
|
||||
Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource();
|
||||
URL url = FaweAPI.upload(clipboard, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
|
||||
whenDone.run(url);
|
||||
return;
|
||||
}
|
||||
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
|
||||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try {
|
||||
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
|
||||
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
|
||||
Map<String, Tag> map = weTag.getValue();
|
||||
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, whenDone);
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.SubCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trimchunks",
|
||||
permission = "plots.admin",
|
||||
description = "Delete unmodified portions of your plotworld",
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class FaweTrim extends SubCommand {
|
||||
|
||||
private boolean ran = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plotPlayer, final String[] strings) {
|
||||
if (ran) {
|
||||
plotPlayer.sendMessage("Already running!");
|
||||
return false;
|
||||
}
|
||||
if (strings.length != 2) {
|
||||
plotPlayer.sendMessage("First make a backup of your world called <world-copy> then stand in the middle of an empty plot");
|
||||
plotPlayer.sendMessage("use /plot trimall <world> <boolean-delete-unowned>");
|
||||
return false;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(strings[0])) {
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(plotPlayer, strings[0]);
|
||||
return false;
|
||||
}
|
||||
ran = true;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// TODO NOT IMPLEMENTED
|
||||
// PlotTrim trim = new PlotTrim(plotPlayer, plotPlayer.getPlotAreaAbs(), strings[0], Boolean.parseBoolean(strings[1]));
|
||||
// Location loc = plotPlayer.getLocation();
|
||||
// trim.setChunk(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
// trim.run();
|
||||
// plotPlayer.sendMessage("Done!");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ran = false;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,341 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "moveto512",
|
||||
permission = "plots.moveto512",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
description = "Move plots to a 512 sized region",
|
||||
usage = "/plots moveto512 [world]"
|
||||
)
|
||||
// TODO FIXME
|
||||
public class MoveTo512 /*extends Command*/ {
|
||||
|
||||
// public MoveTo512() {
|
||||
// super(MainCommand.getInstance(), true);
|
||||
// }
|
||||
//
|
||||
// private MCAChunk emptyPlot(MCAChunk chunk, HybridPlotWorld hpw) {
|
||||
// int maxLayer = (hpw.PLOT_HEIGHT) >> 4;
|
||||
// for (int i = maxLayer + 1; i < chunk.ids.length; i++) {
|
||||
// chunk.ids[i] = null;
|
||||
// chunk.data[i] = null;
|
||||
// }
|
||||
// for (int layer = 0; layer <= maxLayer; layer++) {
|
||||
// byte[] ids = chunk.ids[layer];
|
||||
// if (ids == null) {
|
||||
// ids = chunk.ids[layer] = new byte[4096];
|
||||
// chunk.data[layer] = new byte[2048];
|
||||
// chunk.skyLight[layer] = new byte[2048];
|
||||
// chunk.blockLight[layer] = new byte[2048];
|
||||
// } else {
|
||||
// Arrays.fill(ids, (byte) 0);
|
||||
// Arrays.fill(chunk.data[layer], (byte) 0);
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 0);
|
||||
// Arrays.fill(chunk.blockLight[layer], (byte) 0);
|
||||
// }
|
||||
// if (layer == maxLayer) {
|
||||
// int yMax = hpw.PLOT_HEIGHT & 15;
|
||||
// for (int y = yMax + 1; y < 15; y++) {
|
||||
// Arrays.fill(chunk.skyLight[layer], y << 7, (y << 7) + 128, (byte) 255);
|
||||
// }
|
||||
// if (layer == 0) {
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// for (int y = 1; y < yMax; y++) {
|
||||
// int y8 = y << 8;
|
||||
// Arrays.fill(ids, y8, y8 + 256, (byte) 3);
|
||||
// }
|
||||
// } else {
|
||||
// for (int y = 0; y < yMax; y++) {
|
||||
// int y8 = y << 8;
|
||||
// Arrays.fill(ids, y8, y8 + 256, (byte) 3);
|
||||
// }
|
||||
// }
|
||||
// int yMax15 = yMax & 15;
|
||||
// int yMax158 = yMax15 << 8;
|
||||
// Arrays.fill(ids, yMax158, yMax158 + 256, (byte) 2);
|
||||
// if (yMax != 15) {
|
||||
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
|
||||
// }
|
||||
// } else if (layer == 0){
|
||||
// Arrays.fill(ids, 256, 4096, (byte) 3);
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// } else {
|
||||
// Arrays.fill(ids, (byte) 3);
|
||||
// }
|
||||
// }
|
||||
// return chunk;
|
||||
// }
|
||||
//
|
||||
// private MCAChunk emptyRoad(MCAChunk chunk, HybridPlotWorld hpw) {
|
||||
// int maxLayer = (hpw.ROAD_HEIGHT) >> 4;
|
||||
// for (int i = maxLayer + 1; i < chunk.ids.length; i++) {
|
||||
// chunk.ids[i] = null;
|
||||
// chunk.data[i] = null;
|
||||
// }
|
||||
// for (int layer = 0; layer <= maxLayer; layer++) {
|
||||
// byte[] ids = chunk.ids[layer];
|
||||
// if (ids == null) {
|
||||
// ids = chunk.ids[layer] = new byte[4096];
|
||||
// chunk.data[layer] = new byte[2048];
|
||||
// chunk.skyLight[layer] = new byte[2048];
|
||||
// chunk.blockLight[layer] = new byte[2048];
|
||||
// } else {
|
||||
// Arrays.fill(ids, (byte) 0);
|
||||
// Arrays.fill(chunk.data[layer], (byte) 0);
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 0);
|
||||
// Arrays.fill(chunk.blockLight[layer], (byte) 0);
|
||||
// }
|
||||
// if (layer == maxLayer) {
|
||||
// int yMax = hpw.ROAD_HEIGHT & 15;
|
||||
// for (int y = yMax + 1; y < 15; y++) {
|
||||
// Arrays.fill(chunk.skyLight[layer], y << 7, (y << 7) + 128, (byte) 255);
|
||||
// }
|
||||
// if (layer == 0) {
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// for (int y = 1; y <= yMax; y++) {
|
||||
// int y8 = y << 8;
|
||||
// Arrays.fill(ids, y8, y8 + 256, (byte) hpw.ROAD_BLOCK.id);
|
||||
// }
|
||||
// } else {
|
||||
// for (int y = 0; y <= yMax; y++) {
|
||||
// int y8 = y << 8;
|
||||
// Arrays.fill(ids, y8, y8 + 256, (byte) hpw.ROAD_BLOCK.id);
|
||||
// }
|
||||
// }
|
||||
// if (yMax != 15) {
|
||||
// int yMax15 = yMax & 15;
|
||||
// int yMax158 = yMax15 << 8;
|
||||
// Arrays.fill(ids, yMax158 + 256, 4096, (byte) 0);
|
||||
// }
|
||||
// } else if (layer == 0){
|
||||
// Arrays.fill(ids, 256, 4096, (byte) hpw.ROAD_BLOCK.id);
|
||||
// Arrays.fill(ids, 0, 256, (byte) 7);
|
||||
// } else {
|
||||
// Arrays.fill(ids, (byte) hpw.ROAD_BLOCK.id);
|
||||
// }
|
||||
// }
|
||||
// return chunk;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
// checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
// PlotArea area = player.getPlotAreaAbs();
|
||||
// check(area, Captions.COMMAND_SYNTAX, getUsage());
|
||||
// checkTrue(area instanceof HybridPlotWorld, Captions.NOT_VALID_HYBRID_PLOT_WORLD);
|
||||
//
|
||||
// WorldUtil.IMP.saveWorld(area.worldname);
|
||||
//
|
||||
// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
|
||||
// MCAQueue queueFrom = new MCAQueue(area.worldname, defaultQueue.getSaveFolder(), defaultQueue.hasSky());
|
||||
//
|
||||
// String world = args[0];
|
||||
// File folder = new File(PS.imp().getWorldContainer(), world + File.separator + "region");
|
||||
// checkTrue(!folder.exists(), Captions.SETUP_WORLD_TAKEN, world);
|
||||
//
|
||||
// HybridPlotWorld hpw = (HybridPlotWorld) area;
|
||||
// int minRoad = 7;
|
||||
// int pLen = Math.min(hpw.PLOT_WIDTH, 512 - minRoad);
|
||||
// int roadWidth = 512 - pLen;
|
||||
// int roadPosLower;
|
||||
// if ((roadWidth & 1) == 0) {
|
||||
// roadPosLower = (short) (Math.floor(roadWidth / 2) - 1);
|
||||
// } else {
|
||||
// roadPosLower = (short) Math.floor(roadWidth / 2);
|
||||
// }
|
||||
// int roadPosUpper = 512 - roadWidth + roadPosLower + 1;
|
||||
//
|
||||
// final ThreadLocal<boolean[]> roadCache = new ThreadLocal<boolean[]>() {
|
||||
// @Override
|
||||
// protected boolean[] initialValue() {
|
||||
// return new boolean[64];
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// MCAChunk reference = new MCAChunk(null, 0, 0);
|
||||
// {
|
||||
// reference.fillCuboid(0, 15, 0, 0, 0, 15, 7, (byte) 0);
|
||||
// reference.fillCuboid(0, 15, 1, hpw.PLOT_HEIGHT - 1, 0, 15, 3, (byte) 0);
|
||||
// reference.fillCuboid(0, 15, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, 0, 15, 2, (byte) 0);
|
||||
// }
|
||||
//
|
||||
// Map<PlotId, Plot> rawPlots = area.getPlotsRaw();
|
||||
// ArrayList<Plot> plots = new ArrayList(rawPlots.values());
|
||||
// int size = plots.size();
|
||||
//
|
||||
// PlotId nextId = new PlotId(0, 0);
|
||||
//
|
||||
// long start = System.currentTimeMillis();
|
||||
//
|
||||
// int percent = 0;
|
||||
// for (Plot plot : plots) {
|
||||
// Fawe.debug(((percent += 100) / size) + "% complete!");
|
||||
//
|
||||
// Location bot = plot.getBottomAbs();
|
||||
// Location top = plot.getTopAbs();
|
||||
//
|
||||
// int oX = roadPosLower - bot.getX() + 1;
|
||||
// int oZ = roadPosLower - bot.getZ() + 1;
|
||||
//
|
||||
// { // Move
|
||||
// PlotId id = plot.getId();
|
||||
// Fawe.debug("Moving " + plot.getId() + " to " + nextId);
|
||||
// id.x = nextId.x;
|
||||
// id.y = nextId.y;
|
||||
// id.recalculateHash();
|
||||
// }
|
||||
//
|
||||
// MCAWriter writer = new MCAWriter(512, 512, folder) {
|
||||
//
|
||||
// @Override
|
||||
// public boolean shouldWrite(int chunkX, int chunkZ) {
|
||||
// int bx = chunkX << 4;
|
||||
// int bz = chunkZ << 4;
|
||||
// int tx = bx + 15;
|
||||
// int tz = bz + 15;
|
||||
// return !(tx < roadPosLower || tz < roadPosLower || bx > roadPosUpper || bz > roadPosUpper);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public MCAChunk write(MCAChunk newChunk, int bx, int tx, int bz, int tz) {
|
||||
// Arrays.fill(newChunk.biomes, (byte) 4);
|
||||
// if (!newChunk.tiles.isEmpty()) newChunk.tiles.clear();
|
||||
// if (tx < roadPosLower || tz < roadPosLower || bx > roadPosUpper || bz > roadPosUpper) {
|
||||
// return emptyRoad(newChunk, hpw);
|
||||
// } else {
|
||||
// boolean partRoad = (bx <= roadPosLower || bz <= roadPosLower || tx >= roadPosUpper || tz >= roadPosUpper);
|
||||
//
|
||||
// boolean changed = false;
|
||||
// emptyPlot(newChunk, hpw);
|
||||
//
|
||||
// int obx = bx - oX;
|
||||
// int obz = bz - oZ;
|
||||
// int otx = tx - oX;
|
||||
// int otz = tz - oZ;
|
||||
// int otherBCX = (obx) >> 4;
|
||||
// int otherBCZ = (obz) >> 4;
|
||||
// int otherTCX = (otx) >> 4;
|
||||
// int otherTCZ = (otz) >> 4;
|
||||
// int cx = newChunk.getX();
|
||||
// int cz = newChunk.getZ();
|
||||
// int cbx = (cx << 4) - oX;
|
||||
// int cbz = (cz << 4) - oZ;
|
||||
//
|
||||
// for (int otherCZ = otherBCZ; otherCZ <= otherTCZ; otherCZ++) {
|
||||
// for (int otherCX = otherBCX; otherCX <= otherTCX; otherCX++) {
|
||||
// FaweChunk chunk;
|
||||
// synchronized (queueFrom) {
|
||||
// chunk = queueFrom.getFaweChunk(otherCX, otherCZ);
|
||||
// }
|
||||
// if (!(chunk instanceof NullFaweChunk)) {
|
||||
// changed = true;
|
||||
// MCAChunk other = (MCAChunk) chunk;
|
||||
// int ocbx = otherCX << 4;
|
||||
// int ocbz = otherCZ << 4;
|
||||
// int octx = ocbx + 15;
|
||||
// int octz = ocbz + 15;
|
||||
// int offsetY = 0;
|
||||
// int minX = obx > ocbx ? (obx - ocbx) & 15 : 0;
|
||||
// int maxX = otx < octx ? (otx - ocbx) : 15;
|
||||
// int minZ = obz > ocbz ? (obz - ocbz) & 15 : 0;
|
||||
// int maxZ = otz < octz ? (otz - ocbz) : 15;
|
||||
// int offsetX = ocbx - cbx;
|
||||
// int offsetZ = ocbz - cbz;
|
||||
// newChunk.copyFrom(other, minX, maxX, 0, 255, minZ, maxZ, offsetX, offsetY, offsetZ);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!changed || reference.idsEqual(newChunk, false)) {
|
||||
// return null;
|
||||
// }
|
||||
// if (partRoad) {
|
||||
// boolean[] rwp = roadCache.get();
|
||||
// for (short i = 0; i < 16; i++) {
|
||||
// int vx = bx + i;
|
||||
// int vz = bz + i;
|
||||
// rwp[i] = vx < roadPosLower || vx > roadPosUpper;
|
||||
// rwp[i + 32] = vx == roadPosLower || vx == roadPosUpper;
|
||||
// rwp[i + 16] = vz < roadPosLower || vz > roadPosUpper;
|
||||
// rwp[i + 48] = vz == roadPosLower || vz == roadPosUpper;
|
||||
// }
|
||||
// for (int z = 0; z < 16; z++) {
|
||||
// final boolean rwpz16 = rwp[z + 16];
|
||||
// final boolean rwpz48 = rwp[z + 48];
|
||||
// for (int x = 0; x < 16; x++) {
|
||||
// if (rwpz16 || rwp[x]) {
|
||||
// for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||
// newChunk.setBlock(x, y, z, hpw.ROAD_BLOCK.id, hpw.ROAD_BLOCK.data);
|
||||
// }
|
||||
// for (int y = hpw.ROAD_HEIGHT + 1; y < 256; y++) {
|
||||
// newChunk.setBlock(x, y, z, 0, 0);
|
||||
// }
|
||||
// } else if (rwpz48 || rwp[x + 32]) {
|
||||
// for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
||||
// newChunk.setBlock(x, y, z, hpw.WALL_FILLING.id, hpw.WALL_FILLING.data);
|
||||
// }
|
||||
// for (int y = hpw.WALL_HEIGHT + 2; y < 256; y++) {
|
||||
// newChunk.setBlock(x, y, z, 0, 0);
|
||||
// }
|
||||
// newChunk.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.CLAIMED_WALL_BLOCK.id, hpw.CLAIMED_WALL_BLOCK.data);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return newChunk;
|
||||
// }
|
||||
// };
|
||||
// writer.setMCAOffset(nextId.x - 1, nextId.y - 1);
|
||||
// try {
|
||||
// writer.generate();
|
||||
// System.gc();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// return;
|
||||
// }
|
||||
// queueFrom.clear();
|
||||
// nextId = nextId.getNextId(1);
|
||||
// }
|
||||
// Fawe.debug("Anvil copy completed in " + ((System.currentTimeMillis() - start) / 1000d) + "s");
|
||||
// Fawe.debug("Updating database, please wait...");
|
||||
// rawPlots.clear();
|
||||
// for (Plot plot : plots) {
|
||||
// rawPlots.put(plot.getId(), plot);
|
||||
// DBFunc.movePlot(plot, plot);
|
||||
// }
|
||||
// SQLManager db = (SQLManager) DBFunc.dbManager;
|
||||
// db.addNotifyTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// Fawe.debug("Instructions");
|
||||
// Fawe.debug(" - Stop the server");
|
||||
// Fawe.debug(" - Rename the folder for the new world to the current world");
|
||||
// Fawe.debug(" - Change the plot size to " + pLen);
|
||||
// Fawe.debug(" - Change the road size to " + roadWidth);
|
||||
// Fawe.debug(" - Start the server");
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds." + world);
|
||||
// if (section == null) section = PS.get().worlds.createSection("worlds." + world);
|
||||
// area.saveConfiguration(section);
|
||||
// section.set("plot.size", pLen);
|
||||
// section.set("road.width", roadWidth);
|
||||
// try {
|
||||
// PS.get().worlds.save(PS.get().worldsFile);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// final SetupObject object = new SetupObject();
|
||||
// object.world = world;
|
||||
// object.plotManager = PS.imp().getPluginName();
|
||||
// object.setupGenerator = PS.imp().getPluginName();
|
||||
// String created = SetupUtils.manager.setupWorld(object);
|
||||
// }
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
private final PlotArea area;
|
||||
|
||||
public PlotRegionFilter(PlotArea area) {
|
||||
checkNotNull(area);
|
||||
this.area = area;
|
||||
}
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
||||
for (Plot plot : plots) {
|
||||
Location bottom = plot.getCorners()[0];
|
||||
Location top = plot.getCorners()[1];
|
||||
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
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;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "generatebiome",
|
||||
permission = "plots.generatebiome",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Generate a biome in your plot",
|
||||
aliases = {"bg", "gb"},
|
||||
usage = "/plots generatebiome <biome>"
|
||||
)
|
||||
public class PlotSetBiome extends Command {
|
||||
public PlotSetBiome() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);
|
||||
if (plot.getRunning() != 0) {
|
||||
Captions.WAIT_FOR_TIMER.send(player);
|
||||
return null;
|
||||
}
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Set<CuboidRegion> regions = plot.getRegions();
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Collection<BiomeType> knownBiomes = BiomeTypes.values();
|
||||
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
|
||||
if (biome == null) {
|
||||
String biomes = StringMan
|
||||
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
|
||||
Captions.NEED_BIOME.send(player);
|
||||
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
confirm.run(this, () -> {
|
||||
if (plot.getRunning() != 0) {
|
||||
Captions.WAIT_FOR_TIMER.send(player);
|
||||
return;
|
||||
}
|
||||
plot.addRunning();
|
||||
TaskManager.IMP.async(() -> {
|
||||
EditSession session = new EditSessionBuilder(FaweAPI.getWorld(plot.getArea().worldname))
|
||||
.autoQueue(false)
|
||||
.checkMemory(false)
|
||||
.allowedRegionsEverywhere()
|
||||
.player(Fawe.imp().wrap(player.getUUID()))
|
||||
.limitUnlimited()
|
||||
.build();
|
||||
long seed = ThreadLocalRandom.current().nextLong();
|
||||
for (CuboidRegion region : regions) {
|
||||
session.regenerate(region, biome, seed);
|
||||
}
|
||||
session.flushQueue();
|
||||
plot.removeRunning();
|
||||
});
|
||||
}, null);
|
||||
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
package com.boydti.fawe.regions.general.integrations.plotquared;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PlotSquaredFeature extends FaweMaskManager {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class);
|
||||
|
||||
public PlotSquaredFeature() {
|
||||
super("PlotSquared");
|
||||
log.debug("Optimizing PlotSquared");
|
||||
if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) {
|
||||
Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false;
|
||||
try {
|
||||
setupBlockQueue();
|
||||
setupSchematicHandler();
|
||||
setupChunkManager();
|
||||
} catch (Throwable ignored) {
|
||||
log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
|
||||
}
|
||||
if (Settings.PLATFORM.toLowerCase().startsWith("bukkit")) {
|
||||
new FaweTrim();
|
||||
}
|
||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||
new PlotSetBiome();
|
||||
}
|
||||
}
|
||||
// TODO: revisit this later on
|
||||
/*
|
||||
try {
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
new ReplaceAll();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.debug("You need to update PlotSquared to access the CFI and REPLACEALL commands");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
return UUIDHandler.getName(uuid);
|
||||
}
|
||||
|
||||
private void setupBlockQueue() throws RuntimeException {
|
||||
// If it's going to fail, throw an error now rather than later
|
||||
QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
|
||||
GlobalBlockQueue.IMP.setProvider(provider);
|
||||
HybridPlotManager.REGENERATIVE_CLEAR = false;
|
||||
log.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
|
||||
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
|
||||
}
|
||||
|
||||
private void setupChunkManager() throws RuntimeException {
|
||||
ChunkManager.manager = new FaweChunkManager(ChunkManager.manager);
|
||||
log.debug(" - ChunkManager: " + ChunkManager.manager);
|
||||
}
|
||||
|
||||
private void setupSchematicHandler() throws RuntimeException {
|
||||
SchematicHandler.manager = new FaweSchematicHandler();
|
||||
log.debug(" - SchematicHandler: " + SchematicHandler.manager);
|
||||
}
|
||||
|
||||
public boolean isAllowed(Player player, Plot plot, MaskType type) {
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
UUID uid = player.getUniqueId();
|
||||
return !Flags.NO_WORLDEDIT.isTrue(plot) && (plot.isOwner(uid)
|
||||
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
|
||||
.contains(DBFunc.EVERYONE)
|
||||
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
|
||||
&& player.hasPermission("fawe.plotsquared.member")) || player
|
||||
.hasPermission("fawe.plotsquared.admin"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(Player player, MaskType type) {
|
||||
final PlotPlayer pp = PlotPlayer.wrap(player.getUniqueId());
|
||||
final Set<CuboidRegion> regions;
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (isAllowed(player, plot, type)) {
|
||||
regions = plot.getRegions();
|
||||
} else {
|
||||
plot = null;
|
||||
regions = WEManager.getMask(pp);
|
||||
if (regions.size() == 1) {
|
||||
CuboidRegion region = regions.iterator().next();
|
||||
if (region.getMinimumPoint().getX() == Integer.MIN_VALUE && region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
|
||||
regions.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
PlotArea area = pp.getApplicablePlotArea();
|
||||
int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
|
||||
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
|
||||
final HashSet<RegionWrapper> faweRegions = new HashSet<>();
|
||||
for (CuboidRegion current : regions) {
|
||||
faweRegions.add(new RegionWrapper(current.getMinimumX(), current.getMaximumX(), min, max, current.getMinimumZ(), current.getMaximumZ()));
|
||||
}
|
||||
final CuboidRegion region = regions.iterator().next();
|
||||
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
|
||||
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
|
||||
final Plot finalPlot = plot;
|
||||
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot) || regions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Region maskedRegion;
|
||||
if (regions.size() == 1) {
|
||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||
} else {
|
||||
World world = FaweAPI.getWorld(area.worldname);
|
||||
List<Region> weRegions = regions.stream()
|
||||
.map(r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())))
|
||||
.collect(Collectors.toList());
|
||||
maskedRegion = new RegionIntersection(world, weRegions);
|
||||
}
|
||||
|
||||
return new FaweMask(maskedRegion) {
|
||||
@Override
|
||||
public boolean isValid(Player player, MaskType type) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) {
|
||||
return false;
|
||||
}
|
||||
return isAllowed(player, finalPlot, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||
if (area != null) return new PlotRegionFilter(area);
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
package com.boydti.fawe.regions.general.plot;
|
||||
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.wrappers.FakePlayer;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "replaceall",
|
||||
permission = "plots.replaceall",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Replace all block in the plot",
|
||||
usage = "/plots replaceall <from> <to>"
|
||||
)
|
||||
public class ReplaceAll extends Command {
|
||||
public ReplaceAll() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length >= 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()), Captions.NOW_OWNER);
|
||||
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
||||
final PlotArea area = plot.getArea();
|
||||
if (area instanceof SinglePlotArea) {
|
||||
plot.addRunning();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(player.getName());
|
||||
Captions.TASK_START.send(player);
|
||||
TaskManager.IMP.async(() -> fp.runAction(() -> {
|
||||
String worldName = plot.getWorldName();
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
SetupUtils.manager.unload(worldName, true);
|
||||
}
|
||||
});
|
||||
FakePlayer actor = FakePlayer.getConsole();
|
||||
String cmd = "/replaceallpattern " + worldName + " " + StringMan.join(args, " ");
|
||||
CommandEvent event = new CommandEvent(actor, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
plot.teleportPlayer(player);
|
||||
}
|
||||
});
|
||||
plot.removeRunning();
|
||||
}, true, false));
|
||||
} else {
|
||||
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user