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 Aug 18, 2024
2 parents ec5c256 + 6f210ad commit c2e6c56
Show file tree
Hide file tree
Showing 28 changed files with 220 additions and 149 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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
- Shutdown the executor service on disable, to prevent waiting on async tasks before shutting down
- Remove legacy code for pre-1.16 //drawsel handling

7.3.4
- Added support for 1.21
- Fixed an issue where //drawsel can prevent using //world overrides in some situation
Expand Down
4 changes: 0 additions & 4 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ repositories {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
}
maven {
name = "SpongePowered"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}
}

dependencies {
Expand Down
15 changes: 15 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ configure<buildlogic.CommonJavaExtension> {
banSlf4j = false
}

paperweight {
injectPaperRepository = false
}

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
mavenCentral()
afterEvaluate {
killNonEngineHubRepositories()
}
}

dependencies {
"implementation"(project(":worldedit-bukkit"))
constraints {
Expand Down
8 changes: 0 additions & 8 deletions build-logic/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ plugins {
group = rootProject.group
version = rootProject.version

repositories {
mavenCentral()
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
}

configurations.all {
resolutionStrategy {
cacheChangingModulesFor(1, TimeUnit.DAYS)
Expand Down
37 changes: 37 additions & 0 deletions build-logic/src/main/kotlin/repositoriesHelper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.logging.Logging

// The primary point of this is repository up-time. We replace most other repositories with EngineHub's repository.
// This is because we have stronger up-time guarantees for our repository. However, Maven Central and Sonatype are
// clearly even better, so we allow those as well. We also allow Gradle's plugin repository.
private val ALLOWED_PREFIXES = listOf(
"https://maven.enginehub.org",
"https://repo.maven.apache.org/maven2/",
"https://s01.oss.sonatype.org/content/repositories/snapshots/",
"https://plugins.gradle.org",
"file:"
)
private val LOGGER = Logging.getLogger("repositoriesHelper")

fun RepositoryHandler.killNonEngineHubRepositories() {
val toRemove = mutableListOf<MavenArtifactRepository>()
for (repo in this) {
if (repo is MavenArtifactRepository && !ALLOWED_PREFIXES.any { repo.url.toString().startsWith(it) }) {
LOGGER.info("Removing non-EngineHub repository: {}", repo.url)
toRemove.add(repo)
}
}
toRemove.forEach { remove(it) }
}

fun RepositoryHandler.verifyEngineHubRepositories() {
for (repo in this) {
if (repo is MavenArtifactRepository) {
val urlString = repo.url.toString()
check(ALLOWED_PREFIXES.any { urlString.startsWith(it) }) {
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
}
}
}
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ version=7.4.0-SNAPSHOT

org.gradle.jvmargs=-Xmx1500M
org.gradle.parallel=true

loom_fabric_repository=https://maven.enginehub.org/artifactory/fabricmc/
loom_libraries_base=https://maven.enginehub.org/artifactory/minecraft/
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"

fabric-mixin = "net.fabricmc:sponge-mixin:0.13.3+mixin.0.8.5"

paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.1"
paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.2"

linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.1.0"
linBus-common.module = "org.enginehub.lin-bus:lin-bus-common"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
44 changes: 40 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,50 @@ pluginManagement {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
maven {
name = "SpongePowered"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("fabric-loom") version "1.6.12"
}
dependencyResolutionManagement {
repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
ivy {
url = uri("https://repo.enginehub.org/language-files/")
name = "EngineHub Language Files"
patternLayout {
artifact("[organisation]/[module]/[revision]/[artifact]-[revision](+[classifier])(.[ext])")
setM2compatible(true)
}
metadataSources {
artifact()
}
content {
includeModuleByRegex(".*", "worldedit-lang")
}
}
gradle.settingsEvaluated {
// Duplicates repositoriesHelper.kt, since we can't import it
val allowedPrefixes = listOf(
"https://maven.enginehub.org",
"https://repo.maven.apache.org/maven2/",
"file:"
)

for (repo in this@repositories) {
if (repo is MavenArtifactRepository) {
val urlString = repo.url.toString()
check(allowedPrefixes.any { urlString.startsWith(it) }) {
"Only EngineHub/Central repositories are allowed: ${repo.url} found"
}
}
}
}
}
}

logger.lifecycle("""
Expand Down
15 changes: 0 additions & 15 deletions verification/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ plugins {
id("me.champeau.gradle.japicmp")
}

repositories {
maven {
name = "EngineHub Repository (Releases Only)"
url = uri("https://maven.enginehub.org/artifactory/libs-release-local/")
}
maven {
name = "EngineHub Repository (Snapshots Only)"
url = uri("https://maven.enginehub.org/artifactory/libs-snapshot-local/")
content {
excludeGroup("com.sk89q.worldedit")
}
}
mavenCentral()
}

val resetAcceptedApiChangesFiles by tasks.registering {
group = "API Compatibility"
description = "Resets ALL the accepted API changes files"
Expand Down
2 changes: 1 addition & 1 deletion worldedit-bukkit/adapters/adapter-1.21/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ plugins {

dependencies {
// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.21-R0.1-20240618.005323-5")
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.21-R0.1-20240807.125219-129")
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
CraftServer.class.cast(Bukkit.getServer());

int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
if (dataVersion != 3953) {
throw new UnsupportedClassVersionError("Not 1.21!");
if (dataVersion != 3953 && dataVersion != 3955) {
throw new UnsupportedClassVersionError("Not 1.21(.1)!");
}

serverWorldsField = CraftServer.class.getDeclaredField("worlds");
Expand Down
7 changes: 0 additions & 7 deletions worldedit-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ platform {
includeClasspath = true
}

repositories {
maven {
name = "Spigot"
url = uri("https://hub.spigotmc.org/nexus/content/groups/public")
}
}

val localImplementation = configurations.create("localImplementation") {
description = "Dependencies used locally, but provided by the runtime Bukkit implementation"
isCanBeConsumed = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private BukkitAdapter() {

static {
TO_BLOCK_CONTEXT.setRestricted(false);
TO_BLOCK_CONTEXT.setTryLegacy(false);
}

/**
Expand Down Expand Up @@ -334,7 +335,8 @@ public static Entity adapt(org.bukkit.entity.Entity entity) {
*/
public static Material adapt(ItemType itemType) {
checkNotNull(itemType);
return Material.matchMaterial(itemType.id());
NamespacedKey key = checkNotNull(NamespacedKey.fromString(itemType.id()), "Item type key is invalid");
return Registry.MATERIAL.get(key);
}

/**
Expand All @@ -345,7 +347,8 @@ public static Material adapt(ItemType itemType) {
*/
public static Material adapt(BlockType blockType) {
checkNotNull(blockType);
return Material.matchMaterial(blockType.id());
NamespacedKey key = checkNotNull(NamespacedKey.fromString(blockType.id()), "Block type key is invalid");
return Registry.MATERIAL.get(key);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ private void initializeRegistries() {
});
// Block & Item
Registry.MATERIAL.forEach(material -> {
String key = material.getKey().toString();
if (material.isBlock()) {
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
BlockType.REGISTRY.register(key, new BlockType(key, blockState -> {
// TODO Use something way less hacky than this.
ParserContext context = new ParserContext();
context.setPreferringWildcard(true);
Expand All @@ -234,13 +235,13 @@ private void initializeRegistries() {
}
return defaultState;
} catch (InputParseException e) {
getLogger().log(Level.WARNING, "Error loading block state for " + material.getKey(), e);
getLogger().log(Level.WARNING, "Error loading block state for " + key, e);
return blockState;
}
}));
}
if (material.isItem()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
ItemType.REGISTRY.register(key, new ItemType(key));
}
});
// Entity
Expand All @@ -262,10 +263,12 @@ private void initializeRegistries() {
private void setupTags() {
// Tags
for (Tag<Material> blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) {
BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString()));
String key = blockTag.getKey().toString();
BlockCategory.REGISTRY.register(key, new BlockCategory(key));
}
for (Tag<Material> itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) {
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
String key = itemTag.getKey().toString();
ItemCategory.REGISTRY.register(key, new ItemCategory(key));
}
}

Expand Down Expand Up @@ -324,7 +327,6 @@ public void onDisable() {
config.unload();
}
this.getServer().getScheduler().cancelTasks(this);
worldEdit.getExecutorService().shutdown();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ public void onStopped() {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(platform);
WorldEdit.getInstance().getExecutorService().shutdown();
}

public FileRegistries getFileRegistries() {
Expand Down
14 changes: 0 additions & 14 deletions worldedit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ plugins {
id("buildlogic.core-and-platform")
}

repositories {
ivy {
url = uri("https://repo.enginehub.org/language-files/")
name = "EngineHub Language Files"
patternLayout {
artifact("[organisation]/[module]/[revision]/[artifact]-[revision](+[classifier])(.[ext])")
setM2compatible(true)
}
metadataSources {
artifact()
}
}
}

configurations {
register("languageFiles")
}
Expand Down
Loading

0 comments on commit c2e6c56

Please sign in to comment.