fix: processorExtent can be null in editsession

- fixes #2375
This commit is contained in:
dordsor21 2023-07-22 13:14:01 +01:00
parent 006ccd6887
commit 2f6de996e3
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 9 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
public class ExtentTraverser<T extends Extent> {
@ -24,6 +25,7 @@ public class ExtentTraverser<T extends Extent> {
return root != null;
}
@Nullable
public T get() {
return root;
}
@ -50,6 +52,7 @@ public class ExtentTraverser<T extends Extent> {
}
@SuppressWarnings("unchecked")
@Nullable
public <U> U findAndGet(Class<U> clazz) {
ExtentTraverser<Extent> traverser = find(clazz);
return (traverser != null) ? (U) traverser.get() : null;

View File

@ -529,10 +529,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
//FAWE start - ExtentTraverser & MaskingExtents
MaskingExtent maskingExtent = new ExtentTraverser<>(getExtent()).findAndGet(MaskingExtent.class);
if (maskingExtent == null) {
ExtentTraverser<ExtentBatchProcessorHolder> processorExtent =
new ExtentTraverser<>(getExtent()).find(ExtentBatchProcessorHolder.class);
maskingExtent =
new ProcessorTraverser<>(processorExtent.get().getProcessor()).find(MaskingExtent.class);
ExtentBatchProcessorHolder processorExtent =
new ExtentTraverser<>(getExtent()).findAndGet(ExtentBatchProcessorHolder.class);
if (processorExtent != null) {
maskingExtent =
new ProcessorTraverser<>(processorExtent.getProcessor()).find(MaskingExtent.class);
}
}
return maskingExtent != null ? maskingExtent.getMask() : null;
//FAWE end