diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e7d6c8e527..255e09c1b7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 1b6a0df028..a3c3cacfb6 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -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 { diff --git a/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts b/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts index 58fce0a239..781e429cdc 100644 --- a/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts +++ b/build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts @@ -12,6 +12,21 @@ configure { 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 { diff --git a/build-logic/src/main/kotlin/buildlogic.common.gradle.kts b/build-logic/src/main/kotlin/buildlogic.common.gradle.kts index 1a84a95388..aa94bbe814 100644 --- a/build-logic/src/main/kotlin/buildlogic.common.gradle.kts +++ b/build-logic/src/main/kotlin/buildlogic.common.gradle.kts @@ -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) diff --git a/build-logic/src/main/kotlin/repositoriesHelper.kt b/build-logic/src/main/kotlin/repositoriesHelper.kt new file mode 100644 index 0000000000..229be12400 --- /dev/null +++ b/build-logic/src/main/kotlin/repositoriesHelper.kt @@ -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() + 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" + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 149a398c4c..f3b8605355 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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/ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3504fde5b1..d0e1925b98 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3..2c3521197d 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138c9..09523c0e54 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index b740cf1339..f5feea6d6b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -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 diff --git a/gradlew.bat b/gradlew.bat index 7101f8e467..9b42019c79 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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 ########################################################################## diff --git a/settings.gradle.kts b/settings.gradle.kts index 050f55e0c1..bd35b3433b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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(""" diff --git a/verification/build.gradle.kts b/verification/build.gradle.kts index 4a85df88bf..3eef387b59 100644 --- a/verification/build.gradle.kts +++ b/verification/build.gradle.kts @@ -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" diff --git a/worldedit-bukkit/adapters/adapter-1.21/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1.21/build.gradle.kts index 45b5e39631..a1389e3ef6 100644 --- a/worldedit-bukkit/adapters/adapter-1.21/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1.21/build.gradle.kts @@ -6,5 +6,5 @@ plugins { dependencies { // https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/ - the().paperDevBundle("1.21-R0.1-20240618.005323-5") + the().paperDevBundle("1.21-R0.1-20240807.125219-129") } diff --git a/worldedit-bukkit/adapters/adapter-1.21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1.21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21/PaperweightAdapter.java index 98f2a5364e..dc5de03d42 100644 --- a/worldedit-bukkit/adapters/adapter-1.21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1.21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21/PaperweightAdapter.java @@ -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"); diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index e5b6e41089..70801d5974 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -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 diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index a0a8672a92..4e53ff7606 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -82,6 +82,7 @@ private BukkitAdapter() { static { TO_BLOCK_CONTEXT.setRestricted(false); + TO_BLOCK_CONTEXT.setTryLegacy(false); } /** @@ -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); } /** @@ -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); } /** diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index e1ae9079c3..3c2b1155db 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -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); @@ -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 @@ -262,10 +263,12 @@ private void initializeRegistries() { private void setupTags() { // Tags for (Tag 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 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)); } } @@ -324,7 +327,6 @@ public void onDisable() { config.unload(); } this.getServer().getScheduler().cancelTasks(this); - worldEdit.getExecutorService().shutdown(); } /** diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java index 3d2f2c6c21..2818876c6b 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java @@ -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() { diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 6780e68712..e403541638 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -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") } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 198c6df445..48db042c9a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -33,12 +33,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Locatable; -import com.sk89q.worldedit.function.RegionFunction; -import com.sk89q.worldedit.function.RegionMaskingFilter; -import com.sk89q.worldedit.function.block.ApplySideEffect; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.internal.annotation.Offset; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.CommandUtil; @@ -295,29 +290,6 @@ void perf(Actor actor, LocalSession session, } } - @Command( - name = "/update", - desc = "Apply side effects to your selection" - ) - @CommandPermissions("worldedit.update") - void update(Actor actor, LocalSession session, World injectedWorld, - @Arg(desc = "The side effects", def = "") - SideEffectSet sideEffectSet) throws WorldEditException { - if (sideEffectSet == null) { - // Use defaults if none supplied. - sideEffectSet = SideEffectSet.defaults(); - } - RegionFunction apply = new ApplySideEffect(injectedWorld, sideEffectSet); - if (session.getMask() != null) { - apply = new RegionMaskingFilter(session.getMask(), apply); - } - - RegionVisitor visitor = new RegionVisitor(session.getSelection(injectedWorld), apply); - Operations.complete(visitor); - - actor.printInfo(TranslatableComponent.of("worldedit.update")); - } - @Command( name = "/reorder", desc = "Sets the reorder mode of WorldEdit" diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 92284f25bd..8fefaab6a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -34,6 +34,8 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.function.GroundFunction; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.function.RegionMaskingFilter; +import com.sk89q.worldedit.function.block.ApplySideEffect; import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.generator.FloraGenerator; import com.sk89q.worldedit.function.mask.ExistingBlockMask; @@ -59,6 +61,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.formatting.text.Component; @@ -603,4 +606,26 @@ public int flora(Actor actor, EditSession editSession, @Selection Region region, return affected; } + @Command( + name = "/update", + desc = "Apply side effects to your selection" + ) + @CommandPermissions("worldedit.update") + void update(Actor actor, LocalSession session, World injectedWorld, + @Arg(desc = "The side effects", def = "") + SideEffectSet sideEffectSet) throws WorldEditException { + if (sideEffectSet == null) { + // Use defaults if none supplied. + sideEffectSet = SideEffectSet.defaults(); + } + RegionFunction apply = new ApplySideEffect(injectedWorld, sideEffectSet); + if (session.getMask() != null) { + apply = new RegionMaskingFilter(session.getMask(), apply); + } + + RegionVisitor visitor = new RegionVisitor(session.getSelection(injectedWorld), apply); + Operations.complete(visitor); + + actor.printInfo(TranslatableComponent.of("worldedit.update")); + } } diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 273b6d5693..a6af19e7bd 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -31,14 +31,8 @@ tasks.withType().configureEach { } repositories { - maven { - name = "EngineHub" - url = uri("https://maven.enginehub.org/repo/") - } - getByName("Mojang") { - content { - includeGroupAndSubgroups("com.mojang") - } + afterEvaluate { + verifyEngineHubRepositories() } } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java index 32066cf0d5..6ceae73eab 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java @@ -218,38 +218,44 @@ private FabricPermissionsProvider getInitialPermissionsProvider() { private void setupRegistries(MinecraftServer server) { // Blocks for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.BLOCK).keySet()) { - if (BlockType.REGISTRY.get(name.toString()) == null) { - BlockType.REGISTRY.register(name.toString(), new BlockType(name.toString(), + String key = name.toString(); + if (BlockType.REGISTRY.get(key) == null) { + BlockType.REGISTRY.register(key, new BlockType(key, input -> FabricAdapter.adapt(FabricAdapter.adapt(input.getBlockType()).defaultBlockState()))); } } // Items for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.ITEM).keySet()) { - if (ItemType.REGISTRY.get(name.toString()) == null) { - ItemType.REGISTRY.register(name.toString(), new ItemType(name.toString())); + String key = name.toString(); + if (ItemType.REGISTRY.get(key) == null) { + ItemType.REGISTRY.register(key, new ItemType(key)); } } // Entities for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.ENTITY_TYPE).keySet()) { - if (EntityType.REGISTRY.get(name.toString()) == null) { - EntityType.REGISTRY.register(name.toString(), new EntityType(name.toString())); + String key = name.toString(); + if (EntityType.REGISTRY.get(key) == null) { + EntityType.REGISTRY.register(key, new EntityType(key)); } } // Biomes for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.BIOME).keySet()) { - if (BiomeType.REGISTRY.get(name.toString()) == null) { - BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString())); + String key = name.toString(); + if (BiomeType.REGISTRY.get(key) == null) { + BiomeType.REGISTRY.register(key, new BiomeType(key)); } } // Tags server.registryAccess().registryOrThrow(Registries.BLOCK).getTagNames().map(TagKey::location).forEach(name -> { - if (BlockCategory.REGISTRY.get(name.toString()) == null) { - BlockCategory.REGISTRY.register(name.toString(), new BlockCategory(name.toString())); + String key = name.toString(); + if (BlockCategory.REGISTRY.get(key) == null) { + BlockCategory.REGISTRY.register(key, new BlockCategory(key)); } }); server.registryAccess().registryOrThrow(Registries.ITEM).getTagNames().map(TagKey::location).forEach(name -> { - if (ItemCategory.REGISTRY.get(name.toString()) == null) { - ItemCategory.REGISTRY.register(name.toString(), new ItemCategory(name.toString())); + String key = name.toString(); + if (ItemCategory.REGISTRY.get(key) == null) { + ItemCategory.REGISTRY.register(key, new ItemCategory(key)); } }); Registry biomeRegistry = server.registryAccess().registryOrThrow(Registries.BIOME); @@ -269,14 +275,16 @@ private void setupRegistries(MinecraftServer server) { }); // Features for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).keySet()) { - if (ConfiguredFeatureType.REGISTRY.get(name.toString()) == null) { - ConfiguredFeatureType.REGISTRY.register(name.toString(), new ConfiguredFeatureType(name.toString())); + String key = name.toString(); + if (ConfiguredFeatureType.REGISTRY.get(key) == null) { + ConfiguredFeatureType.REGISTRY.register(key, new ConfiguredFeatureType(key)); } } // Structures for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.STRUCTURE).keySet()) { - if (StructureType.REGISTRY.get(name.toString()) == null) { - StructureType.REGISTRY.register(name.toString(), new StructureType(name.toString())); + String key = name.toString(); + if (StructureType.REGISTRY.get(key) == null) { + StructureType.REGISTRY.register(key, new StructureType(key)); } } } @@ -299,7 +307,6 @@ private void onStopServer(MinecraftServer minecraftServer) { WorldEdit worldEdit = WorldEdit.getInstance(); worldEdit.getSessionManager().unload(); WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform)); - WorldEdit.getInstance().getExecutorService().shutdown(); } private boolean skipEvents() { diff --git a/worldedit-neoforge/build.gradle.kts b/worldedit-neoforge/build.gradle.kts index a039185c5f..0c5c61dd1f 100644 --- a/worldedit-neoforge/build.gradle.kts +++ b/worldedit-neoforge/build.gradle.kts @@ -27,17 +27,15 @@ val apiClasspath = configurations.create("apiClasspath") { } repositories { - val toRemove = mutableListOf() - for (repo in project.repositories) { - if (repo is MavenArtifactRepository && repo.url.toString() == "https://maven.neoforged.net/releases/") { - toRemove.add(repo) - } - } - toRemove.forEach { remove(it) } maven { name = "EngineHub" url = uri("https://maven.enginehub.org/repo/") } + mavenCentral() + killNonEngineHubRepositories() + afterEvaluate { + killNonEngineHubRepositories() + } } dependencies { @@ -72,6 +70,7 @@ subsystems { parchment { minecraftVersion = libs.versions.parchment.minecraft.get() mappingsVersion = libs.versions.parchment.mappings.get() + addRepository = false } decompiler { maxMemory("3G") diff --git a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java index 6492442a80..b0518be5d0 100644 --- a/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java +++ b/worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java @@ -157,38 +157,44 @@ private void setupPlatform() { private void setupRegistries(MinecraftServer server) { // Blocks for (ResourceLocation name : BuiltInRegistries.BLOCK.keySet()) { - if (BlockType.REGISTRY.get(name.toString()) == null) { - BlockType.REGISTRY.register(name.toString(), new BlockType(name.toString(), + String key = name.toString(); + if (BlockType.REGISTRY.get(key) == null) { + BlockType.REGISTRY.register(key, new BlockType(key, input -> NeoForgeAdapter.adapt(NeoForgeAdapter.adapt(input.getBlockType()).defaultBlockState()))); } } // Items for (ResourceLocation name : BuiltInRegistries.ITEM.keySet()) { - if (ItemType.REGISTRY.get(name.toString()) == null) { - ItemType.REGISTRY.register(name.toString(), new ItemType(name.toString())); + String key = name.toString(); + if (ItemType.REGISTRY.get(key) == null) { + ItemType.REGISTRY.register(key, new ItemType(key)); } } // Entities for (ResourceLocation name : BuiltInRegistries.ENTITY_TYPE.keySet()) { - if (EntityType.REGISTRY.get(name.toString()) == null) { - EntityType.REGISTRY.register(name.toString(), new EntityType(name.toString())); + String key = name.toString(); + if (EntityType.REGISTRY.get(key) == null) { + EntityType.REGISTRY.register(key, new EntityType(key)); } } // Biomes for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.BIOME).keySet()) { - if (BiomeType.REGISTRY.get(name.toString()) == null) { - BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString())); + String key = name.toString(); + if (BiomeType.REGISTRY.get(key) == null) { + BiomeType.REGISTRY.register(key, new BiomeType(key)); } } // Tags server.registryAccess().registryOrThrow(Registries.BLOCK).getTagNames().map(TagKey::location).forEach(name -> { - if (BlockCategory.REGISTRY.get(name.toString()) == null) { - BlockCategory.REGISTRY.register(name.toString(), new BlockCategory(name.toString())); + String key = name.toString(); + if (BlockCategory.REGISTRY.get(key) == null) { + BlockCategory.REGISTRY.register(key, new BlockCategory(key)); } }); server.registryAccess().registryOrThrow(Registries.ITEM).getTagNames().map(TagKey::location).forEach(name -> { - if (ItemCategory.REGISTRY.get(name.toString()) == null) { - ItemCategory.REGISTRY.register(name.toString(), new ItemCategory(name.toString())); + String key = name.toString(); + if (ItemCategory.REGISTRY.get(key) == null) { + ItemCategory.REGISTRY.register(key, new ItemCategory(key)); } }); Registry biomeRegistry = server.registryAccess().registryOrThrow(Registries.BIOME); @@ -208,14 +214,16 @@ private void setupRegistries(MinecraftServer server) { }); // Features for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).keySet()) { - if (ConfiguredFeatureType.REGISTRY.get(name.toString()) == null) { - ConfiguredFeatureType.REGISTRY.register(name.toString(), new ConfiguredFeatureType(name.toString())); + String key = name.toString(); + if (ConfiguredFeatureType.REGISTRY.get(key) == null) { + ConfiguredFeatureType.REGISTRY.register(key, new ConfiguredFeatureType(key)); } } // Structures for (ResourceLocation name : server.registryAccess().registryOrThrow(Registries.STRUCTURE).keySet()) { - if (StructureType.REGISTRY.get(name.toString()) == null) { - StructureType.REGISTRY.register(name.toString(), new StructureType(name.toString())); + String key = name.toString(); + if (StructureType.REGISTRY.get(key) == null) { + StructureType.REGISTRY.register(key, new StructureType(key)); } } } @@ -257,7 +265,6 @@ public void serverStopping(ServerStoppingEvent event) { WorldEdit worldEdit = WorldEdit.getInstance(); worldEdit.getSessionManager().unload(); WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform)); - WorldEdit.getInstance().getExecutorService().shutdown(); } @SubscribeEvent diff --git a/worldedit-sponge/build.gradle.kts b/worldedit-sponge/build.gradle.kts index 33ebe5dd1c..34ac6bc042 100644 --- a/worldedit-sponge/build.gradle.kts +++ b/worldedit-sponge/build.gradle.kts @@ -18,15 +18,25 @@ commonJava { banSlf4j = false } -repositories { - mavenCentral() -} - minecraft { + injectRepositories(false) version(libs.versions.sponge.minecraft.get()) } +repositories { + maven { + name = "EngineHub" + url = uri("https://maven.enginehub.org/repo/") + } + mavenCentral() + verifyEngineHubRepositories() + afterEvaluate { + verifyEngineHubRepositories() + } +} + sponge { + injectRepositories(false) apiVersion(libs.versions.sponge.api.asProvider().get()) license("GPL-3.0-or-later") plugin("worldedit") { diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java index 6acb688238..9134274ee6 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java @@ -244,7 +244,6 @@ public void serverStopping(StoppingEngineEvent event) { WorldEdit worldEdit = WorldEdit.getInstance(); worldEdit.getSessionManager().unload(); WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform)); - WorldEdit.getInstance().getExecutorService().shutdown(); } @Listener