Skip to content

Commit

Permalink
Merge branch 'main' into feat/alter-clipboard-thread-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dordsor21 authored Nov 6, 2024
2 parents 2f38ad6 + e55e8fa commit 31dbda5
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 67 deletions.
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ val properties = Properties().also { props ->
dependencies {
implementation(gradleApi())
implementation("org.ajoberstar.grgit:grgit-gradle:5.3.0")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.3")
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.3")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.4")
constraints {
val asmVersion = "[9.7,)"
implementation("org.ow2.asm:asm:$asmVersion") {
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ mapmanager = "1.8.0-SNAPSHOT"
griefprevention = "17.0.0"
griefdefender = "2.1.0-SNAPSHOT"
residence = "4.5._13.1"
towny = "0.100.4.5"
plotsquared = "7.3.11"
towny = "0.100.4.9"
plotsquared = "7.3.12"

# Third party
bstats = "3.1.0"
sparsebitset = "1.3"
parallelgzip = "1.0.5"
adventure = "4.17.0"
adventure-bukkit = "4.3.4"
checkerqual = "3.48.1"
checkerqual = "3.48.2"
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 @@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.TreeGenerator;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.BlockState;

import java.util.List;
import java.util.Map;

/**
* A base class for version-specific implementations of the BukkitImplAdapter
Expand All @@ -21,6 +24,16 @@
*/
public abstract class FaweAdapter<TAG, SERVER_LEVEL> extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<TAG> {

protected final BukkitImplAdapter<TAG> parent;
protected char[] ibdToStateOrdinal = null;
protected int[] ordinalToIbdID = null;
protected boolean initialised = false;
protected Map<String, List<Property<?>>> allBlockProperties = null;

protected FaweAdapter(final BukkitImplAdapter<TAG> parent) {
this.parent = parent;
}

@Override
public boolean generateTree(
final TreeGenerator.TreeType treeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ private Populator() {
@Override
protected void write(final MutableTileChange change, final CompoundTag tag) {
change.tag = tag;
change.create = create;
}

@Override
Expand Down Expand Up @@ -845,6 +846,7 @@ private Populator() {
@Override
protected void write(final MutableEntityChange change, final CompoundTag tag) {
change.tag = tag;
change.create = create;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ public int compareTo(@Nonnull PropertyKey o) {
return Integer.compare(this.id, o.id);
}

@Override
public String toString() {
return "PropertyKey[" + getName() + "]";
}

}
48 changes: 45 additions & 3 deletions worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
import com.sk89q.worldedit.regions.NullRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionIntersection;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
Expand Down Expand Up @@ -1804,18 +1805,59 @@ public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int stackCuboidRegion(
Region region, BlockVector3 offset, int count,
boolean copyEntities, boolean copyBiomes, Mask mask
Region region,
BlockVector3 offset,
int count,
boolean copyEntities,
boolean copyBiomes,
Mask mask
) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(offset);

BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
try {
return stackRegionBlockUnits(region, offset.multiply(size), count, copyEntities, copyBiomes, mask);
} catch (RegionOperationException e) {
// Should never be able to happen
throw new AssertionError(e);
}
}

/**
* Stack a region using block units.
*
* @param region the region to stack
* @param offset how far to move the contents each stack in block units
* @param count the number of times to stack
* @param copyEntities true to copy entities
* @param copyBiomes true to copy biomes
* @param mask source mask for the operation (only matching blocks are copied)
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
* @throws RegionOperationException thrown if the region operation is invalid
*/
public int stackRegionBlockUnits(
Region region,
BlockVector3 offset,
int count,
boolean copyEntities,
boolean copyBiomes,
Mask mask
) throws MaxChangedBlocksException, RegionOperationException {
checkNotNull(region);
checkNotNull(offset);
checkArgument(count >= 1, "count >= 1 required");

BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
BlockVector3 offsetAbs = offset.abs();
if (offsetAbs.x() < size.x() && offsetAbs.y() < size.y() && offsetAbs.z() < size.z()) {
throw new RegionOperationException(Caption.of("worldedit.stack.intersecting-region"));
}
BlockVector3 to = region.getMinimumPoint();
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
copy.setRepetitions(count);
copy.setTransform(new AffineTransform().translate(offset.multiply(size)));
copy.setTransform(new AffineTransform().translate(offset));
copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes);
final Region allowedRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public int move(
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
actor.printError(e.getRichMessage());
}
}

Expand Down Expand Up @@ -640,7 +640,7 @@ public int stack(
int count,
@Arg(desc = "How far to move the contents each stack", def = Offset.FORWARD)
@Offset
BlockVector3 direction,
BlockVector3 offset,
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
Expand All @@ -649,6 +649,8 @@ public int stack(
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@Switch(name = 'r', desc = "Use block units")
boolean blockUnits,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air")
Mask mask
) throws WorldEditException {
Expand All @@ -668,19 +670,24 @@ public int stack(
combinedMask = mask;
}

int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);
int affected;
if (blockUnits) {
affected = editSession.stackRegionBlockUnits(region, offset, count, copyEntities, copyBiomes, combinedMask);
} else {
affected = editSession.stackCuboidRegion(region, offset, count, copyEntities, copyBiomes, combinedMask);
}

if (moveSelection) {
try {
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);

final BlockVector3 shiftVector = direction.multiply(size).multiply(count);
final BlockVector3 shiftSize = blockUnits ? offset : offset.multiply(size);
final BlockVector3 shiftVector = shiftSize.multiply(count);
region.shift(shiftVector);

session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
actor.printError(TextComponent.of(e.getMessage()));
actor.printError(e.getRichMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (fe != null) {
printError(fe.getComponent());
} else {
LOGGER.error("Error in asyncNotifyQueue", throwable);
LOGGER.error("Error occurred executing player action", throwable);
}
}
}, this::getUniqueId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ public World getWorldForEditing(World base) {
public <T extends Actor> T createProxyActor(T base) {
checkNotNull(base);

if (base instanceof Player) {
Player player = (Player) base;

if (base instanceof Player player) {
Player permActor = queryCapability(Capability.PERMISSIONS).matchPlayer(player);
if (permActor == null) {
permActor = player;
Expand Down Expand Up @@ -389,10 +387,9 @@ public void handleBlockInteract(BlockInteractEvent event) {
Location location = event.getLocation();

// At this time, only handle interaction from players
if (!(actor instanceof Player)) {
if (!(actor instanceof Player player)) {
return;
}
Player player = (Player) actor;
LocalSession session = worldEdit.getSessionManager().get(actor);

Request.reset();
Expand Down Expand Up @@ -463,7 +460,7 @@ public void handleThrowable(Throwable e, Actor actor) {
} else {
actor.print(Caption.of("worldedit.command.error.report"));
actor.print(TextComponent.of(e.getClass().getName()+ ": " + e.getMessage()));
e.printStackTrace();
LOGGER.error("Error occurred executing player action", e);
}
}
//FAWE end
Expand Down Expand Up @@ -511,14 +508,7 @@ public void handlePlayerInput(PlayerInputEvent event) {
}
//FAWE start - add own message
} catch (Throwable e) {
FaweException faweException = FaweException.get(e);
if (faweException != null) {
player.print(Caption.of("fawe.cancel.reason", faweException.getComponent()));
} else {
player.print(Caption.of("worldedit.command.error.report"));
player.print(TextComponent.of(e.getClass().getName() + ": " + e.getMessage()));
e.printStackTrace();
}
handleThrowable(e, player);
//FAWE end
} finally {
Request.reset();
Expand Down
Loading

0 comments on commit 31dbda5

Please sign in to comment.