Merge branch 'version/7.2.x'

This commit is contained in:
Madeline Miller 2021-08-22 14:36:57 +10:00
commit 81f98b7b96
5 changed files with 51 additions and 35 deletions

View File

@ -11,6 +11,10 @@
- Support 48x48x48 //drawsel on new versions of Minecraft
- Fixed the offset mask forcing negation of itself
- Fixed //regen breaking when some certain mods are in use
- Fixed cycler tool removing NBT data
- Improved performance of event bus in situations where it was flooded with data
- Improve performance of poorly constructed masks with heavily-nested negation
- Fixed error when using /delchunks with non-cuboid regions
7.2.5
- Allow /toggleplace to work on any Locatable Actor, e.g. Command Blocks

View File

@ -59,7 +59,7 @@
"compileOnly"("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}")
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
"languageFiles"("${project.group}:worldedit-lang:7.2.6:289@zip")
"languageFiles"("${project.group}:worldedit-lang:7.2.6:355@zip")
"testRuntimeOnly"("org.apache.logging.log4j:log4j-core:2.14.1")
}

View File

@ -66,26 +66,12 @@ public static Mask negate(final Mask mask) {
return ALWAYS_FALSE;
} else if (mask instanceof AlwaysFalse) {
return ALWAYS_TRUE;
} else if (mask instanceof NegatedMask) {
return ((NegatedMask) mask).mask;
}
checkNotNull(mask);
return new AbstractMask() {
@Override
public boolean test(BlockVector3 vector) {
return !mask.test(vector);
}
@Nullable
@Override
public Mask2D toMask2D() {
Mask2D mask2d = mask.toMask2D();
if (mask2d != null) {
return negate(mask2d);
} else {
return null;
}
}
};
return new NegatedMask(mask);
}
/**
@ -99,15 +85,12 @@ public static Mask2D negate(final Mask2D mask) {
return ALWAYS_FALSE;
} else if (mask instanceof AlwaysFalse) {
return ALWAYS_TRUE;
} else if (mask instanceof NegatedMask2D) {
return ((NegatedMask2D) mask).mask;
}
checkNotNull(mask);
return new AbstractMask2D() {
@Override
public boolean test(BlockVector2 vector) {
return !mask.test(vector);
}
};
return new NegatedMask2D(mask);
}
/**
@ -167,4 +150,39 @@ public Mask2D toMask2D() {
}
}
private static class NegatedMask implements Mask {
private final Mask mask;
private NegatedMask(Mask mask) {
this.mask = mask;
}
@Override
public boolean test(BlockVector3 vector) {
return !mask.test(vector);
}
@Nullable
@Override
public Mask2D toMask2D() {
Mask2D mask2D = mask.toMask2D();
if (mask2D == null) {
return null;
}
return negate(mask2D);
}
}
private static class NegatedMask2D implements Mask2D {
private final Mask2D mask;
private NegatedMask2D(Mask2D mask) {
this.mask = mask;
}
@Override
public boolean test(BlockVector2 vector) {
return !mask.test(vector);
}
}
}

View File

@ -59,7 +59,7 @@ public final class ChunkDeleter {
);
private static final Gson chunkDeleterGson = new GsonBuilder()
.registerTypeAdapter(BlockVector2.class, new BlockVector2Adapter())
.registerTypeAdapter(BlockVector2.class, new BlockVector2Adapter().nullSafe())
.setPrettyPrinting()
.create();

View File

@ -19,9 +19,6 @@
package com.sk89q.worldedit.session.request;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.world.World;
@ -29,14 +26,11 @@
import javax.annotation.Nullable;
/**
* Describes the current request.
* Describes the current request using a {@link ThreadLocal}.
*/
public final class Request {
private static final LoadingCache<Thread, Request> THREAD_TO_REQUEST =
CacheBuilder.newBuilder()
.weakKeys()
.build(CacheLoader.from(Request::new));
private static final ThreadLocal<Request> threadLocal = ThreadLocal.withInitial(Request::new);
private @Nullable World world;
private @Nullable LocalSession session;
@ -106,7 +100,7 @@ public void setEditSession(@Nullable EditSession editSession) {
* @return the current request
*/
public static Request request() {
return THREAD_TO_REQUEST.getUnchecked(Thread.currentThread());
return threadLocal.get();
}
/**
@ -114,7 +108,7 @@ public static Request request() {
*/
public static void reset() {
request().invalidate();
THREAD_TO_REQUEST.invalidate(Thread.currentThread());
threadLocal.remove();
}
/**