refactor: Drop custom snakeyaml implementation (#1523)

* refactor: Drop custom snakeyaml implementation

* Merge branch 'main' into chore/main/remove-snakeyaml-wannabe-abstraction
Dieser Commit ist enthalten in:
Alex 2022-01-09 10:55:16 +01:00 committet von GitHub
Ursprung c2f3c13a09
Commit 9ba90d8c83
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
137 geänderte Dateien mit 371 neuen und 1642 gelöschten Zeilen

Datei anzeigen

@ -141,6 +141,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
return parent;
}
@SuppressWarnings("unchecked")
private synchronized boolean init() {
if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) {
return false;
@ -159,10 +160,9 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
try {
for (Field field : BlockStateProperties.class.getDeclaredFields()) {
Object obj = field.get(null);
if (!(obj instanceof net.minecraft.world.level.block.state.properties.Property)) {
if (!(obj instanceof net.minecraft.world.level.block.state.properties.Property<?> state)) {
continue;
}
net.minecraft.world.level.block.state.properties.Property<?> state = (net.minecraft.world.level.block.state.properties.Property<?>) obj;
Property<?> property;
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
property = new BooleanProperty(
@ -288,6 +288,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
return SideEffectSet.defaults().getSideEffectsToApply();
}
@SuppressWarnings("rawtypes")
public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) {
CraftChunk craftChunk = (CraftChunk) chunk;
LevelChunk levelChunk = craftChunk.getHandle();

Datei anzeigen

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return;
}
for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x, chunk.z, false);
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false);
}
}
};
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
));
for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x, chunk.z, false);
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false);
}
}
};

Datei anzeigen

@ -77,6 +77,8 @@ import java.util.concurrent.Future;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBlocks {
@ -320,6 +322,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}
@Override
@SuppressWarnings("unchecked")
public CompoundTag getEntity(UUID uuid) {
Entity entity = serverLevel.getEntity(uuid);
if (entity != null) {
@ -365,10 +368,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
@Override
public boolean contains(Object get) {
if (!(get instanceof CompoundTag)) {
if (!(get instanceof CompoundTag getTag)) {
return false;
}
CompoundTag getTag = (CompoundTag) get;
Map<String, Tag> value = getTag.getValue();
CompoundTag getParts = (CompoundTag) value.get("UUID");
UUID getUUID = new UUID(getParts.getLong("Most"), getParts.getLong("Least"));
@ -388,17 +390,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
@NotNull
@Override
public Iterator<CompoundTag> iterator() {
Iterable<CompoundTag> result = Iterables.transform(
Iterables.concat(slices),
new com.google.common.base.Function<Entity, CompoundTag>() {
@Nullable
@Override
public CompoundTag apply(@Nullable Entity input) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
return (CompoundTag) adapter.toNative(input.saveWithoutId(tag));
}
}
);
Iterable<CompoundTag> result = StreamSupport.stream(Iterables.concat(slices).spliterator(), false).map(input -> {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
return (CompoundTag) adapter.toNative(input.saveWithoutId(tag));
}).collect(Collectors.toList());
return result.iterator();
}
};
@ -842,6 +837,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
* @return the given array to be filled with data, or a new array if null is given.
*/
@Override
@SuppressWarnings("unchecked")
public char[] update(int layer, char[] data, boolean aggressive) {
LevelChunkSection section = getSections(aggressive)[layer];
// Section is null, return empty array
@ -1005,6 +1001,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}
@Override
@SuppressWarnings("unchecked")
public synchronized boolean trim(boolean aggressive) {
skyLight = new DataLayer[getSectionCount()];
blockLight = new DataLayer[getSectionCount()];

Datei anzeigen

@ -67,6 +67,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
return tiles.get(BlockVector3.at(x, y, z));
}
@SuppressWarnings({"unchecked", "rawtypes"})
protected void storeEntity(Entity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();

Datei anzeigen

@ -227,6 +227,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
}
@SuppressWarnings("unchecked")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) {
@ -412,6 +413,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return BiomeTypes.get(resourceLocation.toString().toLowerCase(Locale.ROOT));
}
@SuppressWarnings("unchecked")
static void removeBeacon(BlockEntity beacon, LevelChunk levelChunk) {
try {
// Do the method ourselves to avoid trying to reflect generic method parameters

Datei anzeigen

@ -70,6 +70,7 @@ public class PaperweightStarlightRelighter implements Relighter {
private final ReentrantLock areaLock = new ReentrantLock();
private final NMSRelighter delegate;
@SuppressWarnings("rawtypes")
public PaperweightStarlightRelighter(ServerLevel serverLevel, IQueueExtent<IQueueChunk> queue) {
this.serverLevel = serverLevel;
this.delegate = new NMSRelighter(queue);

Datei anzeigen

@ -16,6 +16,7 @@ public class PaperweightStarlightRelighterFactory implements RelighterFactory {
@Override
public @Nonnull
@SuppressWarnings("rawtypes")
Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
org.bukkit.World w = Bukkit.getWorld(world.getName());
if (w == null) {

Datei anzeigen

@ -35,6 +35,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Tag> getValue() {
if (compoundTag == null) {
compoundTag = (CompoundTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(compoundTagSupplier.get());
@ -92,6 +93,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
return 0;
}
@SuppressWarnings("unchecked")
public List<Tag> getList(String key) {
net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key);
if (tag instanceof net.minecraft.nbt.ListTag nbtList) {
@ -108,6 +110,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
return Collections.emptyList();
}
@SuppressWarnings("unchecked")
public ListTag getListTag(String key) {
net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key);
if (tag instanceof net.minecraft.nbt.ListTag) {

Datei anzeigen

@ -402,6 +402,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
}
//util
@SuppressWarnings("unchecked")
private void removeWorldFromWorldsMap() {
Fawe.instance().getQueueHandler().sync(() -> {
try {
@ -421,6 +422,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
};
}
@SuppressWarnings({"unchecked", "rawtypes"})
private BiomeSource fastOverworldBiomeSource(BiomeSource biomeSource) throws Exception {
Field legacyBiomeInitLayerField = OverworldBiomeSource.class.getDeclaredField(
Refraction.pickName("legacyBiomeInitLayer", "i"));
@ -584,17 +586,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
}
private static class FastAreaLazy implements Area {
private final PixelTransformer transformer;
//ConcurrentHashMap is 50% faster that Long2IntLinkedOpenHashMap in a synchronized context
//using a map for each thread worsens the performance significantly due to cache misses (factor 5)
private final ConcurrentHashMap<Long, Integer> sharedMap;
public FastAreaLazy(ConcurrentHashMap<Long, Integer> sharedMap, PixelTransformer transformer) {
this.sharedMap = sharedMap;
this.transformer = transformer;
}
private record FastAreaLazy(ConcurrentHashMap<Long, Integer> sharedMap, PixelTransformer transformer) implements Area {
@Override
public int get(int x, int z) {

Datei anzeigen

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return;
}
for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x, chunk.z, false);
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false);
}
}
};
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
));
for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x, chunk.z, false);
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false);
}
}
};

Datei anzeigen

@ -309,6 +309,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}
@Override
@SuppressWarnings("unchecked")
public CompoundTag getEntity(UUID uuid) {
Entity entity = serverLevel.getEntity(uuid);
if (entity != null) {
@ -868,6 +869,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
* @return the given array to be filled with data, or a new array if null is given.
*/
@Override
@SuppressWarnings("unchecked")
public char[] update(int layer, char[] data, boolean aggressive) {
LevelChunkSection section = getSections(aggressive)[layer];
// Section is null, return empty array
@ -1064,6 +1066,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}
@Override
@SuppressWarnings("unchecked")
public synchronized boolean trim(boolean aggressive) {
skyLight = new DataLayer[getSectionCount()];
blockLight = new DataLayer[getSectionCount()];

Datei anzeigen

@ -67,6 +67,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
return tiles.get(BlockVector3.at(x, y, z));
}
@SuppressWarnings({"unchecked", "rawtypes"})
protected void storeEntity(Entity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();

Datei anzeigen

@ -559,6 +559,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return BiomeTypes.get(resourceLocation.toString().toLowerCase(Locale.ROOT));
}
@SuppressWarnings("unchecked")
static void removeBeacon(BlockEntity beacon, LevelChunk levelChunk) {
try {
// Do the method ourselves to avoid trying to reflect generic method parameters
@ -594,13 +595,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
}
static class FakeIdMapBlock implements IdMap<net.minecraft.world.level.block.state.BlockState> {
private final int size;
FakeIdMapBlock(int size) {
this.size = size;
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
@Override
public int getId(final net.minecraft.world.level.block.state.BlockState entry) {
@ -613,11 +608,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return null;
}
@Override
public int size() {
return size;
}
@NotNull
@Override
public Iterator<net.minecraft.world.level.block.state.BlockState> iterator() {
@ -626,13 +616,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
static class FakeIdMapBiome implements IdMap<Biome> {
private final int size;
FakeIdMapBiome(int size) {
this.size = size;
}
record FakeIdMapBiome(int size) implements IdMap<Biome> {
@Override
public int getId(final Biome entry) {
@ -645,11 +629,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return null;
}
@Override
public int size() {
return size;
}
@NotNull
@Override
public Iterator<Biome> iterator() {

Datei anzeigen

@ -70,6 +70,7 @@ public class PaperweightStarlightRelighter implements Relighter {
private final ReentrantLock areaLock = new ReentrantLock();
private final NMSRelighter delegate;
@SuppressWarnings("rawtypes")
public PaperweightStarlightRelighter(ServerLevel serverLevel, IQueueExtent<IQueueChunk> queue) {
this.serverLevel = serverLevel;
this.delegate = new NMSRelighter(queue);

Datei anzeigen

@ -16,6 +16,7 @@ public class PaperweightStarlightRelighterFactory implements RelighterFactory {
@Override
public @Nonnull
@SuppressWarnings("rawtypes")
Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
org.bukkit.World w = Bukkit.getWorld(world.getName());
if (w == null) {

Datei anzeigen

@ -35,6 +35,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Tag> getValue() {
if (compoundTag == null) {
compoundTag = (CompoundTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(compoundTagSupplier.get());
@ -92,6 +93,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
return 0;
}
@SuppressWarnings("unchecked")
public List<Tag> getList(String key) {
net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key);
if (tag instanceof net.minecraft.nbt.ListTag nbtList) {
@ -108,6 +110,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag {
return Collections.emptyList();
}
@SuppressWarnings("unchecked")
public ListTag getListTag(String key) {
net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key);
if (tag instanceof net.minecraft.nbt.ListTag) {

Datei anzeigen

@ -184,6 +184,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
}
@Override
@SuppressWarnings("unchecked")
protected boolean initNewWorld() throws Exception {
//world folder
tempDir = java.nio.file.Files.createTempDirectory("FastAsyncWorldEditWorldGen");
@ -385,6 +386,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
}
//util
@SuppressWarnings("unchecked")
private void removeWorldFromWorldsMap() {
Fawe.instance().getQueueHandler().sync(() -> {
try {

Datei anzeigen

@ -11,8 +11,6 @@ import java.lang.reflect.Method;
public class BukkitQueueHandler extends QueueHandler {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private volatile boolean timingsEnabled;
private static boolean alertTimingsChange = true;

Datei anzeigen

@ -34,7 +34,7 @@ public class BrushListener implements Listener {
BukkitPlayer player = BukkitAdapter.adapt(bukkitPlayer);
LocalSession session = player.getSession();
Tool tool = session.getTool(player);
if (tool instanceof ScrollTool) {
if (tool instanceof ScrollTool scrollable) {
final int slot = event.getNewSlot();
final int oldSlot = event.getPreviousSlot();
final int ri;
@ -43,7 +43,6 @@ public class BrushListener implements Listener {
} else {
ri = -1;
}
ScrollTool scrollable = (ScrollTool) tool;
if (scrollable.increment(player, ri)) {
bukkitPlayer.getInventory().setHeldItemSlot(oldSlot);
}

Datei anzeigen

@ -53,8 +53,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
if (region instanceof GlobalProtectedRegion) {
return RegionWrapper.GLOBAL();
}
if (region instanceof ProtectedPolygonalRegion) {
ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
if (region instanceof ProtectedPolygonalRegion casted) {
BlockVector3 max = region.getMaximumPoint();
BlockVector3 min = region.getMinimumPoint();
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());

Datei anzeigen

@ -43,6 +43,7 @@ import java.util.UUID;
import static org.bukkit.Bukkit.getWorld;
@SuppressWarnings("unused")
public class FaweDelegateRegionManager {
public boolean setCuboids(

Datei anzeigen

@ -50,6 +50,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.GZIPInputStream;
@SuppressWarnings("unused")
public class FaweDelegateSchematicHandler {
private static final Logger LOGGER = LogManagerCompat.getLogger();

Datei anzeigen

@ -25,6 +25,7 @@ import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
@SuppressWarnings({"unused", "rawtypes"})
public class FaweQueueCoordinator extends QueueCoordinator {
public final IQueueExtent<IQueueChunk> instance;

Datei anzeigen

@ -33,6 +33,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
@SuppressWarnings("unused")
@CommandDeclaration(command = "generatebiome",
permission = "plots.generatebiome",
category = CommandCategory.APPEARANCE,

Datei anzeigen

@ -120,7 +120,7 @@ public enum FaweCache implements Trimable {
}
public <T, V> LoadingCache<T, V> createCache(Supplier<V> withInitial) {
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
return CacheBuilder.newBuilder().build(new CacheLoader<>() {
@Override
public V load(@Nonnull T key) {
return withInitial.get();
@ -129,7 +129,7 @@ public enum FaweCache implements Trimable {
}
public <T, V> LoadingCache<T, V> createCache(Function<T, V> withInitial) {
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
return CacheBuilder.newBuilder().build(new CacheLoader<>() {
@Override
public V load(@Nonnull T key) {
return withInitial.apply(key);
@ -246,9 +246,6 @@ public enum FaweCache implements Trimable {
/**
* Convert raw char array to palette
*
* @param layerOffset
* @param blocks
* @return palette
*/
public Palette toPalette(int layerOffset, char[] blocks) {
@ -257,9 +254,6 @@ public enum FaweCache implements Trimable {
/**
* Convert raw int array to palette
*
* @param layerOffset
* @param blocks
* @return palette
*/
public Palette toPalette(int layerOffset, int[] blocks) {
@ -344,8 +338,6 @@ public enum FaweCache implements Trimable {
/**
* Convert raw int array to unstretched palette (1.16)
*
* @param layerOffset
* @param blocks
* @return palette
*/
public Palette toPaletteUnstretched(int layerOffset, char[] blocks) {

Datei anzeigen

@ -9,13 +9,7 @@ import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
public class AngleBrush implements Brush {
private final int distance;
public AngleBrush(int distance) {
this.distance = distance;
}
public record AngleBrush(int distance) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws

Datei anzeigen

@ -7,19 +7,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
public class BlobBrush implements Brush {
private final double amplitude;
private final double frequency;
private final Vector3 radius;
private final double sphericity;
public BlobBrush(Vector3 radius, double frequency, double amplitude, double sphericity) {
this.frequency = frequency;
this.amplitude = amplitude;
this.radius = radius;
this.sphericity = sphericity;
}
public record BlobBrush(Vector3 radius, double frequency, double amplitude, double sphericity) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws

Datei anzeigen

@ -38,10 +38,9 @@ public class CatenaryBrush implements Brush, ResettableTool {
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws
MaxChangedBlocksException {
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
if (pos1 == null || pos2.equals(pos1)) {
pos1 = pos2;
actor.print(Caption.of("fawe.worldedit.brush.brush.line.primary", pos2));

Datei anzeigen

@ -11,38 +11,17 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
public class CircleBrush implements Brush {
private final boolean filled;
public CircleBrush(boolean filled) {
this.filled = filled;
}
public record CircleBrush(boolean filled) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException {
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
Vector3 normal = position.toVector3().subtract(player.getLocation());
editSession.makeCircle(position, pattern, size, size, size, filled, normal);
}
private Vector3 any90Rotate(Vector3 normal) {
normal = normal.normalize();
if (normal.getX() == 1 || normal.getY() == 1 || normal.getZ() == 1) {
return Vector3.at(normal.getZ(), normal.getX(), normal.getY());
}
AffineTransform affine = new AffineTransform();
affine = affine.rotateX(90);
affine = affine.rotateY(90);
affine = affine.rotateZ(90);
Vector3 random = affine.apply(normal);
return random.cross(normal).normalize();
}
}

Datei anzeigen

@ -43,10 +43,9 @@ public class CommandBrush implements Brush {
.replace("{size}", Integer.toString(radius));
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
//Use max world height to allow full coverage of the world height
Location face = player.getBlockTraceFace(editSession.getWorld().getMaxY(), true);
if (face == null) {

Datei anzeigen

@ -39,7 +39,7 @@ public class ImageBrush implements Brush {
private final ColorFunction colorFunction;
public ImageBrush(BufferedImage image, LocalSession session, boolean alpha /*, boolean glass */) throws IOException {
public ImageBrush(BufferedImage image, LocalSession session, boolean alpha /*, boolean glass */) {
this.session = session;
this.table = new SummedColorTable(image, alpha);
this.width = image.getWidth();
@ -89,10 +89,9 @@ public class ImageBrush implements Brush {
double scale = Math.max(width, height) / sizeDouble;
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
Location loc = player.getLocation();
float yaw = loc.getYaw();
float pitch = loc.getPitch();

Datei anzeigen

@ -34,8 +34,6 @@ import java.util.function.Supplier;
public class InspectBrush extends BrushTool {
private static final Logger LOGGER = LogManagerCompat.getLogger();
/**
* Construct the tool.
*/

Datei anzeigen

@ -14,19 +14,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;
private final int rarity;
public PopulateSchem(Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean randomRotate) {
this.mask = mask;
this.clipboards = clipboards;
this.rarity = rarity;
this.randomRotate = randomRotate;
}
public record PopulateSchem(Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean randomRotate) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws

Datei anzeigen

@ -14,13 +14,7 @@ import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
public class RecurseBrush implements Brush {
private final boolean dfs;
public RecurseBrush(boolean dfs) {
this.dfs = dfs;
}
public record RecurseBrush(boolean dfs) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException {

Datei anzeigen

@ -10,17 +10,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;
public RockBrush(Vector3 radius, double frequency, double amplitude) {
this.frequency = frequency;
this.amplitude = amplitude;
this.radius = radius;
}
public record RockBrush(double amplitude, double frequency, Vector3 radius) implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws

Datei anzeigen

@ -50,10 +50,9 @@ public class ScatterCommand extends ScatterBrush {
.replace("{size}", Integer.toString(radius));
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
player.setSelection(selector);
List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) {

Datei anzeigen

@ -137,61 +137,4 @@ public class SplineBrush implements Brush, ResettableTool {
return sum.multiply(1.0 / points.size());
}
private BlockVector3 normal(Collection<BlockVector3> points, BlockVector3 centroid) {
int n = points.size();
switch (n) {
case 1:
return null;
case 2:
return null;
}
// Calc full 3x3 covariance matrix, excluding symmetries:
double xx = 0.0;
double xy = 0.0;
double xz = 0.0;
double yy = 0.0;
double yz = 0.0;
double zz = 0.0;
MutableVector3 r = new MutableVector3();
for (BlockVector3 p : points) {
r.mutX(p.getX() - centroid.getX());
r.mutY(p.getY() - centroid.getY());
r.mutZ(p.getZ() - centroid.getZ());
xx += r.getX() * r.getX();
xy += r.getX() * r.getY();
xz += r.getX() * r.getZ();
yy += r.getY() * r.getY();
yz += r.getY() * r.getZ();
zz += r.getZ() * r.getZ();
}
double det_x = yy * zz - yz * yz;
double det_y = xx * zz - xz * xz;
double det_z = xx * yy - xy * xy;
double det_max = Math.max(Math.max(det_x, det_y), det_z);
if (det_max <= 0.0) {
return null;
}
// Pick path with best conditioning:
BlockVector3 dir;
if (det_max == det_x) {
double a = (xz * yz - xy * zz) / det_x;
double b = (xy * yz - xz * yy) / det_x;
dir = BlockVector3.at(1.0, a, b);
} else if (det_max == det_y) {
double a = (yz * xz - xy * zz) / det_y;
double b = (xy * xz - yz * xx) / det_y;
dir = BlockVector3.at(a, 1.0, b);
} else {
double a = (yz * xy - xz * yy) / det_z;
double b = (xz * xy - yz * xx) / det_z;
dir = BlockVector3.at(a, b, 1.0);
}
return dir.normalize();
}
}

Datei anzeigen

@ -51,10 +51,9 @@ public class StencilBrush extends HeightBrush {
final SolidBlockMask solid = new SolidBlockMask(editSession);
Actor actor = editSession.getActor();
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
throw FaweCache.PLAYER_ONLY;
}
Player player = (Player) actor;
Location loc = player.getLocation();
float yaw = loc.getYaw();
float pitch = loc.getPitch();

Datei anzeigen

@ -21,7 +21,6 @@ public class SurfaceSphereBrush implements Brush {
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),

Datei anzeigen

@ -52,8 +52,6 @@ public abstract class Scroll implements ScrollTool {
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
switch (mode) {
case NONE:
return null;
case CLIPBOARD:
if (arguments.size() != 2) {
if (message) {

Datei anzeigen

@ -18,9 +18,6 @@ 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 {

Datei anzeigen

@ -15,9 +15,6 @@ 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
*/
public abstract class Spline {
@ -202,19 +199,7 @@ public abstract class Spline {
return finalPosition;
}
private class Section {
final double uniStart;
final double uniLength;
final double flexStart;
final double flexLength;
Section(double uniStart, double uniLength, double flexStart, double flexLength) {
this.uniStart = uniStart;
this.uniLength = uniLength;
this.flexStart = flexStart;
this.flexLength = flexLength;
}
private record Section(double uniStart, double uniLength, double flexStart, double flexLength) {
}

Datei anzeigen

@ -90,23 +90,20 @@ public class SweepBrush implements Brush, ResettableTool {
}
switch (copies) {
case 1: {
case 1 -> {
spline.pastePosition(0D);
break;
}
case -1: {
case -1 -> {
double length = interpol.arcLength(0, 1);
double step = 1 / (length * quality);
for (double pos = 0; pos <= 1; pos += step) {
spline.pastePosition(pos);
}
break;
}
default: {
default -> {
for (double pos = 0D; pos <= 1D; pos += 1D / (copies - 1)) {
spline.pastePosition(pos);
}
break;
}
}
actor.print(Caption.of("fawe.worldedit.brush.spline.secondary"));

Datei anzeigen

@ -42,7 +42,7 @@ public class Caption {
private static Component color(TextComponent text) {
String content = text.content();
if (colorCodes.matcher(content).find()) {
TextComponent legacy = LegacyComponentSerializer.INSTANCE.deserialize(content, '&');
TextComponent legacy = LegacyComponentSerializer.legacy().deserialize(content, '&');
legacy.style().merge(text.style(), Style.Merge.Strategy.IF_ABSENT_ON_TARGET);
if (!text.children().isEmpty()) {
text = TextComponent.builder().append(legacy).append(text.children()).build();
@ -86,8 +86,7 @@ public class Caption {
if (children != (children = color(parent, children))) {
parent = parent.children(children);
}
if (parent instanceof TranslatableComponent) {
TranslatableComponent tc = (TranslatableComponent) parent;
if (parent instanceof TranslatableComponent tc) {
List<Component> args = tc.args();
if (args != (args = color(parent, args))) {
parent = tc.args(args);

Datei anzeigen

@ -100,7 +100,6 @@ public class Config {
* Set all values in the file (load first to avoid overwriting).
*/
public void save(File file) {
Class<? extends Config> root = getClass();
try {
if (!file.exists()) {
File parent = file.getParentFile();
@ -198,23 +197,6 @@ public class Config {
}
/**
* Get the static fields in a section.
*/
private Map<String, Object> getFields(Class<?> clazz) {
HashMap<String, Object> map = new HashMap<>();
for (Field field : clazz.getFields()) {
if (Modifier.isStatic(field.getModifiers())) {
try {
map.put(toNodeName(field.getName()), field.get(null));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return map;
}
private String toYamlString(Object value, String spacing) {
if (value instanceof List) {
Collection<?> listValue = (Collection<?>) value;
@ -314,19 +296,6 @@ public class Config {
}
}
/**
* Get the field for a specific config node.
*
* @param split the node (split by period)
*/
private Field getField(String[] split, Class<?> root) {
Object instance = getInstance(split, root);
if (instance == null) {
return null;
}
return getField(split, instance);
}
/**
* Get the field for a specific config node and instance.
* <p>

Datei anzeigen

@ -3,7 +3,6 @@ package com.fastasyncworldedit.core.configuration;
/**
* Exception thrown when attempting to load an invalid {@link Configuration}
*/
@SuppressWarnings("serial")
public class InvalidConfigurationException extends Exception {
/**

Datei anzeigen

@ -76,8 +76,7 @@ public class MemorySection implements ConfigurationSection {
return Double.parseDouble((String) obj);
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
List<?> val = (List<?>) obj;
} else if (obj instanceof List<?> val) {
if (!val.isEmpty()) {
return toDouble(val.get(0), def);
}
@ -94,8 +93,7 @@ public class MemorySection implements ConfigurationSection {
return Integer.parseInt((String) obj);
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
List<?> val = (List<?>) obj;
} else if (obj instanceof List<?> val) {
if (!val.isEmpty()) {
return toInt(val.get(0), def);
}
@ -112,8 +110,7 @@ public class MemorySection implements ConfigurationSection {
return Long.parseLong((String) obj);
} catch (NumberFormatException ignored) {
}
} else if (obj instanceof List) {
List<?> val = (List<?>) obj;
} else if (obj instanceof List<?> val) {
if (!val.isEmpty()) {
return toLong(val.get(0), def);
}
@ -706,8 +703,7 @@ public class MemorySection implements ConfigurationSection {
for (Object object : list) {
if (object instanceof Character) {
result.add((Character) object);
} else if (object instanceof String) {
String str = (String) object;
} else if (object instanceof String str) {
if (str.length() == 1) {
result.add(str.charAt(0));
@ -797,14 +793,12 @@ public class MemorySection implements ConfigurationSection {
}
protected void mapChildrenKeys(Set<String> output, ConfigurationSection section, boolean deep) {
if (section instanceof MemorySection) {
MemorySection sec = (MemorySection) section;
if (section instanceof MemorySection sec) {
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
output.add(createPath(section, entry.getKey(), this));
if (deep && (entry.getValue() instanceof ConfigurationSection)) {
ConfigurationSection subsection = (ConfigurationSection) entry.getValue();
if (deep && (entry.getValue() instanceof ConfigurationSection subsection)) {
mapChildrenKeys(output, subsection, deep);
}
}
@ -818,8 +812,7 @@ public class MemorySection implements ConfigurationSection {
}
protected void mapChildrenValues(Map<String, Object> output, ConfigurationSection section, boolean deep) {
if (section instanceof MemorySection) {
MemorySection sec = (MemorySection) section;
if (section instanceof MemorySection sec) {
for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
output.put(createPath(section, entry.getKey(), this), entry.getValue());

Datei anzeigen

@ -31,8 +31,10 @@ public class Settings extends Config {
public boolean PROTOCOL_SUPPORT_FIX = false;
@Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable
@SuppressWarnings("unused")
public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit/issues";
@Final
@SuppressWarnings("unused")
public String WIKI = "https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki";
@Final
public String DATE; // These values are set from FAWE before loading

Datei anzeigen

@ -1,607 +0,0 @@
package com.fastasyncworldedit.core.configuration;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.composer.Composer;
import org.yaml.snakeyaml.constructor.BaseConstructor;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.emitter.Emitable;
import org.yaml.snakeyaml.emitter.Emitter;
import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.events.Event;
import org.yaml.snakeyaml.introspector.BeanAccess;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.parser.Parser;
import org.yaml.snakeyaml.parser.ParserImpl;
import org.yaml.snakeyaml.reader.StreamReader;
import org.yaml.snakeyaml.reader.UnicodeReader;
import org.yaml.snakeyaml.representer.Representer;
import org.yaml.snakeyaml.resolver.Resolver;
import org.yaml.snakeyaml.serializer.Serializer;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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;
protected DumperOptions dumperOptions;
private String name;
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*/
public Yaml() {
this(new Constructor(), new Representer(), new DumperOptions(), new Resolver());
}
/**
* Create Yaml instance.
*
* @param dumperOptions DumperOptions to configure outgoing objects
*/
public Yaml(DumperOptions dumperOptions) {
this(new Constructor(), new Representer(), dumperOptions);
}
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param representer Representer to emit outgoing objects
*/
public Yaml(Representer representer) {
this(new Constructor(), representer);
}
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor BaseConstructor to construct incoming documents
*/
public Yaml(BaseConstructor constructor) {
this(constructor, new Representer());
}
/**
* 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
*/
public Yaml(BaseConstructor constructor, Representer representer) {
this(constructor, representer, new DumperOptions());
}
/**
* 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 dumperOptions DumperOptions to configure outgoing objects
*/
public Yaml(Representer representer, DumperOptions dumperOptions) {
this(new Constructor(), representer, dumperOptions, new Resolver());
}
/**
* 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 dumperOptions DumperOptions to configure outgoing objects
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) {
this(constructor, representer, dumperOptions, new Resolver());
}
/**
* 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 dumperOptions DumperOptions to configure outgoing objects
* @param resolver Resolver to detect implicit type
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
} else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor = constructor;
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils().setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer = representer;
this.dumperOptions = dumperOptions;
this.resolver = resolver;
this.name = "Yaml:" + System.identityHashCode(this);
}
/**
* Serialize a Java object into a YAML String.
*
* @param data Java object to be Serialized to YAML
* @return YAML String
*/
public String dump(Object data) {
List<Object> list = new ArrayList<>(1);
list.add(data);
return dumpAll(list.iterator());
}
/**
* Produce the corresponding representation tree for a given Object.
*
* @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>
*/
public Node represent(Object data) {
return representer.represent(data);
}
/**
* Serialize a sequence of Java objects into a YAML String.
*
* @param data Iterator with Objects
* @return YAML String with all the objects in proper sequence
*/
public String dumpAll(Iterator<? extends Object> data) {
StringWriter buffer = new StringWriter();
dumpAll(data, buffer, null);
return buffer.toString();
}
/**
* Serialize a Java object into a YAML stream.
*
* @param data Java object to be serialized to YAML
* @param output stream to write to
*/
public void dump(Object data, Writer output) {
List<Object> list = new ArrayList<>(1);
list.add(data);
dumpAll(list.iterator(), output, null);
}
/**
* Serialize a sequence of Java objects into a YAML stream.
*
* @param data Iterator with Objects
* @param output stream to write to
*/
public void dumpAll(Iterator<? extends Object> data, Writer output) {
dumpAll(data, output, null);
}
private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) {
Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag);
try {
serializer.open();
while (data.hasNext()) {
Node node = representer.represent(data.next());
serializer.serialize(node);
}
serializer.close();
} catch (IOException e) {
throw new YAMLException(e);
}
}
/**
* <p>
* Serialize a Java object into a YAML string. Override the default root tag
* with {@code rootTag}.
* </p>
*
* <p>
* This method is similar to {@code Yaml.dump(data)} except that the
* root tag for the whole document is replaced with the given tag. This has
* two main uses.
* </p>
*
* <p>
* First, if the root tag is replaced with a standard YAML tag, such as
* {@code Tag.MAP}, then the object will be dumped as a map. The root
* tag will appear as {@code !!map}, or blank (implicit !!map).
* </p>
*
* <p>
* Second, if the root tag is replaced by a different custom tag, then the
* document appears to be a different type when loaded. For example, if an
* instance of MyClass is dumped with the tag !!YourClass, then it will be
* 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 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.
* @return YAML String
*/
public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) {
FlowStyle oldStyle = representer.getDefaultFlowStyle();
if (flowStyle != null) {
representer.setDefaultFlowStyle(flowStyle);
}
List<Object> list = new ArrayList<>(1);
list.add(data);
StringWriter buffer = new StringWriter();
dumpAll(list.iterator(), buffer, rootTag);
representer.setDefaultFlowStyle(oldStyle);
return buffer.toString();
}
/**
* <p>
* Serialize a Java object into a YAML string. Override the default root tag
* with {@code Tag.MAP}.
* </p>
* <p>
* This method is similar to {@code Yaml.dump(data)} except that the
* root tag for the whole document is replaced with {@code Tag.MAP} tag
* (implicit !!map).
* </p>
* <p>
* Block Mapping is used as the collection style. See 10.2.2. Block Mappings
* (http://yaml.org/spec/1.1/#id934537)
* </p>
*
* @param data Java object to be serialized to YAML
* @return YAML String
*/
public String dumpAsMap(Object data) {
return dumpAs(data, Tag.MAP, FlowStyle.BLOCK);
}
/**
* Serialize the representation tree into Events.
*
* @param data representation tree
* @return Event list
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
*/
public List<Event> serialize(Node data) {
SilentEmitter emitter = new SilentEmitter();
Serializer serializer = new Serializer(emitter, resolver, dumperOptions, null);
try {
serializer.open();
serializer.serialize(data);
serializer.close();
} catch (IOException e) {
throw new YAMLException(e);
}
return emitter.getEvents();
}
/**
* Parse the only YAML document in a String and produce the corresponding
* Java object. (Because the encoding in known BOM is not respected.)
*
* @param yaml YAML data to load from (BOM must not be present)
* @return parsed object
*/
public Object load(String yaml) {
return loadFromReader(new StreamReader(yaml), Object.class);
}
/**
* Parse the only YAML document in a stream and produce the corresponding
* Java object.
*
* @param io data to load from (BOM is respected and removed)
* @return parsed object
*/
public Object load(InputStream io) {
return loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class);
}
/**
* Parse the only YAML document in a stream and produce the corresponding
* Java object.
*
* @param io data to load from (BOM must not be present)
* @return parsed object
*/
public Object load(Reader io) {
return loadFromReader(new StreamReader(io), Object.class);
}
/**
* 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 type Class of the object to be created
* @return parsed object
*/
@SuppressWarnings("unchecked")
public <T> T loadAs(Reader io, Class<T> type) {
return (T) loadFromReader(new StreamReader(io), type);
}
/**
* 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 yaml YAML data to load from (BOM must not be present)
* @param type Class of the object to be created
* @return parsed object
*/
@SuppressWarnings("unchecked")
public <T> T loadAs(String yaml, Class<T> type) {
return (T) loadFromReader(new StreamReader(yaml), type);
}
/**
* Parse the only YAML document in a stream and produce the corresponding
* Java object.
*
* @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
* @return parsed object
*/
@SuppressWarnings("unchecked")
public <T> T loadAs(InputStream input, Class<T> type) {
return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type);
}
private Object loadFromReader(StreamReader sreader, Class<?> type) {
Composer composer = new Composer(new ParserImpl(sreader), resolver);
constructor.setComposer(composer);
return constructor.getSingleData(type);
}
/**
* Parse all YAML documents in a String and produce corresponding Java
* objects. The documents are parsed only when the iterator is invoked.
*
* @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
*/
public Iterable<Object> loadAll(Reader yaml) {
Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
constructor.setComposer(composer);
Iterator<Object> result = new Iterator<Object>() {
public boolean hasNext() {
return constructor.checkData();
}
public Object next() {
return constructor.getData();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
return new YamlIterable(result);
}
/**
* Parse all YAML documents in a String and produce corresponding Java
* objects. (Because the encoding in known BOM is not respected.) The
* documents are parsed only when the iterator is invoked.
*
* @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
*/
public Iterable<Object> loadAll(String yaml) {
return loadAll(new StringReader(yaml));
}
/**
* Parse all YAML documents in a stream and produce corresponding Java
* objects. The documents are parsed only when the iterator is invoked.
*
* @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
*/
public Iterable<Object> loadAll(InputStream yaml) {
return loadAll(new UnicodeReader(yaml));
}
/**
* Parse the first YAML document in a stream and produce the corresponding
* representation tree. (This is the opposite of the represent() method)
*
* @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>
*/
public Node compose(Reader yaml) {
Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
constructor.setComposer(composer);
return composer.getSingleNode();
}
/**
* Parse all YAML documents in a stream and produce corresponding
* representation trees.
*
* @param yaml stream of YAML documents
* @return parsed root Nodes for all the specified YAML documents
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
*/
public Iterable<Node> composeAll(Reader yaml) {
final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
constructor.setComposer(composer);
Iterator<Node> result = new Iterator<Node>() {
public boolean hasNext() {
return composer.checkNode();
}
public Node next() {
return composer.getNode();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
return new NodeIterable(result);
}
/**
* 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 regexp regular expression to match against
* @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);
}
@Override
public String toString() {
return name;
}
/**
* Get a meaningful name. It simplifies debugging in a multi-threaded
* environment. If nothing is set explicitly the address of the instance is
* returned.
*
* @return human readable name
*/
public String getName() {
return name;
}
/**
* Set a meaningful name to be shown in {@code toString()}.
*
* @param name human readable name
*/
public void setName(String name) {
this.name = name;
}
/**
* Parse a YAML stream and produce parsing events.
*
* @param yaml YAML document(s)
* @return parsed events
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
*/
public Iterable<Event> parse(Reader yaml) {
final Parser parser = new ParserImpl(new StreamReader(yaml));
Iterator<Event> result = new Iterator<Event>() {
public boolean hasNext() {
return parser.peekEvent() != null;
}
public Event next() {
return parser.getEvent();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
return new EventIterable(result);
}
public void setBeanAccess(BeanAccess beanAccess) {
constructor.getPropertyUtils().setBeanAccess(beanAccess);
representer.getPropertyUtils().setBeanAccess(beanAccess);
}
private static class SilentEmitter implements Emitable {
private final List<Event> events = new ArrayList<>(100);
public List<Event> getEvents() {
return events;
}
public void emit(Event event) throws IOException {
events.add(event);
}
}
private static class YamlIterable implements Iterable<Object> {
private final Iterator<Object> iterator;
public YamlIterable(Iterator<Object> iterator) {
this.iterator = iterator;
}
public Iterator<Object> iterator() {
return iterator;
}
}
private static class NodeIterable implements Iterable<Node> {
private final Iterator<Node> iterator;
public NodeIterable(Iterator<Node> iterator) {
this.iterator = iterator;
}
public Iterator<Node> iterator() {
return iterator;
}
}
private static class EventIterable implements Iterable<Event> {
private final Iterator<Event> iterator;
public EventIterable(Iterator<Event> iterator) {
this.iterator = iterator;
}
public Iterator<Event> iterator() {
return iterator;
}
}
}

Datei anzeigen

@ -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 org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.representer.Representer;
@ -127,7 +127,7 @@ public class YamlConfiguration extends FileConfiguration {
Map<?, ?> input;
try {
input = (Map<?, ?>) yaml.load(contents);
input = yaml.load(contents);
} catch (final YAMLException e) {
throw new InvalidConfigurationException(e);
} catch (final ClassCastException e) {
@ -193,8 +193,7 @@ public class YamlConfiguration extends FileConfiguration {
if (options().copyHeader()) {
final Configuration def = getDefaults();
if (def != null && def instanceof FileConfiguration) {
final FileConfiguration filedefaults = (FileConfiguration) def;
if (def != null && def instanceof final FileConfiguration filedefaults) {
final String defaultsHeader = filedefaults.buildHeader();
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {

Datei anzeigen

@ -27,28 +27,6 @@ public class ConfigurationSerialization {
this.clazz = clazz;
}
/**
* Attempts to deserialize the given arguments into a new instance of the
* given class.
* <p>
* <p>The class must implement {@link ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p>
* <p>
* <p>If a new instance could not be made, an example being the class not
* fully implementing the interface, null will be returned.</p>
*
* @param args Arguments for deserialization
* @param clazz Class to deserialize into
* @return New instance of the specified class
*/
public static ConfigurationSerializable deserializeObject(
Map<String, ?> args,
Class<? extends ConfigurationSerializable> clazz
) {
return new ConfigurationSerialization(clazz).deserialize(args);
}
/**
* Attempts to deserialize the given arguments into a new instance of the
* <p>
@ -66,7 +44,7 @@ public class ConfigurationSerialization {
* @return New instance of the specified class
*/
public static ConfigurationSerializable deserializeObject(Map<String, ?> args) {
Class<? extends ConfigurationSerializable> clazz = null;
Class<? extends ConfigurationSerializable> clazz;
if (args.containsKey(SERIALIZED_TYPE_KEY)) {
try {
@ -116,25 +94,6 @@ public class ConfigurationSerialization {
aliases.put(alias, clazz);
}
/**
* Unregisters the specified alias to a {@link ConfigurationSerializable}
*
* @param alias Alias to unregister
*/
public static void unregisterClass(String alias) {
aliases.remove(alias);
}
/**
* Unregisters any aliases for the specified {@link ConfigurationSerializable} class.
*
* @param clazz Class to unregister
*/
public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) {
while (aliases.values().remove(clazz)) {
}
}
/**
* Attempts to get a registered {@link ConfigurationSerializable} class by
* its alias.

Datei anzeigen

@ -2,7 +2,6 @@ package com.fastasyncworldedit.core.entity;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.util.TaskManager;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.entity.EntityType;

Datei anzeigen

@ -20,6 +20,7 @@ public interface MapMetadatable extends Metadatable {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
default <T> T getAndSetMeta(String key, T value) {
return (T) getRawMeta().put(key, value);
}
@ -40,6 +41,7 @@ public interface MapMetadatable extends Metadatable {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
default <V> V getMeta(String key) {
return (V) getRawMeta().get(key);
}
@ -49,6 +51,7 @@ public interface MapMetadatable extends Metadatable {
*/
@Nonnull
@Override
@SuppressWarnings("unchecked")
default <V> V getMeta(String key, @Nonnull V def) {
V value = (V) getRawMeta().get(key);
return value == null ? def : value;
@ -58,6 +61,7 @@ public interface MapMetadatable extends Metadatable {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
default <V> V deleteMeta(String key) {
return (V) getRawMeta().remove(key);
}

Datei anzeigen

@ -65,8 +65,7 @@ public class PasteEvent extends Event implements Cancellable {
* @return a new event
*/
public PasteEvent clone(Stage stage) {
PasteEvent clone = new PasteEvent(actor, clipboard, uri, extent, to);
return clone;
return new PasteEvent(actor, clipboard, uri, extent, to);
}
}

Datei anzeigen

@ -109,17 +109,13 @@ public class RichMaskParser extends FaweParser<Mask> {
// Legacy syntax
if (charMask) {
switch (char0) {
case '\\':
case '/':
case '{':
case '|':
case '~': {
case '\\', '/', '{', '|', '~' -> {
String value = command.substring(1) + ((entry.getValue().isEmpty())
? ""
: "[" + StringMan.join(
entry.getValue(),
"]["
) + "]");
entry.getValue(),
"]["
) + "]");
if (value.contains(":")) {
if (value.charAt(0) == ':') {
value = value.replaceFirst(":", "");
@ -127,15 +123,11 @@ public class RichMaskParser extends FaweParser<Mask> {
value = value.replaceAll(":", "][");
}
mask = parseFromInput(char0 + "[" + value + "]", context);
break;
}
case '%':
case '$':
case '<':
case '>':
case '!':
case '%', '$', '<', '>', '!' -> {
input = input.substring(input.indexOf(char0) + 1);
mask = parseFromInput(char0 + "[" + input + "]", context);
}
}
}
if (mask == null) {

Datei anzeigen

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

Datei anzeigen

@ -30,15 +30,11 @@ public class Linear2DPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -30,16 +30,11 @@ public class Linear3DPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
case 3:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -29,16 +29,11 @@ public class LinearPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
case 3:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -26,15 +26,11 @@ public class MaskedPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getMaskFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getMaskFactory().getSuggestions(argumentInput).stream();
case 1, 2 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -26,16 +26,11 @@ public class OffsetPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
case 3:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -26,16 +26,11 @@ public class RandomOffsetPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
case 3:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -26,16 +26,11 @@ public class SolidRandomOffsetPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
case 2:
case 3:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -26,14 +26,11 @@ public class SurfaceRandomOffsetPatternParser extends RichParser<Pattern> {
@Override
protected Stream<String> getSuggestions(String argumentInput, int index) {
switch (index) {
case 0:
return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1:
return SuggestionHelper.suggestPositiveIntegers(argumentInput);
default:
return Stream.empty();
}
return switch (index) {
case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream();
case 1 -> SuggestionHelper.suggestPositiveIntegers(argumentInput);
default -> Stream.empty();
};
}
@Override

Datei anzeigen

@ -50,8 +50,8 @@ public class RandomTransformParser extends InputParser<ResettableExtent> {
return null;
}
RandomTransform randomTransform = new RandomTransform();
for (int i = 0; i < split.size(); i++) {
ResettableExtent transform = worldEdit.getTransformFactory().parseFromInput(split.get(i), context);
for (String s : split) {
ResettableExtent transform = worldEdit.getTransformFactory().parseFromInput(s, context);
randomTransform.add(transform, 1d);
}
return randomTransform;

Datei anzeigen

@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.util.Optional;
import java.util.function.Function;
@SuppressWarnings({"rawtypes", "unchecked"})
public class Bindings {
private static final Logger LOGGER = LogManagerCompat.getLogger();

Datei anzeigen

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.extension.platform.binding;
import com.sk89q.worldedit.WorldEdit;
@SuppressWarnings("unused")
public class CommandBindings extends Bindings {
public CommandBindings(WorldEdit worldEdit) {

Datei anzeigen

@ -32,6 +32,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
import java.util.UUID;
@SuppressWarnings("unused")
public class ConsumeBindings extends Bindings {
private final PlatformCommandManager manager;

Datei anzeigen

@ -15,6 +15,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nullable;
import java.util.Locale;
@SuppressWarnings("unused")
public class PrimitiveBindings extends Bindings {
public PrimitiveBindings(WorldEdit worldEdit) {
@ -48,26 +49,12 @@ public class PrimitiveBindings extends Bindings {
*/
@Binding
public Boolean getBoolean(String argument) {
switch (argument.toLowerCase(Locale.ROOT)) {
case "":
throw new InputParseException(Caption.of("fawe.error.input-parser-exception"));
case "true":
case "yes":
case "on":
case "y":
case "1":
case "t":
return true;
case "false":
case "no":
case "off":
case "f":
case "n":
case "0":
return false;
default:
throw new InputParseException(Caption.of("fawe.error.invalid-boolean", TextComponent.of(argument)));
}
return switch (argument.toLowerCase(Locale.ROOT)) {
case "" -> throw new InputParseException(Caption.of("fawe.error.input-parser-exception"));
case "true", "yes", "on", "y", "1", "t" -> true;
case "false", "no", "off", "f", "n", "0" -> false;
default -> throw new InputParseException(Caption.of("fawe.error.invalid-boolean", TextComponent.of(argument)));
};
}
/**
@ -84,18 +71,13 @@ public class PrimitiveBindings extends Bindings {
final double radiusY;
final double radiusZ;
switch (radii.length) {
case 1:
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
break;
case 3:
case 1 -> radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
case 3 -> {
radiusX = PrimitiveBindings.parseNumericInput(radii[0]);
radiusY = PrimitiveBindings.parseNumericInput(radii[1]);
radiusZ = PrimitiveBindings.parseNumericInput(radii[2]);
break;
default:
throw new InputParseException("You must either specify 1 or 3 radius values.");
}
default -> throw new InputParseException("You must either specify 1 or 3 radius values.");
}
return Vector3.at(radiusX, radiusY, radiusZ);
}
@ -115,17 +97,12 @@ public class PrimitiveBindings extends Bindings {
final double radiusX;
final double radiusZ;
switch (radii.length) {
case 1:
radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
break;
case 2:
case 1 -> radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
case 2 -> {
radiusX = PrimitiveBindings.parseNumericInput(radii[0]);
radiusZ = PrimitiveBindings.parseNumericInput(radii[1]);
break;
default:
throw new InputParseException("You must either specify 1 or 2 radius values.");
}
default -> throw new InputParseException("You must either specify 1 or 2 radius values.");
}
return Vector2.at(radiusX, radiusZ);
}
@ -145,18 +122,13 @@ public class PrimitiveBindings extends Bindings {
final double radiusY;
final double radiusZ;
switch (radii.length) {
case 1:
radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
break;
case 3:
case 1 -> radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]);
case 3 -> {
radiusX = PrimitiveBindings.parseNumericInput(radii[0]);
radiusY = PrimitiveBindings.parseNumericInput(radii[1]);
radiusZ = PrimitiveBindings.parseNumericInput(radii[2]);
break;
default:
throw new InputParseException("You must either specify 1 or 3 radius values.");
}
default -> throw new InputParseException("You must either specify 1 or 3 radius values.");
}
return BlockVector3.at(radiusX, radiusY, radiusZ);
}
@ -175,17 +147,12 @@ public class PrimitiveBindings extends Bindings {
final double radiusX;
final double radiusZ;
switch (radii.length) {
case 1:
radiusX = radiusZ = parseNumericInput(radii[0]);
break;
case 2:
case 1 -> radiusX = radiusZ = parseNumericInput(radii[0]);
case 2 -> {
radiusX = parseNumericInput(radii[0]);
radiusZ = parseNumericInput(radii[1]);
break;
default:
throw new InputParseException("You must either specify 1 or 2 radius values.");
}
default -> throw new InputParseException("You must either specify 1 or 2 radius values.");
}
return BlockVector2.at(radiusX, radiusZ);
}

Datei anzeigen

@ -125,8 +125,7 @@ public class ProvideBindings extends Bindings {
return extent;
}
EditSession editSession = editSession(getLocalSession(actor), actor, access);
if (access instanceof InjectedValueStore) {
InjectedValueStore store = (InjectedValueStore) access;
if (access instanceof InjectedValueStore store) {
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
}
return editSession;

Datei anzeigen

@ -101,6 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
return super.setBlock(x, y, z, block);
}
@SuppressWarnings("unchecked")
private <B extends BlockStateHolder<B>> B checkBlock(B block) {
if (blockedBlocks != null) {
if (blockedBlocks.contains(block.getBlockType().getId())) {

Datei anzeigen

@ -65,11 +65,11 @@ public class StripNBTExtent extends AbstractDelegateExtent implements IBatchProc
return super.createEntity(location, stripEntityNBT(entity));
}
@SuppressWarnings("unchecked")
public <B extends BlockStateHolder<B>> B stripBlockNBT(B block) {
if (!(block instanceof BaseBlock)) {
if (!(block instanceof BaseBlock localBlock)) {
return block;
}
BaseBlock localBlock = (BaseBlock) block;
if (!localBlock.hasNbtData()) {
return block;
}

Datei anzeigen

@ -93,6 +93,7 @@ public class TransformExtent extends BlockTransformExtent {
}
@Override
@SuppressWarnings("unchecked")
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return super.setBlock(getPos(x, y, z), transformInverse(block));
@ -100,6 +101,7 @@ public class TransformExtent extends BlockTransformExtent {
@Override
@SuppressWarnings("unchecked")
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException {
return super.setBlock(getPos(location), transformInverse(block));

Datei anzeigen

@ -107,7 +107,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
}
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
IntTriple key = entry.getKey();
setTile(getIndex(key.getX(), key.getY(), key.getZ()), entry.getValue());
setTile(getIndex(key.x(), key.y(), key.z()), entry.getValue());
}
nbtMapLoc.clear();
}

Datei anzeigen

@ -379,7 +379,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple key = entry.getKey();
int index = getIndex(key.getX(), key.getY(), key.getZ());
int index = getIndex(key.x(), key.y(), key.z());
if (index == i) {
nbt = entry.getValue();
break;

Datei anzeigen

@ -42,8 +42,6 @@ public abstract class LinearClipboard extends SimpleClipboard {
/**
* The locations provided are relative to the clipboard min
*
* @param task
*/
public abstract void streamBiomes(IntValueReader task);
@ -63,27 +61,25 @@ public abstract class LinearClipboard extends SimpleClipboard {
@Override
public Iterator<BlockVector3> iterator(Order order) {
Region region = getRegion();
switch (order) {
case YZX:
if (region instanceof CuboidRegion) {
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
LinearFilter filter = new LinearFilter();
if (order == Order.YZX) {
if (region instanceof CuboidRegion) {
Iterator<BlockVector3> iter = ((CuboidRegion) region).iterator_old();
LinearFilter filter = new LinearFilter();
return new ForwardingIterator<BlockVector3>() {
@Override
protected Iterator<BlockVector3> delegate() {
return iter;
}
return new ForwardingIterator<>() {
@Override
protected Iterator<BlockVector3> delegate() {
return iter;
}
@Override
public BlockVector3 next() {
return filter.next(super.next());
}
};
}
default:
return order.create(region);
@Override
public BlockVector3 next() {
return filter.next(super.next());
}
};
}
}
return order.create(region);
}

Datei anzeigen

@ -215,7 +215,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
nbt = null;
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
IntTriple trio = entry.getKey();
int index = getIndex(trio.getX(), trio.getY(), trio.getZ());
int index = getIndex(trio.x(), trio.y(), trio.z());
if (index == i) {
nbt = entry.getValue();
break;
@ -308,10 +308,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override
public List<? extends Entity> getEntities(Region region) {
return new ArrayList<>(entities
return entities
.stream()
.filter(e -> region.contains(e.getLocation().toBlockPoint()))
.collect(Collectors.toList()));
.filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList());
}
@Override

Datei anzeigen

@ -69,8 +69,7 @@ public class MultiClipboardHolder extends URIClipboardHolder {
@Override
public URI getURI(Clipboard clipboard) {
for (ClipboardHolder holder : getHolders()) {
if (holder instanceof URIClipboardHolder) {
URIClipboardHolder uriHolder = (URIClipboardHolder) holder;
if (holder instanceof URIClipboardHolder uriHolder) {
URI uri = uriHolder.getURI(clipboard);
if (uri != null) {
return uri;

Datei anzeigen

@ -66,12 +66,10 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory {
try {
while (iterator.hasNext()) {
Change change = iterator.next();
if (change instanceof MutableBlockChange) {
MutableBlockChange blockChange = (MutableBlockChange) change;
if (change instanceof MutableBlockChange blockChange) {
BlockState block = BlockState.getFromOrdinal(blockChange.ordinal);
clipboard.setBlock(blockChange.x, blockChange.y, blockChange.z, block);
} else if (change instanceof MutableTileChange) {
MutableTileChange tileChange = (MutableTileChange) change;
} else if (change instanceof MutableTileChange tileChange) {
int x = tileChange.tag.getInt("x");
int y = tileChange.tag.getInt("y");
int z = tileChange.tag.getInt("z");

Datei anzeigen

@ -275,8 +275,7 @@ public class FastSchematicReader extends NBTSchematicReader {
if (blocksOut != null && blocksOut.getSize() != 0) {
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) {
if (clipboard instanceof LinearClipboard) {
LinearClipboard linear = (LinearClipboard) clipboard;
if (clipboard instanceof LinearClipboard linear) {
int volume = width * height * length;
if (palette.length < 128) {
for (int index = 0; index < volume; index++) {

Datei anzeigen

@ -99,7 +99,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
for (Map.Entry<String, Tag> entry : properties.getValue().entrySet()) {
String key = entry.getKey();
String value = ((StringTag) entry.getValue()).getValue();
Property property = type.getProperty(key);
Property<Object> property = type.getProperty(key);
state = state.with(property, property.getValueFor(value));
}
}

Datei anzeigen

@ -9,6 +9,7 @@ public abstract class ForkedFilter<T extends ForkedFilter<T>> implements Filter
protected final Map<Thread, T> children;
@SuppressWarnings("unchecked")
public ForkedFilter(T root) {
if (root != null) {
children = root.children;

Datei anzeigen

@ -12,6 +12,7 @@ public abstract class DelegateFilter<T extends Filter> implements IDelegateFilte
}
@Override
@SuppressWarnings("unchecked")
public final T getParent() {
return (T) parent;
}

Datei anzeigen

@ -20,8 +20,6 @@ public interface IBatchProcessorHolder extends IBatchProcessor {
/**
* Set the held processor
*
* @param set
*/
void setProcessor(IBatchProcessor set);

Datei anzeigen

@ -55,14 +55,11 @@ public class MultiBatchProcessor implements IBatchProcessor {
list.add(processor);
}
}
switch (list.size()) {
case 0:
return EmptyBatchProcessor.getInstance();
case 1:
return list.get(0);
default:
return new MultiBatchProcessor(list.toArray(new IBatchProcessor[0]));
}
return switch (list.size()) {
case 0 -> EmptyBatchProcessor.getInstance();
case 1 -> list.get(0);
default -> new MultiBatchProcessor(list.toArray(new IBatchProcessor[0]));
};
}
public void addBatchProcessor(IBatchProcessor processor) {

Datei anzeigen

@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
@SuppressWarnings("rawtypes")
public class NMSRelighter implements Relighter {
private static final int DISPATCH_SIZE = 64;
@ -988,11 +989,10 @@ public class NMSRelighter implements Relighter {
return;
}
switch (reason) {
case SkipReason.SOLID: {
case SkipReason.SOLID -> {
Arrays.fill(mask, (byte) 0);
return;
}
case SkipReason.AIR: {
case SkipReason.AIR -> {
int index = 0;
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {

Datei anzeigen

@ -26,8 +26,6 @@ public class OreGen implements Resource {
private final double ONE_8 = 1 / 8F;
private final double ONE_16 = 1 / 16F;
public int laced = 0;
public OreGen(Extent extent, Mask mask, Pattern pattern, int size, int minY, int maxY) {
this.maxSize = size;
this.maxSizeO8 = size * ONE_8;

Datei anzeigen

@ -55,8 +55,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
@Override
public Mask tryCombine(Mask mask) {
if (mask instanceof ABlockMask) {
ABlockMask other = (ABlockMask) mask;
if (mask instanceof ABlockMask other) {
BlockMask newMask = new BlockMask(getExtent());
for (BlockState state : BlockTypesCache.states) {
if (state != null) {
@ -76,8 +75,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
@Override
public Mask tryOr(Mask mask) {
if (mask instanceof ABlockMask) {
ABlockMask other = (ABlockMask) mask;
if (mask instanceof ABlockMask other) {
BlockMask newMask = new BlockMask(getExtent());
for (BlockState state : BlockTypesCache.states) {
if (state != null) {

Datei anzeigen

@ -161,16 +161,13 @@ public class BlockMaskBuilder {
for (int i = last; i < length; i++) {
char c = input.charAt(i);
switch (c) {
case '[':
case '{':
case '(':
case '[', '{', '(' -> {
int next = StringMan.findMatchingBracket(input, i);
if (next != -1) {
i = next;
}
break;
case ']':
case ',': {
}
case ']', ',' -> {
charSequence.setSubstring(last, i);
if (key == null && PropertyKey.getByName(charSequence) == null) {
suggest(
@ -218,35 +215,21 @@ public class BlockMaskBuilder {
key = null;
operator = null;
last = i + 1;
break;
}
case '~':
case '!':
case '=':
case '<':
case '>': {
case '~', '!', '=', '<', '>' -> {
charSequence.setSubstring(last, i);
boolean extra = input.charAt(i + 1) == '=';
if (extra) {
i++;
}
switch (c) {
case '~':
operator = EQUAL_OR_NULL;
break;
case '!':
operator = NOT;
break;
case '=':
operator = EQUAL;
break;
case '<':
operator = extra ? LESS_EQUAL : LESS;
break;
case '>':
operator = extra ? GREATER_EQUAL : GREATER;
break;
}
operator = switch (c) {
case '~' -> EQUAL_OR_NULL;
case '!' -> NOT;
case '=' -> EQUAL;
case '<' -> extra ? LESS_EQUAL : LESS;
case '>' -> extra ? GREATER_EQUAL : GREATER;
default -> operator;
};
if (charSequence.length() > 0 || key == null) {
key = PropertyKey.getByName(charSequence);
if (key == null) {
@ -258,10 +241,9 @@ public class BlockMaskBuilder {
}
}
last = i + 1;
break;
}
default:
break;
default -> {
}
}
}
} else {
@ -395,6 +377,7 @@ public class BlockMaskBuilder {
return this;
}
@SuppressWarnings({"unchecked", "rawtypes"})
public <T> BlockMaskBuilder filter(
Predicate<BlockType> typePredicate,
BiPredicate<BlockType, Map.Entry<Property<T>, T>> allowed
@ -491,6 +474,7 @@ public class BlockMaskBuilder {
return this;
}
@SuppressWarnings({"unchecked", "rawtypes"})
public BlockMaskBuilder addAll(
Predicate<BlockType> typePredicate,
BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate

Datei anzeigen

@ -13,7 +13,6 @@ public class ExtremaMask extends AngleMask {
protected boolean testSlope(Extent extent, int x, int y, int z) {
double slope;
double tmp;
boolean aboveMin;
lastY = y;
int base = getHeight(extent, x, y, z);

Datei anzeigen

@ -55,14 +55,11 @@ public class MaskUnion extends MaskIntersection {
}
}
}
switch (set.size()) {
case 0:
return Masks.alwaysTrue();
case 1:
return set.iterator().next();
default:
return new MaskUnion(masks).optimize();
}
return switch (set.size()) {
case 0 -> Masks.alwaysTrue();
case 1 -> set.iterator().next();
default -> new MaskUnion(masks).optimize();
};
}
@Override

Datei anzeigen

@ -51,8 +51,7 @@ public class SingleBlockStateMask extends ABlockMask {
@Override
public Mask tryCombine(Mask mask) {
if (mask instanceof ABlockMask) {
ABlockMask other = (ABlockMask) mask;
if (mask instanceof ABlockMask other) {
if (other.test(BlockState.getFromOrdinal(ordinal))) {
return this;
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.fastasyncworldedit.core.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
@ -9,7 +8,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;
public YAxisMask(Extent extent) {
public YAxisMask() {
}
@Override
@ -27,7 +26,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
@Override
public Mask copy() {
return new YAxisMask(null);
return new YAxisMask();
}
}

Datei anzeigen

@ -19,6 +19,7 @@ public class PatternTraverser {
reset(pattern, newExtent);
}
@SuppressWarnings({"unchecked"})
private void reset(Object pattern, Extent newExtent) {
if (pattern == null) {
return;

Datei anzeigen

@ -95,9 +95,9 @@ public abstract class DFSVisitor implements Operation {
int countAdd = 0;
int countAttempt = 0;
for (IntTriple direction : dirs) {
mutable2.mutX(from.getX() + direction.getX());
mutable2.mutY(from.getY() + direction.getY());
mutable2.mutZ(from.getZ() + direction.getZ());
mutable2.mutX(from.getX() + direction.x());
mutable2.mutY(from.getY() + direction.y());
mutable2.mutZ(from.getZ() + direction.z());
if (isVisitable(mutable, mutable2)) {
Node adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
if (!adjacent.equals(current.from)) {
@ -175,7 +175,7 @@ public abstract class DFSVisitor implements Operation {
}
@Override
public final int hashCode() {
public int hashCode() {
return (x ^ (z << 12)) ^ (y << 24);
}
@ -208,17 +208,7 @@ public abstract class DFSVisitor implements Operation {
}
public static class NodePair {
public final Node to;
public final Node from;
private final int depth;
NodePair(Node from, Node to, int depth) {
this.from = from;
this.to = to;
this.depth = depth;
}
public record NodePair(Node from, Node to, int depth) {
}

Datei anzeigen

@ -4,13 +4,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
public class IntersectRegionFunction implements RegionFunction {
private final RegionFunction[] functions;
public IntersectRegionFunction(RegionFunction... functions) {
this.functions = functions;
}
public record IntersectRegionFunction(RegionFunction... functions) implements RegionFunction {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {

Datei anzeigen

@ -50,6 +50,7 @@ public class MutableEntityChange implements Change {
}
}
@SuppressWarnings({"unchecked"})
public void delete(UndoContext context) {
Map<String, Tag> map = tag.getValue();
long most;

Datei anzeigen

@ -38,9 +38,7 @@ public abstract class CompressedCompoundTag<T> extends CompoundTag {
CompoundTag tag = (CompoundTag) nbtIn.readTag();
Map<String, Tag> value = tag.getValue();
Map<String, Tag> raw = super.getValue();
for (Map.Entry<String, Tag> entry : value.entrySet()) {
raw.put(entry.getKey(), entry.getValue());
}
raw.putAll(value);
} catch (IOException e) {
throw new RuntimeException(e);
}

Datei anzeigen

@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Stack;
import java.util.regex.Pattern;
@SuppressWarnings({"unchecked", "rawtypes"})
public class JSON2NBT {
private static final Pattern INT_ARRAY_MATCHER = Pattern.compile("\\[[-+\\d|,\\s]+\\]");
@ -56,11 +57,11 @@ public class JSON2NBT {
}
} else if (!flag) {
if (c0 != 123 && c0 != 91) {
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
if (c0 == 125 && (stack.isEmpty() || (Character) stack.pop() != 123)) {
throw new NBTException("Unbalanced curly brackets {}: " + str);
}
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
if (c0 == 93 && (stack.isEmpty() || (Character) stack.pop() != 91)) {
throw new NBTException("Unbalanced square brackets []: " + str);
}
} else {
@ -68,7 +69,7 @@ public class JSON2NBT {
++i;
}
stack.push(Character.valueOf(c0));
stack.push(c0);
}
}
}
@ -93,7 +94,6 @@ public class JSON2NBT {
private static JSON2NBT.Any nameValueToNBT(String key, String value) throws NBTException {
value = value.trim();
String s;
boolean c0;
char c01;
if (value.startsWith("{")) {
value = value.substring(1, value.length() - 1);
@ -102,7 +102,6 @@ public class JSON2NBT {
for (JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, true);
if (s.length() > 0) {
c0 = false;
JSON2NBT$list1.tagList.add(getTagFromNameValue(s, false));
}
@ -124,7 +123,6 @@ public class JSON2NBT {
for (JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, false);
if (s.length() > 0) {
c0 = true;
JSON2NBT$list.tagList.add(getTagFromNameValue(s, true));
}
@ -392,10 +390,8 @@ public class JSON2NBT {
public Tag parse() throws NBTException {
ArrayList<Tag> list = new ArrayList<>();
Iterator var2 = this.tagList.iterator();
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
for (Any JSON2NBT$any : this.tagList) {
list.add(JSON2NBT$any.parse());
}
Class<? extends Tag> tagType = list.isEmpty() ? CompoundTag.class : list.get(0).getClass();
@ -414,10 +410,8 @@ public class JSON2NBT {
public Tag parse() throws NBTException {
HashMap<String, Tag> map = new HashMap<>();
Iterator var2 = this.tagList.iterator();
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
for (Any JSON2NBT$any : this.tagList) {
map.put(JSON2NBT$any.json, JSON2NBT$any.parse());
}

Datei anzeigen

@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger;
import java.io.DataInputStream;
import java.io.IOException;
@SuppressWarnings({"unchecked", "rawtypes"})
public class StreamDelegate {
private static final Logger LOGGER = LogManagerCompat.getLogger();

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen