Skip to content

Commit

Permalink
Merge branch 'EngineHub:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomamaeatstoes authored Oct 2, 2024
2 parents c2e6c56 + 305f0cb commit 13a2326
Show file tree
Hide file tree
Showing 24 changed files with 297 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ target
forge-download
out
run
.jqwik-database

/dependency-reduced-pom.xml
*-private.sh
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
7.3.6
- [Bukkit] Allow 1.21 Paper adapter to load on 1.21.1
- Revert "Shutdown the executor service on disable, to prevent waiting on async tasks before shutting down" due to it causing issues in some situations

7.3.5
- [Bukkit] Utilise new Bukkit registry API, allowing WorldEdit to work with Commodore disabled (`paper.disableOldApiSupport` flag on Paper)
- Fix queryRel not behaving correctly in //deform and the deform brush
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Java Edition required. WorldEdit is compatible with Forge, Fabric, Bukkit, Spigo

## Download WorldEdit

This place contains the Java code for WorldEdit, but if you want to just use WorldEdit, get the mod or plugin from these pages:
This place contains the Java code for WorldEdit, but if you want to just use WorldEdit, get the mod or plugin from Modrinth:

* For the mod: https://www.curseforge.com/minecraft/mc-mods/worldedit
* For the server plugin: https://dev.bukkit.org/projects/worldedit
https://modrinth.com/plugin/worldedit/versions

Edit the Code
---------
Expand Down
4 changes: 0 additions & 4 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ plugins {
id("io.papermc.paperweight.userdev")
}

configure<buildlogic.CommonJavaExtension> {
banSlf4j = false
}

paperweight {
injectPaperRepository = false
}
Expand Down
18 changes: 4 additions & 14 deletions build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ plugins {
id("buildlogic.common")
}

val commonJava = extensions.create<buildlogic.CommonJavaExtension>("commonJava")
commonJava.banSlf4j.convention(true)

tasks
.withType<JavaCompile>()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
Expand All @@ -33,14 +30,17 @@ configure<CheckstyleExtension> {
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
useJUnitPlatform {
includeEngines("junit-jupiter", "jqwik")
}
}

dependencies {
"compileOnly"(stringyLibs.getLibrary("jsr305"))
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
"testImplementation"(stringyLibs.getLibrary("jqwik"))
"testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
"testImplementation"(stringyLibs.getLibrary("mockito-core"))
"testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
Expand All @@ -67,16 +67,6 @@ configure<JavaPluginExtension> {
withSourcesJar()
}

configurations["compileClasspath"].apply {
resolutionStrategy.componentSelection {
withModule("org.slf4j:slf4j-api") {
if (commonJava.banSlf4j.get()) {
reject("No SLF4J allowed on compile classpath")
}
}
}
}

tasks.named("check").configure {
dependsOn("checkstyleMain", "checkstyleTest")
}
13 changes: 11 additions & 2 deletions build-logic/src/main/kotlin/buildlogic.platform.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import buildlogic.getLibrary
import buildlogic.stringyLibs

plugins {
id("com.github.johnrengelman.shadow")
id("buildlogic.core-and-platform")
Expand All @@ -9,17 +12,23 @@ platform.extraAttributes.convention(mapOf())

tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveClassifier.set("dist")
relocate("com.sk89q.jchronic", "com.sk89q.worldedit.jchronic")
val jchronic = stringyLibs.getLibrary("jchronic").get()
dependencies {
include(project(":worldedit-libs:core"))
include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
include(project(":worldedit-core"))
exclude("com.google.code.findbugs:jsr305")
include(dependency(jchronic))
exclude(dependency("com.google.code.findbugs:jsr305"))
}
exclude("GradleStart**")
exclude(".cache")
exclude("LICENSE*")
exclude("META-INF/maven/**")
minimize()
minimize {
// jchronic uses reflection to load things, so we need to exclude it from minimizing
exclude(dependency(jchronic))
}
}
val javaComponent = components["java"] as AdhocComponentWithVariants
// I don't think we want this published (it's the shadow jar)
Expand Down
7 changes: 0 additions & 7 deletions build-logic/src/main/kotlin/buildlogic/CommonJavaExtension.kt

This file was deleted.

4 changes: 4 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ Checks based on Google Checks, modified for EngineHub.
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>
</module>
<module name="IllegalImport">
<property name="illegalPkgs" value="org.slf4j"/>
<message key="name.invalidPattern" value="Illegal import - {0}. Use Log4J instead."/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ junit-jupiter-api.module = "org.junit.jupiter:junit-jupiter-api"
junit-jupiter-params.module = "org.junit.jupiter:junit-jupiter-params"
junit-jupiter-engine.module = "org.junit.jupiter:junit-jupiter-engine"

jqwik = "net.jqwik:jqwik:1.9.0"

mockito-bom = "org.mockito:mockito-bom:5.11.0"
mockito-core.module = "org.mockito:mockito-core"
mockito-junit-jupiter.module = "org.mockito:mockito-junit-jupiter"
Expand Down
1 change: 0 additions & 1 deletion worldedit-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ dependencies {
because("Resolving Spigot annotations")
}
"compileOnly"(libs.paperApi) {
exclude("org.slf4j", "slf4j-api")
exclude("junit", "junit")
}
"implementation"(libs.paperLib)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.extent.TracingExtent;
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
import com.sk89q.worldedit.extent.buffer.internal.BatchingExtent;
import com.sk89q.worldedit.extent.cache.LastAccessExtentCache;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
Expand Down Expand Up @@ -199,6 +200,7 @@ public String getDisplayName() {

private @Nullable SideEffectExtent sideEffectExtent;
private final SurvivalModeExtent survivalExtent;
private @Nullable BatchingExtent batchingExtent;
private @Nullable ChunkBatchingExtent chunkBatchingExtent;
private final BlockBagExtent blockBagExtent;
@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -267,6 +269,7 @@ public String getDisplayName() {
this.bypassReorderHistory = traceIfNeeded(new DataValidatorExtent(extent, world));

// This extent can be skipped by calling rawSetBlock()
extent = traceIfNeeded(batchingExtent = new BatchingExtent(extent));
@SuppressWarnings("deprecation")
MultiStageReorder reorder = new MultiStageReorder(extent, false);
extent = traceIfNeeded(reorderExtent = reorder);
Expand Down Expand Up @@ -557,7 +560,7 @@ public void setSideEffectApplier(SideEffectSet sideEffectSet) {
*/
@Deprecated
public boolean hasFastMode() {
return sideEffectExtent != null && this.sideEffectExtent.getSideEffectSet().doesApplyAny();
return sideEffectExtent != null && !this.sideEffectExtent.getSideEffectSet().doesApplyAny();
}

public SideEffectSet getSideEffectApplier() {
Expand Down Expand Up @@ -616,10 +619,12 @@ public void setBatchingChunks(boolean batchingChunks) {
}
return;
}
assert batchingExtent != null : "same nullness as chunkBatchingExtent";
if (!batchingChunks && isBatchingChunks()) {
internalFlushSession();
}
chunkBatchingExtent.setEnabled(batchingChunks);
batchingExtent.setEnabled(!batchingChunks);
}

/**
Expand Down Expand Up @@ -648,6 +653,8 @@ public void disableBuffering() {
setReorderMode(ReorderMode.NONE);
if (chunkBatchingExtent != null) {
chunkBatchingExtent.setEnabled(false);
assert batchingExtent != null : "same nullness as chunkBatchingExtent";
batchingExtent.setEnabled(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public int line(Actor actor, EditSession editSession,
@Arg(desc = "The pattern of blocks to place")
Pattern pattern,
@Arg(desc = "The thickness of the line", def = "0")
int thickness,
double thickness,
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException {
if (!((region instanceof CuboidRegion) || (region instanceof ConvexPolyhedralRegion))) {
Expand Down Expand Up @@ -171,7 +171,7 @@ public int curve(Actor actor, EditSession editSession,
@Arg(desc = "The pattern of blocks to place")
Pattern pattern,
@Arg(desc = "The thickness of the curve", def = "0")
int thickness,
double thickness,
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion cpregion)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.extent.buffer.internal;

import com.google.common.base.Throwables;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractBufferingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.collection.BlockMap;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;

/**
* An extent that buffers all changes until completed.
*/
public class BatchingExtent extends AbstractBufferingExtent {

private final BlockMap<BaseBlock> blockMap = BlockMap.createForBaseBlock();
private boolean enabled;

public BatchingExtent(Extent extent) {
this(extent, true);
}

public BatchingExtent(Extent extent, boolean enabled) {
super(extent);
this.enabled = enabled;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean commitRequired() {
return enabled;
}

@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
if (!enabled) {
return setDelegateBlock(location, block);
}
blockMap.put(location, block.toBaseBlock());
return true;
}

@Override
protected BaseBlock getBufferedFullBlock(BlockVector3 position) {
if (!enabled) {
// Early exit if we're not enabled.
return null;
}
return blockMap.get(position);
}

@Override
protected Operation commitBefore() {
if (!commitRequired()) {
return null;
}
return new Operation() {

@Override
public Operation resume(RunContext run) throws WorldEditException {
try {
blockMap.forEach((position, block) -> {
try {
getExtent().setBlock(position, block);
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
});
} catch (RuntimeException e) {
Throwables.throwIfInstanceOf(e.getCause(), WorldEditException.class);
throw e;
}
blockMap.clear();
return null;
}

@Override
public void cancel() {
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void decodeBlocksIntoClipboard(VersionedDataFixer fixer, LinCompoundTag
);

byte[] blocks = blockContainer.getTag("Data", LinTagType.byteArrayTag()).value();
LinListTag<LinCompoundTag> blockEntities = blockContainer.getListTag("BlockEntities", LinTagType.compoundTag());
LinListTag<LinCompoundTag> blockEntities = blockContainer.findListTag("BlockEntities", LinTagType.compoundTag());

ReaderUtil.initializeClipboardFromBlocks(
clipboard, palette, blocks, blockEntities, fixer, true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.sk89q.worldedit.world.block.BlockStateHolder;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
Expand Down Expand Up @@ -91,18 +90,11 @@ protected Operation commitBefore() {
}
return new Operation() {

// we get modified between create/resume -- only create this on resume to prevent CME
private Iterator<BlockVector3> iterator;

@Override
public Operation resume(RunContext run) throws WorldEditException {
if (iterator == null) {
List<BlockVector3> blockVectors = new ArrayList<>(blockMap.keySet());
RegionOptimizedVectorSorter.sort(blockVectors);
iterator = blockVectors.iterator();
}
while (iterator.hasNext()) {
BlockVector3 position = iterator.next();
List<BlockVector3> blockVectors = new ArrayList<>(blockMap.keySet());
RegionOptimizedVectorSorter.sort(blockVectors);
for (BlockVector3 position : blockVectors) {
BaseBlock block = blockMap.get(position);
getExtent().setBlock(position, block);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static <B extends BlockStateHolder<B>> B transform(B block, Transform tra
Property<Object> propAsObj = (Property<Object>) prop;
result = result.with(propAsObj, "none");
}
directionalProperties.put(closestProp, result.getState(prop));
directionalProperties.put(closestProp, state);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ private static Substring onlyOnLastQuotedWord(Substring lastArg, Substring sugge
return suggestion;
}
String substr = suggestion.getSubstring();
int sp = substr.lastIndexOf(' ');
// Check if there is a space inside the substring, and suggest starting from there instead.
int sp = substr.trim().lastIndexOf(' ');
if (sp < 0) {
return suggestion;
}
Expand Down
Loading

0 comments on commit 13a2326

Please sign in to comment.