Add and apply .editorconfig from P2 (#1195)

* Consistenty use javax annotations.
 - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax
 - Cleaning up of import order in #1195
 - Must be merged before #1195

* Add and apply .editorconfig from P2
 - Does not rearrange entries

* Address some comments

* add back some javadoc comments

* Address final comments

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -1,7 +1,7 @@
package com.fastasyncworldedit.core;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.core.util.CachedTextureUtil;
import com.fastasyncworldedit.core.util.CleanTextureUtil;
import com.fastasyncworldedit.core.util.FaweTimer;
@ -16,6 +16,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import javax.management.InstanceAlreadyExistsException;
import javax.management.NotificationEmitter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@ -29,28 +32,25 @@ import java.lang.management.MemoryUsage;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.management.InstanceAlreadyExistsException;
import javax.management.NotificationEmitter;
/**
* [ WorldEdit action]
* |
* |
* \|/
* [ EditSession ] - The change is processed (area restrictions, change limit, block type)
* |
* |
* \|/
* [Block change] - A block change from some location
* |
* |
* \|/
* [ Set Queue ] - The SetQueue manages the implementation specific queue
* |
* |
* \|/
* [ Fawe Queue] - A queue of chunks - check if the queue has the chunk for a change
* |
* |
* \|/
* [ Fawe Chunk Implementation ] - Otherwise create a new FaweChunk object which is a wrapper around the Chunk object
* |
* |
* \|/
* [ Execution ] - When done, the queue then sets the blocks for the chunk, performs lighting updates and sends the chunk packet to the clients
* <p>
@ -131,10 +131,18 @@ public class Fawe {
TaskManager.IMP = this.implementation.getTaskManager();
TaskManager.IMP.async(() -> {
MainUtil.deleteOlder(MainUtil.getFile(this.implementation
.getDirectory(), Settings.IMP.PATHS.HISTORY), TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS), false);
MainUtil.deleteOlder(MainUtil.getFile(this.implementation
.getDirectory(), Settings.IMP.PATHS.CLIPBOARD), TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS), false);
MainUtil.deleteOlder(
MainUtil.getFile(this.implementation
.getDirectory(), Settings.IMP.PATHS.HISTORY),
TimeUnit.DAYS.toMillis(Settings.IMP.HISTORY.DELETE_AFTER_DAYS),
false
);
MainUtil.deleteOlder(
MainUtil.getFile(this.implementation
.getDirectory(), Settings.IMP.PATHS.CLIPBOARD),
TimeUnit.DAYS.toMillis(Settings.IMP.CLIPBOARD.DELETE_AFTER_DAYS),
false
);
});
/*
@ -208,7 +216,6 @@ public class Fawe {
/**
* The FAWE version.
*
* @apiNote Unofficial jars may be lacking version information
* @return FaweVersion
*/
@Nullable
@ -226,7 +233,7 @@ public class Fawe {
File file = new File(this.implementation.getDirectory(), "config.yml");
Settings.IMP.PLATFORM = implementation.getPlatform().replace("\"", "");
try (InputStream stream = getClass().getResourceAsStream("/fawe.properties");
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
String versionString = br.readLine();
String commitString = br.readLine();
String dateString = br.readLine();
@ -263,14 +270,14 @@ public class Fawe {
Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL);
LOGGER.error("ZSTD Compression Binding Not Found.\n"
+ "FAWE will still work but compression won't work as well.\n", e);
+ "FAWE will still work but compression won't work as well.\n", e);
}
}
try {
net.jpountz.util.Native.load();
} catch (Throwable e) {
LOGGER.error("LZ4 Compression Binding Not Found.\n"
+ "FAWE will still work but compression will be slower.\n", e);
+ "FAWE will still work but compression will be slower.\n", e);
}
}
@ -313,8 +320,8 @@ public class Fawe {
}
} catch (Throwable ignored) {
LOGGER.error("FAWE encountered an error trying to listen to JVM memory.\n"
+ "Please change your Java security settings or disable this message by"
+ "changing 'max-memory-percent' in the config files to '-1'.");
+ "Please change your Java security settings or disable this message by"
+ "changing 'max-memory-percent' in the config files to '-1'.");
}
}
@ -335,4 +342,5 @@ public class Fawe {
public Thread setMainThread() {
return this.thread = Thread.currentThread();
}
}

View File

@ -1,16 +1,16 @@
package com.fastasyncworldedit.core;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
import com.fastasyncworldedit.core.queue.implementation.ParallelQueueExtent;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
import com.fastasyncworldedit.core.history.DiskStorageHistory;
import com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.fastasyncworldedit.core.queue.implementation.ParallelQueueExtent;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.util.EditSessionBuilder;
import com.fastasyncworldedit.core.util.MainUtil;
import com.fastasyncworldedit.core.util.MemUtil;
@ -88,7 +88,7 @@ public class FaweAPI {
* EditSession} can do a lot more. Remember to commit when you are done!
* </p>
*
* @param world The name of the world
* @param world The name of the world
* @param autoQueue If it should start dispatching before you enqueue it.
* @return the queue extent
*/
@ -115,7 +115,7 @@ public class FaweAPI {
* Upload the clipboard to the configured web interface.
*
* @param clipboard The clipboard (may not be null)
* @param format The format to use (some formats may not be supported)
* @param format The format to use (some formats may not be supported)
* @return The download URL or null
*/
public static URL upload(final Clipboard clipboard, final ClipboardFormat format) {
@ -192,7 +192,7 @@ public class FaweAPI {
if (!file.getName().toLowerCase(Locale.ROOT).endsWith(".bd")) {
throw new IllegalArgumentException("Not a BD file!");
}
String[] path = file.getPath().split(File.separatorChar=='\\' ? "\\\\" : File.separator);
String[] path = file.getPath().split(File.separatorChar == '\\' ? "\\\\" : File.separator);
if (path.length < 3) {
throw new IllegalArgumentException("Not in history directory!");
}
@ -214,16 +214,13 @@ public class FaweAPI {
/**
* Used in the rollback to generate a list of {@link DiskStorageHistory} objects.
*
* @param origin - The origin location
* @param user - The uuid (may be null)
* @param radius - The radius from the origin of the edit
* @param origin - The origin location
* @param user - The uuid (may be null)
* @param radius - The radius from the origin of the edit
* @param timediff - The max age of the file in milliseconds
* @param shallow - If shallow is true, FAWE will only read the first {@link
* Settings.HISTORY#BUFFER_SIZE} bytes to obtain history info
* @param shallow - If shallow is true, FAWE will only read the first {@link
* Settings.HISTORY#BUFFER_SIZE} bytes to obtain history info
* @return a list of DiskStorageHistory Objects
* @apiNote An edit outside the radius may be included if it overlaps with an edit inside
* that depends on it. Reading only part of the file will result in unreliable bounds info
* for large edits.
*/
public static List<DiskStorageHistory> getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) {
Extent extent = origin.getExtent();
@ -270,7 +267,12 @@ public class FaweAPI {
long value = aI - bI;
return value == 0 ? 0 : value < 0 ? -1 : 1;
});
RegionWrapper bounds = new RegionWrapper(origin.getBlockX() - radius, origin.getBlockX() + radius, origin.getBlockZ() - radius, origin.getBlockZ() + radius);
RegionWrapper bounds = new RegionWrapper(
origin.getBlockX() - radius,
origin.getBlockX() + radius,
origin.getBlockZ() - radius,
origin.getBlockZ() + radius
);
RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512);
HashSet<RegionWrapper> regionSet = Sets.<RegionWrapper>newHashSet(bounds);
ArrayList<DiskStorageHistory> result = new ArrayList<>();
@ -302,7 +304,6 @@ public class FaweAPI {
/**
* The DiskStorageHistory class is what FAWE uses to represent the undo on disk.
*
*/
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
return new DiskStorageHistory(world, uuid, index);
@ -317,13 +318,18 @@ public class FaweAPI {
* <li>Resends the chunks to the client.</li>
* </ol>
*
* @param world World to relight in
* @param world World to relight in
* @param selection Region to relight
* @param queue Queue to relight in/from
* @param mode The mode to relight with
* @param queue Queue to relight in/from
* @param mode The mode to relight with
* @return Chunks changed
*/
public static int fixLighting(World world, Region selection, @Nullable IQueueExtent<IQueueChunk> queue, final RelightMode mode) {
public static int fixLighting(
World world,
Region selection,
@Nullable IQueueExtent<IQueueChunk> queue,
final RelightMode mode
) {
final BlockVector3 bot = selection.getMinimumPoint();
final BlockVector3 top = selection.getMaximumPoint();
@ -341,7 +347,7 @@ public class FaweAPI {
queue = (IQueueExtent) unwrapped;
} else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1) {
ParallelQueueExtent parallel =
new ParallelQueueExtent(Fawe.get().getQueueHandler(), world, true);
new ParallelQueueExtent(Fawe.get().getQueueHandler(), world, true);
queue = parallel.getExtent();
} else {
queue = Fawe.get().getQueueHandler().getQueue(world);

View File

@ -1,18 +1,20 @@
package com.fastasyncworldedit.core;
import com.fastasyncworldedit.core.queue.IChunkSet;
import com.fastasyncworldedit.core.queue.Trimable;
import com.fastasyncworldedit.core.queue.Pool;
import com.fastasyncworldedit.core.queue.implementation.QueuePool;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.math.BitArray;
import com.fastasyncworldedit.core.math.BitArrayUnstretched;
import com.fastasyncworldedit.core.util.collection.CleanableThreadLocal;
import com.fastasyncworldedit.core.internal.exception.FaweBlockBagException;
import com.fastasyncworldedit.core.internal.exception.FaweChunkLoadException;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.fastasyncworldedit.core.math.BitArray;
import com.fastasyncworldedit.core.math.BitArrayUnstretched;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.fastasyncworldedit.core.queue.IChunkSet;
import com.fastasyncworldedit.core.queue.Pool;
import com.fastasyncworldedit.core.queue.Trimable;
import com.fastasyncworldedit.core.queue.implementation.QueuePool;
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.collection.CleanableThreadLocal;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -31,12 +33,10 @@ import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -59,8 +59,7 @@ import java.util.function.Supplier;
import static com.google.common.base.Preconditions.checkNotNull;
public enum FaweCache implements Trimable {
IMP
; // singleton
IMP; // singleton
private static final Logger LOGGER = LogManagerCompat.getLogger();
@ -140,13 +139,16 @@ public enum FaweCache implements Trimable {
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
public static final FaweException MANUAL = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.manual"));
public static final FaweException NO_REGION = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.no.region"));
public static final FaweException OUTSIDE_REGION = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
public static final FaweException OUTSIDE_REGION = new FaweException(Caption.of(
"fawe.cancel.worldedit.cancel.reason.outside.region"));
public static final FaweException MAX_CHECKS = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.max.checks"));
public static final FaweException MAX_CHANGES = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.max.changes"));
public static final FaweException LOW_MEMORY = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.low.memory"));
public static final FaweException MAX_ENTITIES = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.max.entities"));
public static final FaweException MAX_ENTITIES = new FaweException(Caption.of(
"fawe.cancel.worldedit.cancel.reason.max.entities"));
public static final FaweException MAX_TILES = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.max.tiles"));
public static final FaweException MAX_ITERATIONS = new FaweException(Caption.of("fawe.cancel.worldedit.cancel.reason.max.iterations"));
public static final FaweException MAX_ITERATIONS = new FaweException(Caption.of(
"fawe.cancel.worldedit.cancel.reason.max.iterations"));
/*
thread cache
@ -167,9 +169,9 @@ public enum FaweCache implements Trimable {
public final CleanableThreadLocal<int[]> PALETTE_TO_BLOCK = new CleanableThreadLocal<>(() -> new int[Character.MAX_VALUE + 1]);
public final CleanableThreadLocal<char[]> PALETTE_TO_BLOCK_CHAR = new CleanableThreadLocal<>(
() -> new char[Character.MAX_VALUE + 1], a -> {
Arrays.fill(a, Character.MAX_VALUE);
}
() -> new char[Character.MAX_VALUE + 1], a -> {
Arrays.fill(a, Character.MAX_VALUE);
}
);
public final CleanableThreadLocal<long[]> BLOCK_STATES = new CleanableThreadLocal<>(() -> new long[2048]);
@ -182,6 +184,7 @@ public enum FaweCache implements Trimable {
* Holds data for a palette used in a chunk section
*/
public static final class Palette {
public int bitsPerEntry;
public int paletteToBlockLength;
@ -195,12 +198,14 @@ public enum FaweCache implements Trimable {
* Reusable buffer array, MUST check blockStatesLength for actual length
*/
public long[] blockStates;
}
private final CleanableThreadLocal<Palette> PALETTE_CACHE = new CleanableThreadLocal<>(Palette::new);
/**
* Convert raw char array to palette
*
* @param layerOffset
* @param blocks
* @return palette
@ -211,6 +216,7 @@ public enum FaweCache implements Trimable {
/**
* Convert raw int array to palette
*
* @param layerOffset
* @param blocks
* @return palette
@ -296,6 +302,7 @@ public enum FaweCache implements Trimable {
/**
* Convert raw int array to unstretched palette (1.16)
*
* @param layerOffset
* @param blocks
* @return palette
@ -531,9 +538,10 @@ public enum FaweCache implements Trimable {
int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads);
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS, queue,
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy()) {
0L, TimeUnit.MILLISECONDS, queue,
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy()
) {
protected void afterExecute(Runnable r, Throwable t) {
try {
super.afterExecute(r, t);

View File

@ -1,7 +1,10 @@
package com.fastasyncworldedit.core;
/** An internal FAWE class not meant for public use. **/
/**
* An internal FAWE class not meant for public use.
**/
public class FaweVersion {
public final int year;
public final int month;
public final int day;
@ -40,7 +43,8 @@ public class FaweVersion {
}
}
@Override public String toString() {
@Override
public String toString() {
if (hash == 0 && build == 0) {
return "FastAsyncWorldEdit-1.17-NoVer-SNAPSHOT";
} else {
@ -51,4 +55,5 @@ public class FaweVersion {
public boolean isNewer(FaweVersion other) {
return other.build < this.build;
}
}

View File

@ -1,7 +1,7 @@
package com.fastasyncworldedit.core;
import com.fastasyncworldedit.core.queue.implementation.preloader.Preloader;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.core.queue.implementation.preloader.Preloader;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.image.ImageViewer;

View File

@ -3,4 +3,5 @@ package com.fastasyncworldedit.core;
public interface Resettable {
void reset();
}

View File

@ -21,11 +21,10 @@ import java.io.IOException;
import static com.google.common.base.Preconditions.checkNotNull;
/**
*
* @deprecated Anvil classes were used on versions prior to 1.13 to trim chunks.
* The way how it's been done was unsafe and led to issues back the years, hence it
* hasn't been implemented in any modern version. Therefore the current
* implementation is deprecated for removal without replacement.
* The way how it's been done was unsafe and led to issues back the years, hence it
* hasn't been implemented in any modern version. Therefore the current
* implementation is deprecated for removal without replacement.
*/
@Deprecated
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
@ -117,17 +116,19 @@ public class AnvilCommands {
// }
@Command(
name = "replaceall",
aliases = {"rea", "repall"},
desc = "Replace all blocks in the selection with another"
name = "replaceall",
aliases = {"rea", "repall"},
desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAll(Player player, String folder,
@Arg(name = "from", desc = "String", def = "")
String fromPattern,
String toPatternStr,
@Switch(name = 'd', desc = "Disable wildcard data matching")
boolean useData) throws WorldEditException {
public void replaceAll(
Player player, String folder,
@Arg(name = "from", desc = "String", def = "")
String fromPattern,
String toPatternStr,
@Switch(name = 'd', desc = "Disable wildcard data matching")
boolean useData
) throws WorldEditException {
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
// if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR;
@ -144,9 +145,9 @@ public class AnvilCommands {
}
@Command(
name = "remapall",
descFooter = "Remap the world between MCPE/PC values",
desc = "Remap the world between MCPE/PC values"
name = "remapall",
descFooter = "Remap the world between MCPE/PC values",
desc = "Remap the world between MCPE/PC values"
)
@CommandPermissions("worldedit.anvil.remapall")
public void remapall(Player player, String folder) throws WorldEditException {
@ -163,18 +164,20 @@ public class AnvilCommands {
@Command(
name = "deleteallunvisited",
aliases = {"delunvisited" },
desc = "Delete all chunks which haven't been occupied",
descFooter = "occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
name = "deleteallunvisited",
aliases = {"delunvisited"},
desc = "Delete all chunks which haven't been occupied",
descFooter = "occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
)
@CommandPermissions("worldedit.anvil.deleteallunvisited")
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis) throws WorldEditException {
public void deleteAllUnvisited(
Player player, String folder, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis
) throws WorldEditException {
// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) {
@ -183,21 +186,23 @@ public class AnvilCommands {
}
@Command(
name = "deleteallunclaimed",
aliases = {"delallunclaimed" },
desc = "Delete all chunks which haven't been occupied",
descFooter = "Supports: WorldGuard, PlotSquared, GriefPrevention:\n"
+ "Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
name = "deleteallunclaimed",
aliases = {"delallunclaimed"},
desc = "Delete all chunks which haven't been occupied",
descFooter = "Supports: WorldGuard, PlotSquared, GriefPrevention:\n"
+ "Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
)
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
public void deleteAllUnclaimed(Player player, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis,
@Switch(name = 'd', desc = "The flag will debug the task")
boolean debug) throws WorldEditException {
public void deleteAllUnclaimed(
Player player, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis,
@Switch(name = 'd', desc = "The flag will debug the task")
boolean debug
) throws WorldEditException {
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
// if (debug) {
@ -210,21 +215,23 @@ public class AnvilCommands {
}
@Command(
name = "deleteunclaimed",
desc = "Delete all chunks which haven't been occupied",
descFooter = "(Supports: WorldGuard, PlotSquared, GriefPrevention):\n"
+ "Is not claimed\n"
+ "Has not been occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
name = "deleteunclaimed",
desc = "Delete all chunks which haven't been occupied",
descFooter = "(Supports: WorldGuard, PlotSquared, GriefPrevention):\n"
+ "Is not claimed\n"
+ "Has not been occupied for `age-ticks` (20t = 1s) and \n"
+ "Have not been accessed since `file-duration` (ms) after creation and\n"
+ "Have not been used in the past `chunk-inactivity` (ms)"
+ "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
)
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis,
@Switch(name = 'd', desc = "The flag will debug the task")
boolean debug) throws WorldEditException {
public void deleteUnclaimed(
Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks,
@Arg(desc = "int", def = "60000")
int fileDurationMillis,
@Switch(name = 'd', desc = "The flag will debug the task")
boolean debug
) throws WorldEditException {
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
// if (debug) {
// filter.enableDebug();
@ -236,11 +243,11 @@ public class AnvilCommands {
}
@Command(
name = "deletealloldregions",
aliases = {"deloldreg" },
desc = "Delete regions which haven't been accessed in a certain amount of time",
descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n"
+ "(months are not a unit of time) e.g., 8h5m12s\n"
name = "deletealloldregions",
aliases = {"deloldreg"},
desc = "Delete regions which haven't been accessed in a certain amount of time",
descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n"
+ "(months are not a unit of time) e.g., 8h5m12s\n"
)
@CommandPermissions("worldedit.anvil.deletealloldregions")
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
@ -253,14 +260,16 @@ public class AnvilCommands {
}
@Command(
name = "trimallplots",
desc = "Trim chunks in a Plot World",
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
name = "trimallplots",
desc = "Trim chunks in a Plot World",
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
)
@CommandPermissions("worldedit.anvil.trimallplots")
public void trimAllPlots(Player player,
@Switch(name = 'v', desc = "Delete unvisited chunks")
boolean deleteUnvisited) throws WorldEditException {
public void trimAllPlots(
Player player,
@Switch(name = 'v', desc = "Delete unvisited chunks")
boolean deleteUnvisited
) throws WorldEditException {
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
// int visitTime = deleteUnvisited ? 1 : -1;
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
@ -274,13 +283,15 @@ public class AnvilCommands {
}
@Command(
name = "deletebiomechunks",
desc = "Delete chunks matching a specific biome"
name = "deletebiomechunks",
desc = "Delete chunks matching a specific biome"
)
@CommandPermissions("worldedit.anvil.trimallair")
public void deleteBiome(Player player, String folder, BiomeType biome,
@Switch(name = 'u', desc = "The flag will run the task unsafe")
boolean unsafe) {
public void deleteBiome(
Player player, String folder, BiomeType biome,
@Switch(name = 'u', desc = "The flag will run the task unsafe")
boolean unsafe
) {
// DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED
// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) {
@ -289,13 +300,15 @@ public class AnvilCommands {
}
@Command(
name = "trimallair",
desc = "Trim all air in the world"
name = "trimallair",
desc = "Trim all air in the world"
)
@CommandPermissions("worldedit.anvil.trimallair")
public void trimAllAir(Player player, String folder,
@Switch(name = 'u', desc = "The flag will run the task unsafe")
boolean unsafe) throws WorldEditException {
public void trimAllAir(
Player player, String folder,
@Switch(name = 'u', desc = "The flag will run the task unsafe")
boolean unsafe
) throws WorldEditException {
// TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED
// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) {
@ -304,8 +317,8 @@ public class AnvilCommands {
}
@Command(
name = "debugfixroads",
desc = "debug - do not use"
name = "debugfixroads",
desc = "debug - do not use"
)
@CommandPermissions("worldedit.anvil.debugfixroads")
public void debugfixroads(Player player, String folder) throws WorldEditException {
@ -317,18 +330,20 @@ public class AnvilCommands {
}
@Command(
name = "replaceallpattern",
aliases = {"reap", "repallpat"},
desc = "Replace all blocks in the selection with another"
name = "replaceallpattern",
aliases = {"reap", "repallpat"},
desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAllPattern(Player player, String folder,
@Arg(desc = "String", def = "")
String from, Pattern toPattern,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData,
@Switch(name = 'm', desc = "The flag specifies the map to use")
boolean useMap) throws WorldEditException {
public void replaceAllPattern(
Player player, String folder,
@Arg(desc = "String", def = "")
String from, Pattern toPattern,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData,
@Switch(name = 'm', desc = "The flag specifies the map to use")
boolean useMap
) throws WorldEditException {
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) {
// if (to instanceof RandomPattern) {
@ -353,13 +368,15 @@ public class AnvilCommands {
//
@Command(
name = "countall",
desc = "Count all blocks in a world"
name = "countall",
desc = "Count all blocks in a world"
)
@CommandPermissions("worldedit.anvil.countall")
public void countAll(Player player, EditSession editSession, String folder, String argStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData) throws WorldEditException {
public void countAll(
Player player, EditSession editSession, String folder, String argStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData
) throws WorldEditException {
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
// MCAFilterCounter filter;
// if (useData || arg.contains(":")) { // Optimize for both cases
@ -376,9 +393,9 @@ public class AnvilCommands {
}
@Command(
name = "clear",
aliases = {"unset"},
desc = "Clear the chunks in a selection (delete without defrag)"
name = "clear",
aliases = {"unset"},
desc = "Clear the chunks in a selection (delete without defrag)"
)
@CommandPermissions("worldedit.anvil.clear")
public void unset(Player player, EditSession editSession, @Selection Region selection) throws WorldEditException {
@ -429,13 +446,15 @@ public class AnvilCommands {
}
@Command(
name = "count",
desc = "Count blocks in a selection"
name = "count",
desc = "Count blocks in a selection"
)
@CommandPermissions("worldedit.anvil.count")
public void count(Player player, EditSession editSession, @Selection Region selection, String argStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData) throws WorldEditException {
public void count(
Player player, EditSession editSession, @Selection Region selection, String argStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData
) throws WorldEditException {
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
// MCAFilterCounter filter;
// if (useData || arg.contains(":")) { // Optimize for both cases
@ -453,13 +472,15 @@ public class AnvilCommands {
//
@Command(
name = "distr",
desc = "Replace all blocks in the selection with another"
name = "distr",
desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.distr")
public void distr(Player player, EditSession editSession, @Selection Region selection,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData) throws WorldEditException {
public void distr(
Player player, EditSession editSession, @Selection Region selection,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData
) throws WorldEditException {
// long total = 0; TODO NOT IMPLEMENTED
// long[] count;
// MCAFilter<long[]> counts;
@ -533,16 +554,18 @@ public class AnvilCommands {
//
@Command(
name = "replace",
aliases = {"r"},
desc = "Replace all blocks in the selection with another"
name = "replace",
aliases = {"r"},
desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.replace")
public void replace(Player player, EditSession editSession, @Selection Region selection,
@Arg(desc = "String", def = "")
String from, String toStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData) throws WorldEditException {
public void replace(
Player player, EditSession editSession, @Selection Region selection,
@Arg(desc = "String", def = "")
String from, String toStr,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData
) throws WorldEditException {
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
// if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR;
@ -559,18 +582,20 @@ public class AnvilCommands {
//
@Command(
name = "replacepattern",
aliases = {"preplace", "rp"},
desc = "Replace all blocks in the selection with a pattern"
name = "replacepattern",
aliases = {"preplace", "rp"},
desc = "Replace all blocks in the selection with a pattern"
)
@CommandPermissions("worldedit.anvil.replace")
public void replacePattern(Player player, EditSession editSession, @Selection Region selection,
@Arg(desc = "String", def = "")
String from, final Pattern toPattern,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData,
@Switch(name = 'm', desc = "The flag specifies the map to use")
boolean useMap) throws WorldEditException {
public void replacePattern(
Player player, EditSession editSession, @Selection Region selection,
@Arg(desc = "String", def = "")
String from, final Pattern toPattern,
@Switch(name = 'd', desc = "The flag specifies the data to use")
boolean useData,
@Switch(name = 'm', desc = "The flag specifies the map to use")
boolean useMap
) throws WorldEditException {
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) {
// if (to instanceof RandomPattern) {
@ -596,12 +621,13 @@ public class AnvilCommands {
}
@Command(
name = "set",
desc = "Set all blocks in the selection with a pattern"
name = "set",
desc = "Set all blocks in the selection with a pattern"
)
@CommandPermissions("worldedit.anvil.set")
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "The flag specifies the data to use") boolean useData, @Switch(name = 'm', desc = "The flag specifies the map to use") boolean useMap
public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException {
public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws
WorldEditException {
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) {
@ -610,12 +636,13 @@ public class AnvilCommands {
}
@Command(
name = "removelayers",
desc = "Removes matching chunk layers",
descFooter = "Only if a chunk matches the provided id"
name = "removelayers",
desc = "Removes matching chunk layers",
descFooter = "Only if a chunk matches the provided id"
)
@CommandPermissions("worldedit.anvil.removelayer")
public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws WorldEditException {
public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws
WorldEditException {
// BlockVector3 min = selection.getMinimumPoint(); TODO NOT IMPLEMENTED
// BlockVector3 max = selection.getMaximumPoint();
// int minY = min.getBlockY();
@ -629,11 +656,12 @@ public class AnvilCommands {
@Command(
name = "copy",
desc = "Lazily copy chunks to your anvil clipboard"
name = "copy",
desc = "Lazily copy chunks to your anvil clipboard"
)
@CommandPermissions("worldedit.anvil.copychunks")
public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException {
public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws
WorldEditException {
// if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED
// player.print(TranslatableComponent.of("fawe.error.no.region"))
// return;
@ -650,14 +678,16 @@ public class AnvilCommands {
}
@Command(
name = "paste",
desc = "Paste chunks from your anvil clipboard",
descFooter = "Paste the chunks from your anvil clipboard."
name = "paste",
desc = "Paste chunks from your anvil clipboard",
descFooter = "Paste the chunks from your anvil clipboard."
)
@CommandPermissions("worldedit.anvil.pastechunks")
public void paste(Player player, LocalSession session, EditSession editSession,
@Switch(name = 'c', desc = "Align to chunks")
boolean alignChunk) throws WorldEditException, IOException {
public void paste(
Player player, LocalSession session, EditSession editSession,
@Switch(name = 'c', desc = "Align to chunks")
boolean alignChunk
) throws WorldEditException, IOException {
// FawePlayer fp = FawePlayer.wrap(player); TODO NOT IMPLEMENTED
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
// if (clipboard == null) {
@ -686,4 +716,5 @@ public class AnvilCommands {
// });
// player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste", player.getPosition().toBlockVector()));
}
}

View File

@ -15,7 +15,9 @@ import java.util.regex.PatternSyntaxException;
//@CommandContainer
public class ListFilters {
public class Filter {
public boolean listPrivate() {
return true;
}
@ -31,6 +33,7 @@ public class ListFilters {
public boolean applies(File file) {
return true;
}
}
@Command(
@ -128,4 +131,5 @@ public class ListFilters {
};
}
}
}

View File

@ -80,4 +80,5 @@ public class SuggestInputParseException extends InputParseException {
this.prefix = input + prefix;
return this;
}
}

View File

@ -3,5 +3,7 @@ package com.fastasyncworldedit.core.command.tool;
import com.sk89q.worldedit.entity.Player;
public interface MovableTool {
boolean move(Player player);
}

View File

@ -1,5 +1,7 @@
package com.fastasyncworldedit.core.command.tool;
public interface ResettableTool {
boolean reset();
}

View File

@ -18,7 +18,8 @@ public class AngleBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
SurfaceMask surface = new SurfaceMask(editSession);
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);
@ -26,4 +27,5 @@ public class AngleBrush implements Brush {
// replace \[angle]
}
}

View File

@ -13,7 +13,8 @@ import java.util.Arrays;
public class BlendBall implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
final int outsetSize = (int) (size + 1);
double brushSizeSquared = size * size;

View File

@ -1,5 +1,6 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.fastasyncworldedit.core.math.random.SimplexNoise;
import com.fastasyncworldedit.core.util.MathMan;
import com.sk89q.worldedit.EditSession;
@ -7,13 +8,13 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import java.util.concurrent.ThreadLocalRandom;
public class BlobBrush implements Brush {
private final double amplitude;
private final double frequency;
private final Vector3 radius;
@ -27,7 +28,8 @@ public class BlobBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
double seedX = ThreadLocalRandom.current().nextDouble();
double seedY = ThreadLocalRandom.current().nextDouble();
double seedZ = ThreadLocalRandom.current().nextDouble();
@ -64,9 +66,9 @@ public class BlobBrush implements Brush {
}
} else {
AffineTransform transform = new AffineTransform()
.rotateX(ThreadLocalRandom.current().nextInt(360))
.rotateY(ThreadLocalRandom.current().nextInt(360))
.rotateZ(ThreadLocalRandom.current().nextInt(360));
.rotateX(ThreadLocalRandom.current().nextInt(360))
.rotateY(ThreadLocalRandom.current().nextInt(360))
.rotateZ(ThreadLocalRandom.current().nextInt(360));
double manScaleX = 1.25 + seedX * 0.5;
double manScaleY = 1.25 + seedY * 0.5;
@ -93,9 +95,18 @@ public class BlobBrush implements Brush {
double manDist = xScaled + yScaled + zScaled;
double distSqr = x * x * modX + z * z * modZ + y * y * modY;
double distance = Math.sqrt(distSqr) * sphericity + MathMan.max(manDist, xScaled * manScaleX, yScaled * manScaleY, zScaled * manScaleZ) * roughness;
double distance = Math.sqrt(distSqr) * sphericity + MathMan.max(
manDist,
xScaled * manScaleX,
yScaled * manScaleY,
zScaled * manScaleZ
) * roughness;
double noise = this.amplitude * SimplexNoise.noise(seedX + x * distort, seedZ + z * distort, seedZ + z * distort);
double noise = this.amplitude * SimplexNoise.noise(
seedX + x * distort,
seedZ + z * distort,
seedZ + z * distort
);
if (distance + distance * noise < radius) {
editSession.setBlock(px + xr, py + yr, pz + zr, pattern);
}
@ -104,4 +115,5 @@ public class BlobBrush implements Brush {
}
}
}
}

View File

@ -19,6 +19,7 @@ import static com.fastasyncworldedit.core.command.tool.brush.BrushSettings.Setti
import static com.google.common.base.Preconditions.checkNotNull;
public class BrushSettings {
public enum SettingType {
BRUSH,
SIZE,
@ -41,7 +42,7 @@ public class BrushSettings {
private ResettableExtent transform;
private Pattern material;
private Expression size = DEFAULT_SIZE;
private Set<String> permissions;
private final Set<String> permissions;
private Scroll scrollAction;
public BrushSettings() {
@ -273,4 +274,5 @@ public class BrushSettings {
name = brush.getClass().getName();
return name.substring(name.lastIndexOf('.') + 1);
}
}

View File

@ -34,7 +34,8 @@ public class CatenaryBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws
MaxChangedBlocksException {
Player player = editSession.getPlayer();
if (player == null) {
return; //todo throw error
@ -90,7 +91,6 @@ public class CatenaryBrush implements Brush, ResettableTool {
double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2;
double a = 0.00001;
for (; g < a * Math.sinh(dh / (2 * a)); a *= 1.00001) {
;
}
double vertX = (dh - a * Math.log((curveLen + dy) / (curveLen - dy))) / 2.0;
double z = (dh / 2) / a;
@ -98,4 +98,5 @@ public class CatenaryBrush implements Brush, ResettableTool {
double vertY = a * 1 + oY;
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();
}
}

View File

@ -19,7 +19,8 @@ public class CircleBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
Player player = editSession.getPlayer();
if (player == null) {
return;
@ -40,4 +41,5 @@ public class CircleBrush implements Brush {
Vector3 random = affine.apply(normal);
return random.cross(normal).normalize();
}
}

View File

@ -26,9 +26,14 @@ public class CommandBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
int radius = (int) size;
CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
CuboidRegionSelector selector = new CuboidRegionSelector(
editSession.getWorld(),
position.subtract(radius, radius, radius),
position.add(radius, radius, radius)
);
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ()))
@ -43,11 +48,15 @@ public class CommandBrush implements Brush {
position = position.add(face.getDirection().toBlockPoint());
}
player.setSelection(selector);
AsyncPlayer wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position.toVector3())));
AsyncPlayer wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(
player,
new Location(player.getExtent(), position.toVector3())
));
List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
}
}
}

View File

@ -49,7 +49,8 @@ public class CopyPastaBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
Player player = editSession.getPlayer();
if (player == null) {
return;
@ -117,4 +118,5 @@ public class CopyPastaBrush implements Brush, ResettableTool {
editSession.flushQueue();
}
}
}

View File

@ -19,7 +19,11 @@ import java.util.Arrays;
public class ErodeBrush implements Brush {
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(Direction::toBlockVector).toArray(BlockVector3[]::new);
private static final BlockVector3[] FACES_TO_CHECK = Direction
.valuesOf(Direction.Flag.CARDINAL)
.stream()
.map(Direction::toBlockVector)
.toArray(BlockVector3[]::new);
private final int erodeFaces;
private final int erodeRecursion;
private final int fillFaces;
@ -37,11 +41,20 @@ public class ErodeBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
this.erosion(editSession, erodeFaces, erodeRecursion, fillFaces, fillRecursion, position, size);
}
public void erosion(final EditSession es, int erodeFaces, int erodeRecursion, int fillFaces, int fillRecursion, BlockVector3 target, double size) {
public void erosion(
final EditSession es,
int erodeFaces,
int erodeRecursion,
int fillFaces,
int fillRecursion,
BlockVector3 target,
double size
) {
int brushSize = (int) size;
int brushSizeSquared = (int) (size * size);
Location min = new Location(es.getWorld(), target.toVector3().subtract(size, size, size));
@ -69,12 +82,24 @@ public class ErodeBrush implements Brush {
int swap = 0;
for (int i = 0; i < erodeRecursion; ++i) {
erosionIteration(brushSize, brushSizeSquared, erodeFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
erosionIteration(
brushSize,
brushSizeSquared,
erodeFaces,
swap % 2 == 0 ? buffer1 : buffer2,
swap % 2 == 1 ? buffer1 : buffer2
);
swap++;
}
for (int i = 0; i < fillRecursion; ++i) {
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
fillIteration(
brushSize,
brushSizeSquared,
fillFaces,
swap % 2 == 0 ? buffer1 : buffer2,
swap % 2 == 1 ? buffer1 : buffer2
);
swap++;
}
Clipboard finalBuffer = swap % 2 == 0 ? buffer1 : buffer2;
@ -85,8 +110,10 @@ public class ErodeBrush implements Brush {
}
}
private void fillIteration(int brushSize, int brushSizeSquared, int fillFaces,
Clipboard current, Clipboard target) {
private void fillIteration(
int brushSize, int brushSizeSquared, int fillFaces,
Clipboard current, Clipboard target
) {
int[] frequency = null;
for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
int x2 = x * x;
@ -111,7 +138,11 @@ public class ErodeBrush implements Brush {
int total = 0;
int highest = 1;
for (BlockVector3 offs : FACES_TO_CHECK) {
BaseBlock next = current.getFullBlock(relx + offs.getBlockX(), rely + offs.getBlockY(), relz + offs.getBlockZ());
BaseBlock next = current.getFullBlock(
relx + offs.getBlockX(),
rely + offs.getBlockY(),
relz + offs.getBlockZ()
);
if (!next.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
@ -130,8 +161,10 @@ public class ErodeBrush implements Brush {
}
}
private void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces,
Clipboard current, Clipboard target) {
private void erosionIteration(
int brushSize, int brushSizeSquared, int erodeFaces,
Clipboard current, Clipboard target
) {
int[] frequency = null;
for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
int x2 = x * x;
@ -156,7 +189,11 @@ public class ErodeBrush implements Brush {
int highest = 1;
int total = 0;
for (BlockVector3 offs : FACES_TO_CHECK) {
BaseBlock next = current.getFullBlock(relx + offs.getBlockX(), rely + offs.getBlockY(), relz + offs.getBlockZ());
BaseBlock next = current.getFullBlock(
relx + offs.getBlockX(),
rely + offs.getBlockY(),
relz + offs.getBlockZ()
);
if (next.getMaterial().isMovementBlocker()) {
continue;
}
@ -174,4 +211,5 @@ public class ErodeBrush implements Brush {
}
}
}
}

View File

@ -8,8 +8,10 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
public class FallingSphere implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
int px = position.getBlockX();
int py = position.getBlockY();
int pz = position.getBlockZ();
@ -54,4 +56,5 @@ public class FallingSphere implements Brush {
}
}
}
}

View File

@ -14,12 +14,21 @@ import java.io.InputStream;
public class FlattenBrush extends HeightBrush {
public FlattenBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard, ScalableHeightMap.Shape shape) {
public FlattenBrush(
InputStream stream,
int rotation,
double yscale,
boolean layers,
boolean smooth,
Clipboard clipboard,
ScalableHeightMap.Shape shape
) {
super(stream, rotation, yscale, layers, smooth, clipboard, shape);
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws
MaxChangedBlocksException {
int size = (int) sizeDouble;
Mask mask = editSession.getMask();
if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
@ -29,4 +38,5 @@ public class FlattenBrush extends HeightBrush {
map.setSize(size);
map.perform(editSession, mask, position, size, rotation, yscale, smooth, true, layers);
}
}

View File

@ -31,7 +31,15 @@ public class HeightBrush implements Brush {
this(stream, rotation, yscale, layers, smooth, clipboard, ScalableHeightMap.Shape.CONE);
}
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard, ScalableHeightMap.Shape shape) {
public HeightBrush(
InputStream stream,
int rotation,
double yscale,
boolean layers,
boolean smooth,
Clipboard clipboard,
ScalableHeightMap.Shape shape
) {
this.rotation = (rotation / 90) % 4;
this.yscale = yscale;
this.layers = layers;
@ -65,7 +73,8 @@ public class HeightBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws
MaxChangedBlocksException {
int size = (int) sizeDouble;
HeightMap map = getHeightMap();
map.setSize(size);
@ -76,4 +85,5 @@ public class HeightBrush implements Brush {
}
map.perform(editSession, mask, position, size, rotation, yscale, smooth, false, layers);
}
}

View File

@ -1,9 +1,9 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.function.mask.ImageBrushMask;
import com.fastasyncworldedit.core.util.collection.SummedColorTable;
import com.fastasyncworldedit.core.function.mask.SurfaceMask;
import com.fastasyncworldedit.core.util.TextureUtil;
import com.fastasyncworldedit.core.util.collection.SummedColorTable;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -12,6 +12,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
@ -23,6 +24,7 @@ import java.io.IOException;
import java.util.Arrays;
public class ImageBrush implements Brush {
private final LocalSession session;
private final SummedColorTable table;
private final int width;
@ -63,11 +65,14 @@ public class ImageBrush implements Brush {
}
public interface ColorFunction {
int call(int x1, int z1, int x2, int z2, Extent extent, BlockVector3 pos);
}
@Override
public void build(EditSession editSession, BlockVector3 center, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 center, Pattern pattern, double sizeDouble) throws
MaxChangedBlocksException {
final Mask solid = new SurfaceMask(editSession);
double scale = Math.max(width, height) / sizeDouble;
@ -77,9 +82,20 @@ public class ImageBrush implements Brush {
float pitch = loc.getPitch();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse();
RecursiveVisitor visitor = new RecursiveVisitor(
new ImageBrushMask(solid, center, transform, scale, centerImageX, centerImageZ, width, height, colorFunction, editSession,
session.getTextureUtil()), vector -> true, Integer.MAX_VALUE);
visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS));
new ImageBrushMask(
solid,
center,
transform,
scale,
centerImageX,
centerImageZ,
width,
height,
colorFunction,
editSession,
session.getTextureUtil()
), vector -> true, Integer.MAX_VALUE);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(center);
Operations.completeBlindly(visitor);
}

View File

@ -70,8 +70,10 @@ public class InspectBrush extends BrushTool {
return false;
}
if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(Caption.of("fawe.error.setting.disable",
"history.use-database (Import with /history import )"));
player.print(Caption.of(
"fawe.error.setting.disable",
"history.use-database (Import with /history import )"
));
LOGGER.debug("No db");
return false;
}
@ -101,7 +103,13 @@ public class InspectBrush extends BrushTool {
String ageFormatted = MainUtil.secToTime(age / 1000);
BlockState blockFrom = BlockState.getFromOrdinal(from);
BlockState blockTo = BlockState.getFromOrdinal(to);
TranslatableComponent msg = Caption.of("fawe.worldedit.tool.tool.inspect.info", name, blockFrom, blockTo, ageFormatted);
TranslatableComponent msg = Caption.of(
"fawe.worldedit.tool.tool.inspect.info",
name,
blockFrom,
blockTo,
ageFormatted
);
TextComponent hover = TextComponent.of("/tool inspect", TextColor.GOLD);
String infoCmd = "//history summary " + uuid + " " + index;
@ -121,4 +129,5 @@ public class InspectBrush extends BrushTool {
public boolean canUse(Actor actor) {
return actor.hasPermission("worldedit.tool.inspect");
}
}

View File

@ -1,9 +1,9 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.function.mask.LayerBrushMask;
import com.fastasyncworldedit.core.math.BlockVectorSet;
import com.fastasyncworldedit.core.function.mask.AdjacentAnyMask;
import com.fastasyncworldedit.core.function.mask.LayerBrushMask;
import com.fastasyncworldedit.core.function.mask.RadiusMask;
import com.fastasyncworldedit.core.math.BlockVectorSet;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
@ -30,8 +30,13 @@ public class LayerBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws
MaxChangedBlocksException {
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(
BlockTypes.AIR,
BlockTypes.CAVE_AIR,
BlockTypes.VOID_AIR
));
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);
visitor = new RecursiveVisitor(new MaskIntersection(adjacent, solid, radius), function -> true);

View File

@ -22,7 +22,8 @@ public class LineBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
if (pos1 == null) {
pos1 = position;
editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.line.primary", position));
@ -42,4 +43,5 @@ public class LineBrush implements Brush, ResettableTool {
pos1 = null;
return true;
}
}

View File

@ -15,6 +15,7 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import java.util.List;
public class PopulateSchem implements Brush {
private final Mask mask;
private final boolean randomRotate;
private final List<ClipboardHolder> clipboards;
@ -28,14 +29,20 @@ public class PopulateSchem implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
new MaskTraverser(mask).reset(editSession);
int size1 = MathMan.roundInt(size);
CuboidRegion cuboid = new CuboidRegion(editSession.getWorld(), position.subtract(size1, size1, size1), position.add(size1, size1, size1));
CuboidRegion cuboid = new CuboidRegion(
editSession.getWorld(),
position.subtract(size1, size1, size1),
position.add(size1, size1, size1)
);
try {
editSession.addSchems(cuboid, mask, clipboards, rarity, randomRotate);
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,10 +1,13 @@
package com.fastasyncworldedit.core.command.tool.brush;
public class RaiseBrush extends ErodeBrush {
public RaiseBrush() {
this(6, 0, 1, 1);
}
public RaiseBrush(int erodeFaces, int erodeRec, int fillFaces, int fillRec) {
super(erodeFaces, erodeRec, fillFaces, fillRec);
}
}

View File

@ -59,4 +59,5 @@ public class RecurseBrush implements Brush {
Operations.completeBlindly(visitor);
}
}
}

View File

@ -11,6 +11,7 @@ import com.sk89q.worldedit.math.Vector3;
import java.util.concurrent.ThreadLocalRandom;
public class RockBrush implements Brush {
private final double amplitude;
private final double frequency;
private final Vector3 radius;
@ -22,7 +23,8 @@ public class RockBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
double seedX = ThreadLocalRandom.current().nextDouble();
double seedY = ThreadLocalRandom.current().nextDouble();
double seedZ = ThreadLocalRandom.current().nextDouble();
@ -56,4 +58,5 @@ public class RockBrush implements Brush {
}
}
}
}

View File

@ -1,10 +1,10 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.math.BlockVectorSet;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.function.mask.AdjacentAnyMask;
import com.fastasyncworldedit.core.function.mask.RadiusMask;
import com.fastasyncworldedit.core.function.mask.SurfaceMask;
import com.fastasyncworldedit.core.math.BlockVectorSet;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;
@ -41,7 +41,8 @@ public class ScatterBrush implements Brush {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
this.mask = editSession.getMask();
if (this.mask == null) {
this.mask = Masks.alwaysTrue();
@ -95,7 +96,9 @@ public class ScatterBrush implements Brush {
return surface.direction(pt);
}
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException {
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws
MaxChangedBlocksException {
editSession.setBlock(pt, p);
}
}

View File

@ -14,6 +14,7 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import java.util.List;
public class ScatterCommand extends ScatterBrush {
private final String command;
public ScatterCommand(int count, int distance, String command) {
@ -22,9 +23,14 @@ public class ScatterCommand extends ScatterBrush {
}
@Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 position, Pattern p, double size) throws MaxChangedBlocksException {
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 position, Pattern p, double size) throws
MaxChangedBlocksException {
int radius = getDistance();
CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
CuboidRegionSelector selector = new CuboidRegionSelector(
editSession.getWorld(),
position.subtract(radius, radius, radius),
position.add(radius, radius, radius)
);
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ()))
@ -39,4 +45,5 @@ public class ScatterCommand extends ScatterBrush {
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
}
}
}

View File

@ -7,16 +7,19 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
public class ScatterOverlayBrush extends ScatterBrush {
public ScatterOverlayBrush(int count, int distance) {
super(count, distance);
}
@Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException {
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws
MaxChangedBlocksException {
int x = pt.getBlockX();
int y = pt.getBlockY();
int z = pt.getBlockZ();
BlockVector3 dir = getDirection(pt);
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p);
}
}

View File

@ -1,7 +1,8 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.function.mask.SurfaceMask;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.Mask;
@ -9,11 +10,11 @@ import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import java.util.concurrent.ThreadLocalRandom;
public class ShatterBrush extends ScatterBrush {
private final MutableBlockVector3 mutable = new MutableBlockVector3();
public ShatterBrush(int count) {
@ -21,11 +22,23 @@ public class ShatterBrush extends ScatterBrush {
}
@Override
public void apply(final EditSession editSession, final LocalBlockVectorSet placed, final BlockVector3 position, Pattern p, double size) throws MaxChangedBlocksException {
public void apply(
final EditSession editSession,
final LocalBlockVectorSet placed,
final BlockVector3 position,
Pattern p,
double size
) throws MaxChangedBlocksException {
}
@Override
public void finish(EditSession editSession, LocalBlockVectorSet placed, final BlockVector3 position, Pattern pattern, double size) {
public void finish(
EditSession editSession,
LocalBlockVectorSet placed,
final BlockVector3 position,
Pattern pattern,
double size
) {
int radius2 = (int) (size * size);
// Individual frontier for each point
LocalBlockVectorSet[] frontiers = new LocalBlockVectorSet[placed.size()];
@ -76,7 +89,7 @@ public class ShatterBrush extends ScatterBrush {
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
if (dSqr <= radius2) {
BlockVector3 bv = mutable.setComponents(x2, y2, z2);
if (surfaceTest.test(bv) && finalMask.test( bv)) {
if (surfaceTest.test(bv) && finalMask.test(bv)) {
// (collision) If it's visited and part of another frontier, set the block
if (!placed.add(x2, y2, z2)) {
if (!frontierVisited.contains(x2, y2, z2)) {
@ -98,4 +111,5 @@ public class ShatterBrush extends ScatterBrush {
}
}
}
}

View File

@ -1,8 +1,8 @@
package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.function.mask.SplatterBrushMask;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.function.mask.SurfaceMask;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.operation.Operations;
@ -14,6 +14,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import java.util.Arrays;
public class SplatterBrush extends ScatterBrush {
private final boolean solid;
private final int recursion;
@ -24,7 +25,13 @@ public class SplatterBrush extends ScatterBrush {
}
@Override
public void apply(final EditSession editSession, final LocalBlockVectorSet placed, final BlockVector3 position, Pattern p, double size) throws MaxChangedBlocksException {
public void apply(
final EditSession editSession,
final LocalBlockVectorSet placed,
final BlockVector3 position,
Pattern p,
double size
) throws MaxChangedBlocksException {
final Pattern finalPattern;
if (solid) {
finalPattern = p.applyBlock(position);
@ -35,10 +42,12 @@ public class SplatterBrush extends ScatterBrush {
SurfaceMask surface = new SurfaceMask(editSession);
RecursiveVisitor visitor = new RecursiveVisitor(new SplatterBrushMask(editSession, position, size2, surface, placed),
vector -> editSession.setBlock(vector, finalPattern), recursion);
vector -> editSession.setBlock(vector, finalPattern), recursion
);
visitor.setMaxBranch(2);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(position);
Operations.completeBlindly(visitor);
}
}

View File

@ -5,6 +5,7 @@ import com.fastasyncworldedit.core.command.tool.ResettableTool;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.function.mask.IdMask;
import com.fastasyncworldedit.core.function.visitor.DFSRecursiveVisitor;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.brush.Brush;
@ -14,7 +15,6 @@ import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.interpolation.Node;
@ -25,7 +25,7 @@ import java.util.List;
public class SplineBrush implements Brush, ResettableTool {
public static int MAX_POINTS = 15;
private ArrayList<ArrayList<BlockVector3>> positionSets;
private final ArrayList<ArrayList<BlockVector3>> positionSets;
private int numSplines;
private final Player player;
@ -193,4 +193,5 @@ public class SplineBrush implements Brush, ResettableTool {
}
return dir.normalize();
}
}

View File

@ -18,6 +18,7 @@ import java.io.InputStream;
import java.util.Arrays;
public class StencilBrush extends HeightBrush {
private final boolean onlyWhite;
public StencilBrush(InputStream stream, int rotation, double yscale, boolean onlyWhite, Clipboard clipboard) {
@ -26,7 +27,8 @@ public class StencilBrush extends HeightBrush {
}
@Override
public void build(EditSession editSession, BlockVector3 center, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 center, Pattern pattern, double sizeDouble) throws
MaxChangedBlocksException {
int size = (int) sizeDouble;
int size2 = (int) (sizeDouble * sizeDouble);
int maxY = editSession.getMaxY();
@ -48,10 +50,24 @@ public class StencilBrush extends HeightBrush {
double scale = (yscale / sizeDouble) * (maxY + 1);
RecursiveVisitor visitor =
new RecursiveVisitor(new StencilBrushMask(editSession, solid, center, transform, size2, map, scale, add, cutoff, maxY, pattern),
vector -> true, Integer.MAX_VALUE);
new RecursiveVisitor(new StencilBrushMask(
editSession,
solid,
center,
transform,
size2,
map,
scale,
add,
cutoff,
maxY,
pattern
),
vector -> true, Integer.MAX_VALUE
);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(center);
Operations.completeBlindly(visitor);
}
}

View File

@ -16,14 +16,20 @@ import com.sk89q.worldedit.math.BlockVector3;
import java.util.Arrays;
public class SurfaceSphereBrush implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
SurfaceMask surface = new SurfaceMask(editSession);
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius), vector -> editSession.setBlock(vector, pattern));
RecursiveVisitor visitor = new RecursiveVisitor(
new MaskIntersection(surface, radius),
vector -> editSession.setBlock(vector, pattern)
);
visitor.visit(position);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
Operations.completeBlindly(visitor);
}
}

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.util.MathMan;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -9,7 +10,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
import com.sk89q.worldedit.math.interpolation.Node;
@ -18,6 +18,7 @@ import java.util.ArrayList;
import java.util.List;
public class SurfaceSpline implements Brush {
private final double tension;
private final double bias;
private final double continuity;
@ -30,13 +31,20 @@ public class SurfaceSpline implements Brush {
this.quality = quality;
}
private ArrayList<BlockVector3> path = new ArrayList<>();
private final ArrayList<BlockVector3> path = new ArrayList<>();
@Override
public void build(EditSession editSession, BlockVector3 pos, Pattern pattern, double radius) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 pos, Pattern pattern, double radius) throws
MaxChangedBlocksException {
int maxY = editSession.getMaxY();
if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
int max = editSession.getNearestSurfaceTerrainBlock(
pos.getBlockX(),
pos.getBlockZ(),
pos.getBlockY(),
0,
editSession.getMaxY()
);
if (max == -1) {
return;
}
@ -103,4 +111,5 @@ public class SurfaceSpline implements Brush {
}
editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.spline.secondary"));
}
}

View File

@ -18,6 +18,7 @@ import java.util.List;
import java.util.Locale;
public abstract class Scroll implements ScrollTool {
private BrushTool tool;
public enum Action {
@ -38,7 +39,14 @@ public abstract class Scroll implements ScrollTool {
return fromArguments(tool, player, session, mode, args, message);
}
public static Scroll fromArguments(BrushTool tool, Player player, LocalSession session, Action mode, List<String> arguments, boolean message) throws InputParseException {
public static Scroll fromArguments(
BrushTool tool,
Player player,
LocalSession session,
Action mode,
List<String> arguments,
boolean message
) throws InputParseException {
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
@ -114,4 +122,5 @@ public abstract class Scroll implements ScrollTool {
public BrushTool getTool() {
return tool;
}
}

View File

@ -9,6 +9,7 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import java.util.List;
public class ScrollClipboard extends Scroll {
private final List<ClipboardHolder> clipboards;
private final LocalSession session;
private int index = 0;
@ -26,4 +27,5 @@ public class ScrollClipboard extends Scroll {
session.setClipboard(clipboard);
return true;
}
}

View File

@ -6,6 +6,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.mask.Mask;
public class ScrollMask extends Scroll {
private final Mask[] masks;
private int index;
@ -23,4 +24,5 @@ public class ScrollMask extends Scroll {
}
return false;
}
}
}

View File

@ -6,6 +6,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern;
public class ScrollPattern extends Scroll {
private final Pattern[] patterns;
private int index;
@ -23,4 +24,5 @@ public class ScrollPattern extends Scroll {
}
return false;
}
}
}

View File

@ -6,6 +6,7 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
public class ScrollRange extends Scroll {
public ScrollRange(BrushTool tool) {
super(tool);
}
@ -17,4 +18,5 @@ public class ScrollRange extends Scroll {
getTool().setRange(newSize);
return true;
}
}

View File

@ -5,6 +5,7 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
public class ScrollSize extends Scroll {
public ScrollSize(BrushTool tool) {
super(tool);
}
@ -16,4 +17,5 @@ public class ScrollSize extends Scroll {
getTool().setSize(newSize);
return true;
}
}

View File

@ -6,6 +6,7 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
public class ScrollTarget extends Scroll {
public ScrollTarget(BrushTool tool) {
super(tool);
}
@ -19,4 +20,5 @@ public class ScrollTarget extends Scroll {
getTool().setTargetMode(newMode);
return true;
}
}

View File

@ -4,6 +4,7 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
public class ScrollTargetOffset extends Scroll {
public ScrollTargetOffset(BrushTool tool) {
super(tool);
}
@ -14,4 +15,5 @@ public class ScrollTargetOffset extends Scroll {
tool.setTargetOffset(tool.getTargetOffset() + amount);
return true;
}
}

View File

@ -3,5 +3,7 @@ package com.fastasyncworldedit.core.command.tool.scroll;
import com.sk89q.worldedit.entity.Player;
public interface ScrollTool {
boolean increment(Player player, int amount);
}

View File

@ -1,6 +1,7 @@
package com.fastasyncworldedit.core.command.tool.sweep;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.math.transform.RoundedTransform;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -11,37 +12,35 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.interpolation.Interpolation;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.fastasyncworldedit.core.math.transform.RoundedTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
/**
* An implementation of a {@link Spline} using a Clipboard as source for the structure.
*
* @author Schuwi
* @version 1.0
*/
public class ClipboardSpline extends Spline {
private final Transform transform;
private ClipboardHolder clipboardHolder;
private BlockVector3 originalOrigin;
private Transform originalTransform;
private final ClipboardHolder clipboardHolder;
private final BlockVector3 originalOrigin;
private final Transform originalTransform;
private BlockVector3 center;
private BlockVector3 centerOffset;
private LocalBlockVectorSet buffer;
private final BlockVector3 centerOffset;
private final LocalBlockVectorSet buffer;
/**
* Constructor without position-correction. Use this constructor for an interpolation
* implementation which does not need position-correction.
*
* @param editSession The EditSession which will be used when pasting the clipboard content
* @param editSession The EditSession which will be used when pasting the clipboard content
* @param clipboardHolder The clipboard that will be pasted along the spline
* @param interpolation An implementation of the interpolation algorithm used to calculate
* the curve
* @apiNote Be advised that currently subsequent changes to the interpolation parameters may
* not be supported.
* @param interpolation An implementation of the interpolation algorithm used to calculate
* the curve
*/
public ClipboardSpline(EditSession editSession, ClipboardHolder clipboardHolder, Interpolation interpolation) {
this(editSession, clipboardHolder, interpolation, new AffineTransform(), -1);
@ -64,15 +63,19 @@ public class ClipboardSpline extends Spline {
* amount to 0.25 × 40 = 10 units of curve length between these two positions.
* </p>
*
* @param editSession The EditSession which will be used when pasting the clipboard content
* @param editSession The EditSession which will be used when pasting the clipboard content
* @param clipboardHolder The clipboard that will be pasted along the spline
* @param interpolation An implementation of the interpolation algorithm used to calculate
* the curve
* @param nodeCount The number of nodes provided to the interpolation object
* @apiNote Be advised that currently subsequent changes to the interpolation parameters may
* not be supported.
* @param interpolation An implementation of the interpolation algorithm used to calculate
* the curve
* @param nodeCount The number of nodes provided to the interpolation object
*/
public ClipboardSpline(EditSession editSession, ClipboardHolder clipboardHolder, Interpolation interpolation, Transform transform, int nodeCount) {
public ClipboardSpline(
EditSession editSession,
ClipboardHolder clipboardHolder,
Interpolation interpolation,
Transform transform,
int nodeCount
) {
super(editSession, interpolation, nodeCount);
this.clipboardHolder = clipboardHolder;
@ -126,4 +129,5 @@ public class ClipboardSpline extends Spline {
return operation instanceof ForwardExtentCopy ? ((ForwardExtentCopy) operation).getAffected() : 0;
}
}

View File

@ -15,6 +15,7 @@ import java.util.List;
* Embodies an abstract implementation for pasting structures along a spline.<br>
* A curve is being interpolated by the provided {@link Interpolation} implementation
* and the structure is pasted along this curve by the specific Spline implementation.
*
* @author Schuwi
* @version 1.0
*/
@ -24,17 +25,18 @@ public abstract class Spline {
private final int nodeCount;
protected EditSession editSession;
private Interpolation interpolation;
private final Interpolation interpolation;
private List<Section> sections;
private double splineLength;
private final double splineLength;
/**
* Constructor without position-correction. Use this constructor for an interpolation implementation which does not need position-correction.
* <p>
* Be advised that currently subsequent changes to the interpolation parameters may not be supported.
* @param editSession The EditSession which will be used when pasting the structure
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
*
* @param editSession The EditSession which will be used when pasting the structure
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
*/
protected Spline(EditSession editSession, Interpolation interpolation) {
this(editSession, interpolation, -1);
@ -53,9 +55,10 @@ public abstract class Spline {
* 0.25 * 40 = 10 units of curve length between these two positions.
* <p>
* Be advised that currently subsequent changes to the interpolation parameters may not be supported.
* @param editSession The EditSession which will be used when pasting the structure
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
* @param nodeCount The number of nodes provided to the interpolation object
*
* @param editSession The EditSession which will be used when pasting the structure
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
* @param nodeCount The number of nodes provided to the interpolation object
*/
protected Spline(EditSession editSession, Interpolation interpolation, int nodeCount) {
this.editSession = editSession;
@ -76,6 +79,7 @@ public abstract class Spline {
* is rotated by that angle to follow the curve slope.
* <p>
* The default direction is a (1;0) vector (pointing in the positive x-direction).
*
* @param direction A vector representing the horizontal forward direction of the clipboard content
*/
public void setDirection(Vector2 direction) {
@ -90,6 +94,7 @@ public abstract class Spline {
* is rotated by that angle to follow the curve slope.
* <p>
* The default direction is a (1;0) vector (pointing in the positive x-direction).
*
* @return A vector representing the horizontal forward direction of the clipboard content
*/
public Vector2 getDirection() {
@ -99,8 +104,9 @@ public abstract class Spline {
/**
* Paste the structure at the provided position on the curve. The position will be position-corrected if the
* nodeCount provided to the constructor is bigger than 2.
*
* @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive)
* @return The amount of blocks that have been changed
* @return The amount of blocks that have been changed
* @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached
*/
public int pastePosition(double position) throws MaxChangedBlocksException {
@ -124,8 +130,9 @@ public abstract class Spline {
/**
* Paste structure at the provided position on the curve. The position will not be position-corrected
* but will be passed directly to the interpolation algorithm.
*
* @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive)
* @return The amount of blocks that have been changed
* @return The amount of blocks that have been changed
* @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached
*/
public int pastePositionDirect(double position) throws MaxChangedBlocksException {
@ -142,9 +149,9 @@ public abstract class Spline {
Vector3 deriv = interpolation.get1stDerivative(position);
Vector2 deriv2D = Vector2.at(deriv.getX(), deriv.getZ()).normalize();
double angle = Math.toDegrees(
-Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D))
-Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D))
);
angle = ((angle % 360) + 360) % 360; // Wrap to 360 degrees
return pasteBlocks(blockTarget, offset, angle);
@ -196,6 +203,7 @@ public abstract class Spline {
}
private class Section {
final double uniStart;
final double uniLength;
final double flexStart;
@ -207,5 +215,7 @@ public abstract class Spline {
this.flexStart = flexStart;
this.flexLength = flexLength;
}
}
}

View File

@ -24,9 +24,10 @@ import java.util.List;
import java.util.stream.Collectors;
public class SweepBrush implements Brush, ResettableTool {
private List<BlockVector3> positions;
private final List<BlockVector3> positions;
private BlockVector3 position;
private int copies;
private final int copies;
private static final double tension = 0D;
private static final double bias = 0D;
@ -38,7 +39,8 @@ public class SweepBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
boolean newPos = !position.equals(this.position);
this.position = position;
@ -100,7 +102,7 @@ public class SweepBrush implements Brush, ResettableTool {
break;
}
default: {
for (double pos = 0D; pos <= 1D; pos += 1D / (copies - 1)) {
for (double pos = 0D; pos <= 1D; pos += 1D / (copies - 1)) {
spline.pastePosition(pos);
}
break;
@ -116,4 +118,5 @@ public class SweepBrush implements Brush, ResettableTool {
position = null;
return true;
}
}

View File

@ -8,8 +8,9 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.Style;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -18,7 +19,6 @@ import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
public class Caption {
@ -104,7 +104,11 @@ public class Caption {
return parent;
}
public static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final List<? extends Component> args) {
public static TranslatableComponent of(
@Nonnull final String key,
@Nullable final TextColor color,
@Nonnull final List<? extends Component> args
) {
return TranslatableComponent.of(key, color, Collections.emptySet(), args);
}
@ -115,4 +119,5 @@ public class Caption {
.collect(Collectors.toList());
return TranslatableComponent.of(key, components);
}
}

View File

@ -124,6 +124,7 @@ public class Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Create {
}
/**
@ -132,6 +133,7 @@ public class Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Final {
}
/**
@ -140,7 +142,9 @@ public class Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Comment {
String[] value();
}
/**
@ -149,7 +153,9 @@ public class Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface BlockName {
String[] value();
}
/**
@ -158,12 +164,13 @@ public class Config {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface Ignore {
}
@Ignore // This is not part of the config
public static class ConfigBlock<T> {
private HashMap<String, T> INSTANCES = new HashMap<>();
private final HashMap<String, T> INSTANCES = new HashMap<>();
public T remove(String key) {
return INSTANCES.remove(key);
@ -188,6 +195,7 @@ public class Config {
private Map<String, T> getRaw() {
return INSTANCES;
}
}
/**
@ -297,7 +305,10 @@ public class Config {
save(writer, current, value, indent + 2);
continue;
} else {
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(field.get(instance), spacing) + CTRF);
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(
field.get(instance),
spacing
) + CTRF);
}
}
} catch (Throwable e) {
@ -332,7 +343,9 @@ public class Config {
setAccessible(field);
return field;
} catch (Throwable ignored) {
LOGGER.debug("Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(instance.getClass().getSimpleName()));
LOGGER.debug("Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(instance
.getClass()
.getSimpleName()));
return null;
}
}
@ -437,4 +450,5 @@ public class Config {
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
}
}
}

View File

@ -19,7 +19,7 @@ public interface Configuration extends ConfigurationSection {
* If value is null, the value will be removed from the default Configuration source.
* </p>
*
* @param path Path of the value to set.
* @param path Path of the value to set.
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
@ -94,4 +94,5 @@ public interface Configuration extends ConfigurationSection {
* @return Options for this configuration
*/
ConfigurationOptions options();
}

View File

@ -5,6 +5,7 @@ package com.fastasyncworldedit.core.configuration;
* Configuration}
*/
public class ConfigurationOptions {
private char pathSeparator = '.';
private boolean copyDefaults = false;
private final Configuration configuration;
@ -87,4 +88,5 @@ public class ConfigurationOptions {
copyDefaults = value;
return this;
}
}

View File

@ -90,7 +90,7 @@ public interface ConfigurationSection {
* <p>
* To retrieve the single name of this section, that is, the final part of the path returned by
* this method, you may use {@link #getName()}.
*</p>
* </p>
*
* @return Path of this section relative to its root
*/
@ -163,7 +163,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the Object to get.
* @param def The default value to return if the path is not found.
* @param def The default value to return if the path is not found.
* @return Requested Object.
*/
Object get(String path, Object def);
@ -182,7 +182,7 @@ public interface ConfigurationSection {
* ConfigurationSection}s, please use {@link #createSection(String)} for that.
* </p>
*
* @param path Path of the object to set.
* @param path Path of the object to set.
* @param value New value to set the path to.
*/
void set(String path, Object value);
@ -209,7 +209,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path to create the section at.
* @param map The values to used.
* @param map The values to used.
* @return Newly created section
*/
ConfigurationSection createSection(String path, Map<?, ?> map);
@ -265,7 +265,7 @@ public interface ConfigurationSection {
* Gets the requested int by a path.
*
* <p>
* If the int does not exist, but a default value has been specified, this
* If the int does not exist, but a default value has been specified, this
* will return the default value. If the int does not exist and no default
* value was specified, this will return 0.
* </p>
@ -284,7 +284,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the int to get.
* @param def The default value to return if the path is not found or is not an int.
* @param def The default value to return if the path is not found or is not an int.
* @return Requested int.
*/
int getInt(String path, int def);
@ -326,7 +326,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the boolean to get.
* @param def The default value to return if the path is not found or is not a boolean.
* @param def The default value to return if the path is not found or is not a boolean.
* @return Requested boolean.
*/
boolean getBoolean(String path, boolean def);
@ -368,7 +368,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the double to get.
* @param def The default value to return if the path is not found or is not a double.
* @param def The default value to return if the path is not found or is not a double.
* @return Requested double.
*/
double getDouble(String path, double def);
@ -410,7 +410,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the long to get.
* @param def The default value to return if the path is not found or is not a long.
* @param def The default value to return if the path is not found or is not a long.
* @return Requested long.
*/
long getLong(String path, long def);
@ -454,7 +454,7 @@ public interface ConfigurationSection {
* </p>
*
* @param path Path of the List to get.
* @param def The default value to return if the path is not found or is not a List.
* @param def The default value to return if the path is not found or is not a List.
* @return Requested List.
*/
List<?> getList(String path, List<?> def);
@ -724,9 +724,10 @@ public interface ConfigurationSection {
* section at the path, replacing anything that may have existed there previously.
* </p>
*
* @param path Path of the value to set.
* @param path Path of the value to set.
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
void addDefault(String path, Object value);
}

View File

@ -43,4 +43,5 @@ public class InvalidConfigurationException extends Exception {
public InvalidConfigurationException(final String msg, final Throwable cause) {
super(msg, cause);
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map;
* This is useful for temporary Configurations for providing defaults.
*/
public class MemoryConfiguration extends MemorySection implements Configuration {
protected Configuration defaults;
protected MemoryConfigurationOptions options;
@ -87,4 +88,5 @@ public class MemoryConfiguration extends MemorySection implements Configuration
return options;
}
}

View File

@ -5,6 +5,7 @@ package com.fastasyncworldedit.core.configuration;
* MemoryConfiguration}
*/
public class MemoryConfigurationOptions extends ConfigurationOptions {
protected MemoryConfigurationOptions(final MemoryConfiguration configuration) {
super(configuration);
}
@ -25,4 +26,5 @@ public class MemoryConfigurationOptions extends ConfigurationOptions {
super.pathSeparator(value);
return this;
}
}

View File

@ -842,7 +842,10 @@ public class MemorySection implements ConfigurationSection {
@Override
public String toString() {
Configuration root = getRoot();
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + (root == null ? null : root.getClass().getSimpleName()) +
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + (root == null
? null
: root.getClass().getSimpleName()) +
"']";
}
}

View File

@ -10,6 +10,7 @@ import java.util.HashSet;
import java.util.List;
public class Settings extends Config {
@Ignore
public static final Settings IMP = new Settings();
@ -72,20 +73,23 @@ public class Settings extends Config {
@Comment("Enable or disable core components")
public static final class ENABLED_COMPONENTS {
public boolean COMMANDS = true;
@Comment({
"Disable the FAWE-PlotSquared hook to take over most intense P2 queueing",
"Specific aspects can be turned on and off further below",
"Only disables/enables the hook with v4. For v6, see PlotSquared settings.yml"
"Disable the FAWE-PlotSquared hook to take over most intense P2 queueing",
"Specific aspects can be turned on and off further below",
"Only disables/enables the hook with v4. For v6, see PlotSquared settings.yml"
})
public boolean PLOTSQUARED_v4_HOOK = true;
@Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.",
"Leave it off if you don't need it, it can spam your console."})
public boolean DEBUG = false;
}
@Comment("Paths for various directories")
public static final class PATHS {
@Comment({
"Put any minecraft or mod jars for FAWE to be aware of block textures",
})
@ -99,16 +103,19 @@ public class Settings extends Config {
public String CLIPBOARD = "clipboard";
@Comment("Each player has his or her own sub directory for schematics")
public boolean PER_PLAYER_SCHEMATICS = true;
}
@Comment("Region restriction settings")
public static final class REGION_RESTRICTIONS_OPTIONS {
@Comment({
"What type of users are allowed to WorldEdit in a region",
" - MEMBER = Players added to a region",
" - OWNER = Players who own the region"
})
public String MODE = "MEMBER";
}
@Comment({
@ -119,6 +126,7 @@ public class Settings extends Config {
})
@BlockName("default") // The name for the default block
public static class LIMITS extends ConfigBlock {
@Comment("Max actions that can be run concurrently (i.e. commands)")
public int MAX_ACTIONS = 1;
@Comment("Max number of block changes (e.g. by `//set stone`).")
@ -168,17 +176,19 @@ public class Settings extends Config {
})
public boolean CONFIRM_LARGE = true;
@Comment({
"If undo and redo commands should be restricted to allowed regions",
" - Prevents scenarios where players can delete/reset a region, and then continue to undo/redo on it"
"If undo and redo commands should be restricted to allowed regions",
" - Prevents scenarios where players can delete/reset a region, and then continue to undo/redo on it"
})
public boolean RESTRICT_HISTORY_TO_REGIONS = true;
@Comment({
"List of blocks to strip nbt from",
})
public List<String> STRIP_NBT = new ArrayList<>();
}
public static class HISTORY {
@Comment({
"Should history be saved on disk:",
" - Frees up a lot of memory",
@ -200,9 +210,9 @@ public class Settings extends Config {
})
public boolean COMBINE_STAGES = true;
@Comment({
"Do not wait for a chunk's history to save before sending it",
" - Undo/redo commands will wait until the history has been written to disk before executing",
" - Requires combine-stages = true"
"Do not wait for a chunk's history to save before sending it",
" - Undo/redo commands will wait until the history has been written to disk before executing",
" - Requires combine-stages = true"
})
public boolean SEND_BEFORE_HISTORY = true;
@Comment({
@ -266,10 +276,12 @@ public class Settings extends Config {
" - Reduces history size by ~10%",
})
public boolean SMALL_EDITS = false;
}
@Comment("This relates to how FAWE places chunks")
public static class QUEUE {
@Comment({
"This should equal the number of processors you have",
})
@ -325,11 +337,12 @@ public class Settings extends Config {
public int DISCARD_AFTER_MS = 60000;
@Comment({
"When using fastmode also do not bother to fix existing ticking blocks"
"When using fastmode also do not bother to fix existing ticking blocks"
})
public boolean NO_TICK_FASTMODE = true;
public static class PROGRESS {
@Comment({"Display constant titles about the progress of a user's edit",
" - false = disabled",
" - title = Display progress titles",
@ -340,7 +353,9 @@ public class Settings extends Config {
public int INTERVAL = 1;
@Comment("Delay sending progress in milliseconds (so quick edits don't spam)")
public int DELAY = 5000;
}
}
@Comment({
@ -349,6 +364,7 @@ public class Settings extends Config {
" - SAFE = Can be buggy but unlikely to cause any damage"
})
public static class EXPERIMENTAL {
@Comment({
"[UNSAFE] Directly modify the region files. (OBSOLETE - USE ANVIL COMMANDS)",
" - IMPROPER USE CAN CAUSE WORLD CORRUPTION!",
@ -384,14 +400,14 @@ public class Settings extends Config {
public boolean OTHER = false;
@Comment({
"Allow blocks placed by WorldEdit to tick. This could cause the big lags.",
"This has no effect on existing blocks one way or the other."
"Allow blocks placed by WorldEdit to tick. This could cause the big lags.",
"This has no effect on existing blocks one way or the other."
})
public boolean ALLOW_TICK_PLACED = false;
@Comment({
"Force re-ticking of existing blocks not edited by FAWE.",
"This will increase time taken slightly."
"Force re-ticking of existing blocks not edited by FAWE.",
"This will increase time taken slightly."
})
public boolean ALLOW_TICK_EXISTING = true;
@ -406,18 +422,22 @@ public class Settings extends Config {
"Set to -1 to disable"
})
public int PER_PLAYER_FILE_NUM_LIMIT = -1;
}
public static class PLOTSQUARED_INTEGRATION {
@Comment({
"Only disables/enables the components with PlotSquared v4.",
"For v6, see PlotSquared settings.yml"
"Only disables/enables the components with PlotSquared v4.",
"For v6, see PlotSquared settings.yml"
})
public boolean CLEAR = true;
public boolean COPY_AND_SWAP = true;
}
public static class WEB {
@Comment({
"The web interface for clipboards",
" - All schematics are anonymous and private",
@ -425,9 +445,11 @@ public class Settings extends Config {
" - Supports clipboard uploads, downloads and saves",
})
public String URL = "https://schem.intellectualsites.com/fawe/";
}
public static class EXTENT {
@Comment({
"Don't bug console when these plugins slow down WorldEdit operations",
" - You'll see a message in console if you need to change this option"
@ -435,10 +457,12 @@ public class Settings extends Config {
public List<String> ALLOWED_PLUGINS = new ArrayList<>();
@Comment("Should debug messages be sent when third party extents are used?")
public boolean DEBUG = true;
}
@Comment("Generic tick limiter (not necessarily WorldEdit related, but useful to stop abuse)")
public static class TICK_LIMITER {
@Comment("Enable the limiter")
public boolean ENABLED = true;
@Comment("The interval in ticks")
@ -455,9 +479,11 @@ public class Settings extends Config {
" - Horizontal fireworks can be hacked in to crash a server"
})
public boolean FIREWORKS_LOAD_CHUNKS = false;
}
public static class CLIPBOARD {
@Comment({
"Store the clipboard on disk instead of memory",
" - Will be slightly slower",
@ -474,9 +500,11 @@ public class Settings extends Config {
public int COMPRESSION_LEVEL = 1;
@Comment("Number of days to keep history on disk before deleting it")
public int DELETE_AFTER_DAYS = 1;
}
public static class LIGHTING {
@Comment({
"If packet sending should be delayed until relight is finished",
})
@ -491,6 +519,7 @@ public class Settings extends Config {
public int MODE = 1;
@Comment({"If existing lighting should be removed before relighting"})
public boolean REMOVE_FIRST = true;
}
public void reload(File file) {
@ -515,15 +544,39 @@ public class Settings extends Config {
if (actor.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) {
limitFound = true;
LIMITS newLimit = LIMITS.get(key);
limit.MAX_ACTIONS = Math.max(limit.MAX_ACTIONS, newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE);
limit.MAX_CHANGES = Math.max(limit.MAX_CHANGES, newLimit.MAX_CHANGES != -1 ? newLimit.MAX_CHANGES : Integer.MAX_VALUE);
limit.MAX_BLOCKSTATES = Math.max(limit.MAX_BLOCKSTATES, newLimit.MAX_BLOCKSTATES != -1 ? newLimit.MAX_BLOCKSTATES : Integer.MAX_VALUE);
limit.MAX_CHECKS = Math.max(limit.MAX_CHECKS, newLimit.MAX_CHECKS != -1 ? newLimit.MAX_CHECKS : Integer.MAX_VALUE);
limit.MAX_ENTITIES = Math.max(limit.MAX_ENTITIES, newLimit.MAX_ENTITIES != -1 ? newLimit.MAX_ENTITIES : Integer.MAX_VALUE);
limit.MAX_ACTIONS = Math.max(
limit.MAX_ACTIONS,
newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE
);
limit.MAX_CHANGES = Math.max(
limit.MAX_CHANGES,
newLimit.MAX_CHANGES != -1 ? newLimit.MAX_CHANGES : Integer.MAX_VALUE
);
limit.MAX_BLOCKSTATES = Math.max(
limit.MAX_BLOCKSTATES,
newLimit.MAX_BLOCKSTATES != -1 ? newLimit.MAX_BLOCKSTATES : Integer.MAX_VALUE
);
limit.MAX_CHECKS = Math.max(
limit.MAX_CHECKS,
newLimit.MAX_CHECKS != -1 ? newLimit.MAX_CHECKS : Integer.MAX_VALUE
);
limit.MAX_ENTITIES = Math.max(
limit.MAX_ENTITIES,
newLimit.MAX_ENTITIES != -1 ? newLimit.MAX_ENTITIES : Integer.MAX_VALUE
);
limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE);
limit.MAX_ITERATIONS = Math.max(limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE);
limit.MAX_HISTORY = Math.max(limit.MAX_HISTORY, newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE);
limit.MAX_EXPRESSION_MS = Math.max(limit.MAX_EXPRESSION_MS, newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE);
limit.MAX_ITERATIONS = Math.max(
limit.MAX_ITERATIONS,
newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE
);
limit.MAX_HISTORY = Math.max(
limit.MAX_HISTORY,
newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE
);
limit.MAX_EXPRESSION_MS = Math.max(
limit.MAX_EXPRESSION_MS,
newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE
);
limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE);
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
@ -544,4 +597,5 @@ public class Settings extends Config {
}
return limit;
}
}

View File

@ -10,11 +10,12 @@ import java.util.Map;
* instance.
*/
public final class TypeDescription {
private final Class<? extends Object> type;
private Tag tag;
private Map<String, Class<? extends Object>> listProperties;
private Map<String, Class<? extends Object>> keyProperties;
private Map<String, Class<? extends Object>> valueProperties;
private final Map<String, Class<? extends Object>> listProperties;
private final Map<String, Class<? extends Object>> keyProperties;
private final Map<String, Class<? extends Object>> valueProperties;
public TypeDescription(Class<? extends Object> clazz, Tag tag) {
this.type = clazz;
@ -68,7 +69,7 @@ public final class TypeDescription {
* Specify that the property is a type-safe {@code List}.
*
* @param property name of the JavaBean property
* @param type class of List values
* @param type class of List values
*/
public void putListPropertyType(String property, Class<? extends Object> type) {
listProperties.put(property, type);
@ -88,11 +89,13 @@ public final class TypeDescription {
* Specify that the property is a type-safe {@code Map}.
*
* @param property property name of this JavaBean
* @param key class of keys in Map
* @param value class of values in Map
* @param key class of keys in Map
* @param value class of values in Map
*/
public void putMapPropertyType(String property, Class<? extends Object> key,
Class<? extends Object> value) {
public void putMapPropertyType(
String property, Class<? extends Object> key,
Class<? extends Object> value
) {
keyProperties.put(property, key);
valueProperties.put(property, value);
}
@ -121,4 +124,5 @@ public final class TypeDescription {
public String toString() {
return "TypeDescription for " + getType() + " (tag='" + getTag() + "')";
}
}

View File

@ -35,6 +35,7 @@ import java.util.regex.Pattern;
* Public YAML interface. Each Thread must have its own instance.
*/
public class Yaml {
protected final Resolver resolver;
protected BaseConstructor constructor;
protected Representer representer;
@ -93,7 +94,7 @@ public class Yaml {
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param representer Representer to emit outgoing objects
* @param representer Representer to emit outgoing objects
* @param dumperOptions DumperOptions to configure outgoing objects
*/
public Yaml(Representer representer, DumperOptions dumperOptions) {
@ -104,8 +105,8 @@ public class Yaml {
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor BaseConstructor to construct incoming documents
* @param representer Representer to emit outgoing objects
* @param constructor BaseConstructor to construct incoming documents
* @param representer Representer to emit outgoing objects
* @param dumperOptions DumperOptions to configure outgoing objects
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) {
@ -116,10 +117,10 @@ public class Yaml {
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor BaseConstructor to construct incoming documents
* @param representer Representer to emit outgoing objects
* @param constructor BaseConstructor to construct incoming documents
* @param representer Representer to emit outgoing objects
* @param dumperOptions DumperOptions to configure outgoing objects
* @param resolver Resolver to detect implicit type
* @param resolver Resolver to detect implicit type
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
@ -156,7 +157,7 @@ public class Yaml {
* @param data instance to build the representation tree for
* @return representation tree
* @see <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
* Overview</a>
* Overview</a>
*/
public Node represent(Object data) {
return representer.represent(data);
@ -177,7 +178,7 @@ public class Yaml {
/**
* Serialize a Java object into a YAML stream.
*
* @param data Java object to be serialized to YAML
* @param data Java object to be serialized to YAML
* @param output stream to write to
*/
public void dump(Object data, Writer output) {
@ -189,7 +190,7 @@ public class Yaml {
/**
* Serialize a sequence of Java objects into a YAML stream.
*
* @param data Iterator with Objects
* @param data Iterator with Objects
* @param output stream to write to
*/
public void dumpAll(Iterator<? extends Object> data, Writer output) {
@ -235,15 +236,15 @@ public class Yaml {
* handled as an instance of YourClass when loaded.
* </p>
*
* @param data Java object to be serialized to YAML
* @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP
* for a JavaBean to make the tag disappear (to use implicit tag
* !!map). If {@code null} is provided then the standard tag
* with the full class name is used.
* @param data Java object to be serialized to YAML
* @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP
* for a JavaBean to make the tag disappear (to use implicit tag
* !!map). If {@code null} is provided then the standard tag
* with the full class name is used.
* @param flowStyle flow style for the whole document. See Chapter 10. Collection
* Styles http://yaml.org/spec/1.1/#id930798. If
* {@code null} is provided then the flow style from
* DumperOptions is used.
* Styles http://yaml.org/spec/1.1/#id930798. If
* {@code null} is provided then the flow style from
* DumperOptions is used.
* @return YAML String
*/
public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) {
@ -338,8 +339,8 @@ public class Yaml {
* Parse the only YAML document in a stream and produce the corresponding
* Java object.
*
* @param <T> Class is defined by the second argument
* @param io data to load from (BOM must not be present)
* @param <T> Class is defined by the second argument
* @param io data to load from (BOM must not be present)
* @param type Class of the object to be created
* @return parsed object
*/
@ -352,7 +353,7 @@ public class Yaml {
* Parse the only YAML document in a String and produce the corresponding
* Java object. (Because the encoding in known BOM is not respected.)
*
* @param <T> Class is defined by the second argument
* @param <T> Class is defined by the second argument
* @param yaml YAML data to load from (BOM must not be present)
* @param type Class of the object to be created
* @return parsed object
@ -366,9 +367,9 @@ public class Yaml {
* Parse the only YAML document in a stream and produce the corresponding
* Java object.
*
* @param <T> Class is defined by the second argument
* @param <T> Class is defined by the second argument
* @param input data to load from (BOM is respected and removed)
* @param type Class of the object to be created
* @param type Class of the object to be created
* @return parsed object
*/
@SuppressWarnings("unchecked")
@ -388,7 +389,7 @@ public class Yaml {
*
* @param yaml YAML data to load from (BOM must not be present)
* @return an iterator over the parsed Java objects in this String in proper
* sequence
* sequence
*/
public Iterable<Object> loadAll(Reader yaml) {
Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
@ -416,7 +417,7 @@ public class Yaml {
*
* @param yaml YAML data to load from (BOM must not be present)
* @return an iterator over the parsed Java objects in this String in proper
* sequence
* sequence
*/
public Iterable<Object> loadAll(String yaml) {
return loadAll(new StringReader(yaml));
@ -428,7 +429,7 @@ public class Yaml {
*
* @param yaml YAML data to load from (BOM is respected and ignored)
* @return an iterator over the parsed Java objects in this stream in proper
* sequence
* sequence
*/
public Iterable<Object> loadAll(InputStream yaml) {
return loadAll(new UnicodeReader(yaml));
@ -441,7 +442,7 @@ public class Yaml {
* @param yaml YAML document
* @return parsed root Node for the specified YAML document
* @see <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
* Overview</a>
* Overview</a>
*/
public Node compose(Reader yaml) {
Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
@ -480,9 +481,9 @@ public class Yaml {
* Add an implicit scalar detector. If an implicit scalar value matches the
* given regexp, the corresponding tag is assigned to the scalar.
*
* @param tag tag to assign to the node
* @param tag tag to assign to the node
* @param regexp regular expression to match against
* @param first a sequence of possible initial characters or null (which means any).
* @param first a sequence of possible initial characters or null (which means any).
*/
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
resolver.addImplicitResolver(tag, regexp, first);
@ -545,7 +546,8 @@ public class Yaml {
private static class SilentEmitter implements Emitable {
private List<Event> events = new ArrayList<>(100);
private final List<Event> events = new ArrayList<>(100);
public List<Event> getEvents() {
return events;
@ -554,11 +556,13 @@ public class Yaml {
public void emit(Event event) throws IOException {
events.add(event);
}
}
private static class YamlIterable implements Iterable<Object> {
private Iterator<Object> iterator;
private final Iterator<Object> iterator;
public YamlIterable(Iterator<Object> iterator) {
this.iterator = iterator;
@ -567,11 +571,13 @@ public class Yaml {
public Iterator<Object> iterator() {
return iterator;
}
}
private static class NodeIterable implements Iterable<Node> {
private Iterator<Node> iterator;
private final Iterator<Node> iterator;
public NodeIterable(Iterator<Node> iterator) {
this.iterator = iterator;
@ -580,11 +586,13 @@ public class Yaml {
public Iterator<Node> iterator() {
return iterator;
}
}
private static class EventIterable implements Iterable<Event> {
private Iterator<Event> iterator;
private final Iterator<Event> iterator;
public EventIterable(Iterator<Event> iterator) {
this.iterator = iterator;
@ -593,6 +601,7 @@ public class Yaml {
public Iterator<Event> iterator() {
return iterator;
}
}
}

View File

@ -107,12 +107,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* <p>
*
* @param file File to load from.
* @throws java.io.FileNotFoundException Thrown when the given file cannot be
* opened.
* @throws java.io.IOException Thrown when the given file cannot be read.
* @throws java.io.FileNotFoundException Thrown when the given file cannot be
* opened.
* @throws java.io.IOException Thrown when the given file cannot be read.
* @throws InvalidConfigurationException Thrown when the given file is not
* a valid Configuration.
* @throws IllegalArgumentException Thrown when file is null.
* a valid Configuration.
* @throws IllegalArgumentException Thrown when file is null.
*/
public void load(File file) throws IOException, InvalidConfigurationException {
if (file == null) {
@ -132,10 +132,10 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* from the given stream.
*
* @param reader the reader to load from
* @throws java.io.IOException thrown when underlying reader throws an IOException
* @throws java.io.IOException thrown when underlying reader throws an IOException
* @throws InvalidConfigurationException thrown when the reader does not
* represent a valid Configuration
* @throws IllegalArgumentException thrown when reader is null
* represent a valid Configuration
* @throws IllegalArgumentException thrown when reader is null
*/
public void load(Reader reader) throws IOException, InvalidConfigurationException {
@ -164,12 +164,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* thrown.
*
* @param file File to load from.
* @throws java.io.FileNotFoundException Thrown when the given file cannot be
* opened.
* @throws java.io.IOException Thrown when the given file cannot be read.
* @throws java.io.FileNotFoundException Thrown when the given file cannot be
* opened.
* @throws java.io.IOException Thrown when the given file cannot be read.
* @throws InvalidConfigurationException Thrown when the given file is not
* a valid Configuration.
* @throws IllegalArgumentException Thrown when file is null.
* a valid Configuration.
* @throws IllegalArgumentException Thrown when file is null.
*/
public void load(String file) throws IOException, InvalidConfigurationException {
if (file == null) {
@ -191,8 +191,8 @@ public abstract class FileConfiguration extends MemoryConfiguration {
*
* @param contents Contents of a Configuration to load.
* @throws InvalidConfigurationException Thrown if the specified string is
* invalid.
* @throws IllegalArgumentException Thrown if contents is null.
* invalid.
* @throws IllegalArgumentException Thrown if contents is null.
*/
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
@ -216,4 +216,5 @@ public abstract class FileConfiguration extends MemoryConfiguration {
return (FileConfigurationOptions) this.options;
}
}

View File

@ -1,14 +1,15 @@
package com.fastasyncworldedit.core.configuration.file;
import com.fastasyncworldedit.core.configuration.Configuration;
import com.fastasyncworldedit.core.configuration.MemoryConfiguration;
import com.fastasyncworldedit.core.configuration.MemoryConfigurationOptions;
import com.fastasyncworldedit.core.configuration.Configuration;
/**
* Various settings for controlling the input and output of a {@link
* FileConfiguration}
*/
public class FileConfigurationOptions extends MemoryConfigurationOptions {
private String header = null;
private boolean copyHeader = true;
@ -117,4 +118,5 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
return this;
}
}

View File

@ -3,10 +3,10 @@ package com.fastasyncworldedit.core.configuration.file;
import com.fastasyncworldedit.core.configuration.Configuration;
import com.fastasyncworldedit.core.configuration.ConfigurationSection;
import com.fastasyncworldedit.core.configuration.InvalidConfigurationException;
import com.fastasyncworldedit.core.configuration.Yaml;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.DumperOptions;
import com.fastasyncworldedit.core.configuration.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.representer.Representer;
@ -232,4 +232,5 @@ public class YamlConfiguration extends FileConfiguration {
return (YamlConfigurationOptions) options;
}
}

View File

@ -4,6 +4,7 @@ package com.fastasyncworldedit.core.configuration.file;
* Various settings for controlling the input and output of a {@link YamlConfiguration}.
*/
public class YamlConfigurationOptions extends FileConfigurationOptions {
private int indent = 2;
protected YamlConfigurationOptions(final YamlConfiguration configuration) {
@ -58,6 +59,7 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
* <p>
* The minimum value this may be is 2, and the maximum is 9.
* </p>
*
* @param value New indent
* @return This object, for chaining
*/
@ -72,4 +74,5 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
indent = value;
return this;
}
}

View File

@ -16,6 +16,7 @@ public class YamlConstructor extends SafeConstructor {
}
private class ConstructCustomObject extends ConstructYamlMap {
@Override
public Object construct(final Node node) {
if (node.isTwoStepsConstruction()) {
@ -44,5 +45,7 @@ public class YamlConstructor extends SafeConstructor {
public void construct2ndStep(final Node node, final Object object) {
throw new YAMLException("Unexpected referential mapping structure. Node: " + node);
}
}
}

View File

@ -22,6 +22,7 @@ public class YamlRepresenter extends Representer {
public Node representData(Object data) {
return super.representData(((ConfigurationSection) data).getValues(false));
}
}
private class RepresentConfigurationSerializable extends RepresentMap {
@ -30,10 +31,15 @@ public class YamlRepresenter extends Representer {
public Node representData(Object data) {
ConfigurationSerializable serializable = (ConfigurationSerializable) data;
Map<String, Object> values = new LinkedHashMap<>();
values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
values.put(
ConfigurationSerialization.SERIALIZED_TYPE_KEY,
ConfigurationSerialization.getAlias(serializable.getClass())
);
values.putAll(serializable.serialize());
return super.representData(values);
}
}
}

View File

@ -32,4 +32,5 @@ public interface ConfigurationSerializable {
* @return Map containing the current state of this class
*/
Map<String, Object> serialize();
}

View File

@ -10,6 +10,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
/**
* Utility class for storing and retrieving classes for {@link Configuration}.
*/
@ -19,7 +20,7 @@ public class ConfigurationSerialization {
public static final String SERIALIZED_TYPE_KEY = "==";
private static final Map<String, Class<? extends ConfigurationSerializable>> aliases =
new HashMap<>();
new HashMap<>();
private final Class<? extends ConfigurationSerializable> clazz;
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {
@ -41,7 +42,10 @@ public class ConfigurationSerialization {
* @param clazz Class to deserialize into
* @return New instance of the specified class
*/
public static ConfigurationSerializable deserializeObject(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) {
public static ConfigurationSerializable deserializeObject(
Map<String, ?> args,
Class<? extends ConfigurationSerializable> clazz
) {
return new ConfigurationSerialization(clazz).deserialize(args);
}
@ -199,26 +203,33 @@ public class ConfigurationSerialization {
ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args);
if (result == null) {
LOGGER.error("Could not call method '" + method.toString() + "' of " + this.clazz + " for deserialization: method returned null");
LOGGER.error("Could not call method '" + method + "' of " + this.clazz + " for deserialization: method returned null");
} else {
return result;
}
} catch (Throwable ex) {
LOGGER.error("Could not call method '" + method.toString() + "' of " + this.clazz
LOGGER.error(
"Could not call method '" + method.toString() + "' of " + this.clazz
+ " for deserialization",
ex instanceof InvocationTargetException ? ex.getCause() : ex);
ex instanceof InvocationTargetException ? ex.getCause() : ex
);
}
return null;
}
protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) {
protected ConfigurationSerializable deserializeViaCtor(
Constructor<? extends ConfigurationSerializable> ctor,
Map<String, ?> args
) {
try {
return ctor.newInstance(args);
} catch (Throwable ex) {
LOGGER.error("Could not call constructor '" + ctor.toString() + "' of " + this.clazz
LOGGER.error(
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
+ " for deserialization",
ex instanceof InvocationTargetException ? ex.getCause() : ex);
ex instanceof InvocationTargetException ? ex.getCause() : ex
);
}
return null;
@ -253,4 +264,5 @@ public class ConfigurationSerialization {
return result;
}
}

View File

@ -12,6 +12,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DelegateDeserialization {
/**
* Which class should be used as a delegate for this classes
* deserialization
@ -19,4 +20,5 @@ public @interface DelegateDeserialization {
* @return Delegate class
*/
Class<? extends ConfigurationSerializable> value();
}

View File

@ -22,6 +22,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SerializableAs {
/**
* This is the name your class will be stored and retrieved as.
* <p>
@ -31,4 +32,5 @@ public @interface SerializableAs {
* @return Name to serialize the class as.
*/
String value();
}

View File

@ -3,17 +3,17 @@ package com.fastasyncworldedit.core.database;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.history.RollbackOptimizedHistory;
import com.fastasyncworldedit.core.util.MainUtil;
import com.fastasyncworldedit.core.util.collection.YieldIterable;
import com.fastasyncworldedit.core.util.task.AsyncNotifyQueue;
import com.fastasyncworldedit.core.util.MainUtil;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import org.apache.logging.log4j.Logger;
import org.intellij.lang.annotations.Language;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -71,7 +71,10 @@ public class RollbackDatabase extends AsyncNotifyQueue {
super((t, e) -> e.printStackTrace());
this.prefix = "";
this.world = world;
this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + "summary.db");
this.dbLocation = MainUtil.getFile(
Fawe.imp().getDirectory(),
Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + "summary.db"
);
connection = openConnection();
// update vars
@ -100,7 +103,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
return ByteBuffer.allocate(16).putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()).array();
}
public Future<Boolean> init() {
public Future<Boolean> init() {
return call(() -> {
try (PreparedStatement stmt = connection.prepareStatement(createTable)) {
stmt.executeUpdate();
@ -180,7 +183,14 @@ public class RollbackDatabase extends AsyncNotifyQueue {
return getEdits(null, 0, pos, pos, false, ascending);
}
public Iterable<Supplier<RollbackOptimizedHistory>> getEdits(UUID uuid, long minTime, BlockVector3 pos1, BlockVector3 pos2, boolean delete, boolean ascending) {
public Iterable<Supplier<RollbackOptimizedHistory>> getEdits(
UUID uuid,
long minTime,
BlockVector3 pos1,
BlockVector3 pos2,
boolean delete,
boolean ascending
) {
YieldIterable<Supplier<RollbackOptimizedHistory>> yieldIterable = new YieldIterable<>();
Future<Integer> future = call(() -> {
@ -219,7 +229,11 @@ public class RollbackDatabase extends AsyncNotifyQueue {
stmt.setInt(5, pos2.getBlockZ());
stmt.setByte(6, (byte) (pos1.getBlockY() - 128));
stmt.setByte(7, (byte) (pos2.getBlockY() - 128));
byte[] uuidBytes = ByteBuffer.allocate(16).putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()).array();
byte[] uuidBytes = ByteBuffer
.allocate(16)
.putLong(uuid.getMostSignificantBits())
.putLong(uuid.getLeastSignificantBits())
.array();
stmt.setBytes(8, uuidBytes);
}
}
@ -251,7 +265,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
}
RollbackOptimizedHistory[] copy = IntStream.range(0, size)
.mapToObj(i -> historyChanges.poll()).toArray(RollbackOptimizedHistory[]::new);
.mapToObj(i -> historyChanges.poll()).toArray(RollbackOptimizedHistory[]::new);
try (PreparedStatement stmt = connection.prepareStatement(insertEdit)) {
// `player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)"
@ -381,4 +395,5 @@ public class RollbackDatabase extends AsyncNotifyQueue {
}
super.close();
}
}

View File

@ -6,11 +6,13 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.world.entity.EntityType;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import java.util.function.Supplier;
public class LazyBaseEntity extends BaseEntity {
private Supplier<CompoundTag> saveTag;
public LazyBaseEntity(EntityType type, Supplier<CompoundTag> saveTag) {
super(type);
this.saveTag = saveTag;
@ -30,4 +32,5 @@ public class LazyBaseEntity extends BaseEntity {
}
return super.getNbtData();
}
}

View File

@ -1,7 +1,6 @@
package com.fastasyncworldedit.core.entity;
import javax.annotation.Nonnull;
import java.util.Map;
public interface MapMetadatable extends Metadatable {
@ -62,4 +61,5 @@ public interface MapMetadatable extends Metadatable {
default <V> V deleteMeta(String key) {
return (V) getRawMeta().remove(key);
}
}

View File

@ -35,14 +35,15 @@ public interface Metadatable {
* Gets the metadata value to which the specified key is mapped,
* or the default value if no metadata exists for the key.
*
* @param key the key of the metadata value to retrieve
* @param key the key of the metadata value to retrieve
* @param defaultValue the value to return if there is no metadata for the given key
* @return the metadata value for the key, if present; else the default value
*/
@Nonnull
default <V> V getMeta(String key, @Nonnull V defaultValue) {
V value = getMeta(key);
return value == null ? defaultValue : value; }
return value == null ? defaultValue : value;
}
/**
* Deletes the given metadata key from object. Do not delete metadata set by another plugin
@ -58,5 +59,7 @@ public interface Metadatable {
public static final String ANVIL_CLIPBOARD = "anvil-clipboard";
public static final String ROLLBACK = "rollback";
}
}

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import java.net.URI;
public class ActorSaveClipboardEvent extends Event implements Cancellable {
private final Actor actor;
private final Clipboard clipboard;
private final URI source;
@ -46,4 +47,5 @@ public class ActorSaveClipboardEvent extends Event implements Cancellable {
public Actor getActor() {
return actor;
}
}

View File

@ -68,4 +68,5 @@ public class PasteEvent extends Event implements Cancellable {
PasteEvent clone = new PasteEvent(actor, clipboard, uri, extent, to);
return clone;
}
}

View File

@ -7,8 +7,8 @@ import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -23,13 +23,14 @@ import java.util.stream.Stream;
* @param <E> the parse result.
*/
public abstract class RichParser<E> extends InputParser<E> {
private final String[] prefixes;
/**
* Create a new rich parser with a defined prefix for the result, e.g. {@code #simplex}.
*
* @param worldEdit the worldedit instance.
* @param aliases the prefix of this parser result.
* @param aliases the prefix of this parser result.
*/
protected RichParser(WorldEdit worldEdit, String... aliases) {
super(worldEdit);
@ -147,4 +148,5 @@ public abstract class RichParser<E> extends InputParser<E> {
}
return arguments.toArray(new String[0]);
}
}

View File

@ -1,15 +1,15 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.AdjacentAnyMask;
import com.fastasyncworldedit.core.function.mask.AdjacentMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class AdjacentMaskParser extends RichParser<Mask> {
@ -47,4 +47,5 @@ public class AdjacentMaskParser extends RichParser<Mask> {
}
return new AdjacentMask(subMask, min, max);
}
}

View File

@ -1,16 +1,16 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.AngleMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class AngleMaskParser extends RichParser<Mask> {
@ -49,8 +49,10 @@ public class AngleMaskParser extends RichParser<Mask> {
if (flag.equals("-o")) {
overlay = true;
} else {
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
TextComponent.of(flag)));
throw new InputParseException(Caption.of(
"fawe.error.invalid-flag",
TextComponent.of(flag)
));
}
}
}
@ -68,4 +70,5 @@ public class AngleMaskParser extends RichParser<Mask> {
return new AngleMask(context.getExtent(), min, max, overlay, 1);
}
}

View File

@ -1,16 +1,16 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.ExtremaMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class ExtremaMaskParser extends RichParser<Mask> {
@ -51,8 +51,10 @@ public class ExtremaMaskParser extends RichParser<Mask> {
if (flag.equals("-o")) {
overlay = true;
} else {
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
TextComponent.of(flag)));
throw new InputParseException(Caption.of(
"fawe.error.invalid-flag",
TextComponent.of(flag)
));
}
}
}
@ -68,4 +70,5 @@ public class ExtremaMaskParser extends RichParser<Mask> {
return new ExtremaMask(context.getExtent(), min, max, overlay, 4);
}
}

View File

@ -26,4 +26,5 @@ public class FalseMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return Masks.alwaysFalse();
}
}

View File

@ -26,4 +26,5 @@ public class LiquidMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new LiquidMask(context.getExtent());
}
}

View File

@ -1,16 +1,16 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.ROCAngleMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class ROCAngleMaskParser extends RichParser<Mask> {
@ -51,8 +51,10 @@ public class ROCAngleMaskParser extends RichParser<Mask> {
if (flag.equals("-o")) {
overlay = true;
} else {
throw new InputParseException(Caption.of("fawe.error.invalid-flag",
TextComponent.of(flag)));
throw new InputParseException(Caption.of(
"fawe.error.invalid-flag",
TextComponent.of(flag)
));
}
}
}
@ -68,4 +70,5 @@ public class ROCAngleMaskParser extends RichParser<Mask> {
return new ROCAngleMask(context.getExtent(), min, max, overlay, 4);
}
}

View File

@ -1,14 +1,14 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.RadiusMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class RadiusMaskParser extends RichParser<Mask> {
@ -34,4 +34,5 @@ public class RadiusMaskParser extends RichParser<Mask> {
int max = Integer.parseInt(arguments[1]);
return new RadiusMask(min, max);
}
}

View File

@ -1,8 +1,8 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
@ -10,8 +10,8 @@ import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.OffsetMask;
import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class RichOffsetMaskParser extends RichParser<Mask> {
@ -48,4 +48,5 @@ public class RichOffsetMaskParser extends RichParser<Mask> {
OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(x, y, z));
return new MaskIntersection(offsetMask, Masks.negate(submask));
}
}

View File

@ -1,17 +1,18 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.mask.SimplexMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class SimplexMaskParser extends RichParser<Mask> {
private static final String SIMPLEX_PREFIX = "#simplex";
public SimplexMaskParser(WorldEdit worldEdit) {
@ -39,4 +40,5 @@ public class SimplexMaskParser extends RichParser<Mask> {
max = (max - 50d) / 50d;
return new SimplexMask(scale, min, max);
}
}

View File

@ -27,4 +27,5 @@ public class SurfaceMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new SurfaceMask(context.getExtent());
}
}

View File

@ -26,4 +26,5 @@ public class TrueMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return Masks.alwaysTrue();
}
}

View File

@ -29,6 +29,10 @@ public class WallMaskParser extends SimpleInputParser<Mask> {
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new MaskIntersection(new ExistingBlockMask(context.getExtent()), new WallMask(new BlockMask(context.getExtent(), BlockTypes.AIR.getDefaultState().toBaseBlock()), 1, 8));
return new MaskIntersection(
new ExistingBlockMask(context.getExtent()),
new WallMask(new BlockMask(context.getExtent(), BlockTypes.AIR.getDefaultState().toBaseBlock()), 1, 8)
);
}
}

View File

@ -26,4 +26,5 @@ public class XAxisMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new XAxisMask(context.getExtent());
}
}

View File

@ -26,4 +26,5 @@ public class YAxisMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new YAxisMask(context.getExtent());
}
}

View File

@ -26,4 +26,5 @@ public class ZAxisMaskParser extends SimpleInputParser<Mask> {
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new ZAxisMask();
}
}

View File

@ -1,9 +1,9 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.pattern.BiomeApplyingPattern;
import com.sk89q.worldedit.WorldEdit;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
@ -11,11 +11,12 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class BiomePatternParser extends RichParser<Pattern> {
private final static String BIOME_PREFIX = "$";
/**
@ -71,4 +72,5 @@ public class BiomePatternParser extends RichParser<Pattern> {
}
return new BiomeApplyingPattern(context.requireExtent(), biomeType);
}
}

View File

@ -1,15 +1,15 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.pattern.BufferedPattern;
import com.sk89q.worldedit.WorldEdit;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class BufferedPatternParser extends RichParser<Pattern> {
@ -34,10 +34,13 @@ public class BufferedPatternParser extends RichParser<Pattern> {
@Override
protected Pattern parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
if (arguments.length != 1) {
throw new InputParseException(Caption.of("fawe.error.command.syntax",
TextComponent.of(getPrefix() + "[pattern] (e.g. " + getPrefix() + "[stone,dirt])")));
throw new InputParseException(Caption.of(
"fawe.error.command.syntax",
TextComponent.of(getPrefix() + "[pattern] (e.g. " + getPrefix() + "[stone,dirt])")
));
}
Pattern inner = this.worldEdit.getPatternFactory().parseFromInput(arguments[0], context);
return new BufferedPattern(context.requireActor(), inner);
}
}

View File

@ -11,6 +11,7 @@ import java.util.Collections;
import java.util.List;
public class ExistingPatternParser extends SimpleInputParser<Pattern> {
private final List<String> aliases = Collections.singletonList("#existing");
public ExistingPatternParser(WorldEdit worldEdit) {
@ -26,4 +27,5 @@ public class ExistingPatternParser extends SimpleInputParser<Pattern> {
public Pattern parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
return new ExistingPattern(context.requireExtent());
}
}

View File

@ -1,19 +1,19 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.fastasyncworldedit.core.function.pattern.Linear2DBlockPattern;
import com.google.common.base.Preconditions;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.fastasyncworldedit.core.extension.factory.parser.RichParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.util.Set;
import java.util.stream.Stream;
@ -44,8 +44,10 @@ public class Linear2DPatternParser extends RichParser<Pattern> {
@Override
protected Pattern parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
if (arguments.length == 0 || arguments.length > 3) {
throw new InputParseException(Caption.of("fawe.error.command.syntax",
TextComponent.of(getPrefix() + "[pattern] (e.g. " + getPrefix() + "[stone,dirt])")));
throw new InputParseException(Caption.of(
"fawe.error.command.syntax",
TextComponent.of(getPrefix() + "[pattern] (e.g. " + getPrefix() + "[stone,dirt])")
));
}
Pattern inner = this.worldEdit.getPatternFactory().parseFromInput(arguments[0], context);
if (inner instanceof BlockStateHolder) {
@ -68,4 +70,5 @@ public class Linear2DPatternParser extends RichParser<Pattern> {
throw new InputParseException(TextComponent.of("Pattern " + inner.getClass().getSimpleName()
+ " cannot be used with " + getPrefix()));
}
}

Some files were not shown because too many files have changed in this diff Show More