Skip to content

Commit

Permalink
Merge branch 'main' into feat/improved-entity-operations
Browse files Browse the repository at this point in the history
# Conflicts:
#	worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java
  • Loading branch information
dordsor21 committed Jul 28, 2024
2 parents bfe5222 + 6052fc3 commit e444638
Show file tree
Hide file tree
Showing 63 changed files with 903 additions and 270 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT"
griefprevention = "17.0.0"
griefdefender = "2.1.0-SNAPSHOT"
residence = "4.5._13.1"
towny = "0.100.3.7"
towny = "0.100.3.9"
plotsquared = "7.3.8"

# Third party
Expand All @@ -23,7 +23,7 @@ sparsebitset = "1.3"
parallelgzip = "1.0.5"
adventure = "4.17.0"
adventure-bukkit = "4.3.3"
checkerqual = "3.44.0"
checkerqual = "3.45.0"
truezip = "6.8.4"
auto-value = "1.11.0"
findbugs = "3.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ public static URL upload(final Clipboard clipboard, final ClipboardFormat format
* @param file the file to load
* @return a clipboard containing the schematic
* @see ClipboardFormat
* @deprecated Opens streams that are not then closed. Use {@link ClipboardFormats#findByFile(File)} and its relevant
* methods to allow closing created streams/closing the reader (which will close the stream(s))
*/
@Deprecated(forRemoval = true, since = "TODO")
public static Clipboard load(File file) throws IOException {
return ClipboardFormats.findByFile(file).load(file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,22 @@ public V apply(final long input) {
Type.OUTSIDE_REGION
);
public static final FaweException MAX_CHECKS = new FaweException(
Caption.of("fawe.cancel.reason.max" + ".checks"),
Caption.of("fawe.cancel.reason.max.checks"),
Type.MAX_CHECKS,
true
);
public static final FaweException MAX_FAILS = new FaweException(
Caption.of("fawe.cancel.reason.max.fails"),
Type.MAX_CHECKS,
true
);
public static final FaweException MAX_CHANGES = new FaweException(
Caption.of("fawe.cancel.reason.max" + ".changes"),
Caption.of("fawe.cancel.reason.max.changes"),
Type.MAX_CHANGES,
false
);
public static final FaweException LOW_MEMORY = new FaweException(
Caption.of("fawe.cancel.reason.low" + ".memory"),
Caption.of("fawe.cancel.reason.low.memory"),
Type.LOW_MEMORY,
false
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public void build(EditSession editSession, BlockVector3 position, Pattern patter
CuboidRegion cuboid = new CuboidRegion(
editSession.getWorld(),
position.subtract(size1, size1, size1),
position.add(size1, size1, size1)
position.add(size1, size1, size1),
true
);
try {
editSession.addSchems(cuboid, mask, clipboards, rarity, randomRotate);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.fastasyncworldedit.core.extension.platform.binding;

import com.sk89q.worldedit.EditSession;

public record EditSessionHolder(EditSession session) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.database.DBHandler;
import com.fastasyncworldedit.core.database.RollbackDatabase;
import com.fastasyncworldedit.core.extent.LimitExtent;
import com.fastasyncworldedit.core.extent.processor.ExtentBatchProcessorHolder;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.util.TextureUtil;
import com.fastasyncworldedit.core.util.image.ImageUtil;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.util.annotation.AllowedRegion;
import com.sk89q.worldedit.command.util.annotation.SynchronousSettingExpected;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor;
Expand All @@ -25,6 +30,7 @@
import org.enginehub.piston.util.ValueProvider;

import java.awt.image.BufferedImage;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Optional;

Expand Down Expand Up @@ -52,11 +58,33 @@ public LocalSession getLocalSession(Actor actor) {

@Binding
public EditSession editSession(LocalSession localSession, Actor actor, InjectedValueAccess context) {
Method commandMethod =
context.injectedValue(Key.of(InjectedValueStore.class)).get().injectedValue(Key.of(Method.class)).get();

Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
String command = arguments == null ? null : arguments.get();
EditSession editSession = localSession.createEditSession(actor, command);
editSession.enableStandardMode();
Request.request().setEditSession(editSession);
boolean synchronousSetting = commandMethod.getAnnotation(SynchronousSettingExpected.class) != null;
EditSessionHolder holder = context.injectedValue(Key.of(EditSessionHolder.class)).orElse(null);
EditSession editSession = holder != null ? holder.session() : null;
if (editSession == null) {
editSession = localSession.createEditSession(actor, command, synchronousSetting);
editSession.enableStandardMode();
} else {
LimitExtent limitExtent = new ExtentTraverser<>(editSession).findAndGet(LimitExtent.class);
if (limitExtent != null) {
limitExtent.setProcessing(!synchronousSetting);
if (!synchronousSetting) {
ExtentBatchProcessorHolder processorHolder = new ExtentTraverser<>(editSession).findAndGet(
ExtentBatchProcessorHolder.class);
if (processorHolder != null) {
processorHolder.addProcessor(limitExtent);
} else {
throw new FaweException(Caption.of("fawe.error.no-process-non-synchronous-edit"));
}
}
}
Request.request().setEditSession(editSession);
}
return editSession;
}

Expand Down
Loading

0 comments on commit e444638

Please sign in to comment.