diff --git a/build.gradle b/build.gradle deleted file mode 100644 index a5f7a101c..000000000 --- a/build.gradle +++ /dev/null @@ -1,195 +0,0 @@ -import org.ajoberstar.grgit.Grgit - -buildscript { - repositories { - mavenCentral() - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - jcenter() - } - - configurations.all { - resolutionStrategy { - force 'commons-io:commons-io:2.4' - } - } - - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1' - } -} - -plugins { - id "org.ajoberstar.grgit" version "3.1.1" - id "com.github.johnrengelman.shadow" version "5.1.0" -} - -println """ -******************************************* - You are building FastAsyncWorldEdit! - - If you encounter trouble: - 1) Read COMPILING.md if you haven't yet - 2) Try running 'build' in a separate Gradle run - 3) Use gradlew and not gradle - 4) If you still need help, ask on Discord! https://discord.gg/ngZCzbU - - Output files will be in /target -******************************************* -""" - -allprojects { - group = 'com.boydti.fawe' - - def rootVersion = "1.13" - def revision = "" - def buildNumber = "" - def date = "" - ext { - git = Grgit.open(dir: new File(rootDir.toString()+'/.git')) - date = git.head().getDate().format("yy.MM.dd") - revision = "-${git.head().abbreviatedId}" - parents = git.head().parentIds; - if (project.hasProperty('buildnumber')) { - buildNumber = "$buildnumber" - } else { - index = -2109; // Offset to match CI - for (; parents != null && !parents.isEmpty(); index++) { - parents = git.getResolve().toCommit(parents.get(0)).getParentIds() - } - buildNumber = "${index}" - } - } - - version = String.format("%s.%s", rootVersion, buildNumber) -} - -description = rootProject.name - -subprojects { - repositories { - mavenCentral() - maven { url "http://maven.sk89q.com/repo/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { url "http://repo.maven.apache.org/maven2" } - // Fawe - maven { url "https://mvnrepository.com/artifact/" } - maven { url "http://repo.dmulloy2.net/content/groups/public/" } - maven { url "https://repo.destroystokyo.com/repository/maven-public//" } - maven { url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/" } - maven { url "https://libraries.minecraft.net" } - mavenLocal() - maven { url "http://empcraft.com/maven2" } - maven { url "https://hub.spigotmc.org/nexus/content/groups/public/" } - maven { url "http://ci.frostcast.net/plugin/repository/everything" } - maven { url "http://maven.sk89q.com/artifactory/repo" } - maven { url "http://repo.spongepowered.org/maven" } - maven { url "http://dl.bintray.com/tastybento/maven-repo" } - maven { url "http://ci.emc.gs/nexus/content/groups/aikar/" } - ivy { - url 'https://ci.athion.net/job' - layout 'pattern', { - artifact '/[organisation]/[revision]/artifact/[module].[ext]' - } - } - } - configurations.all { - resolutionStrategy { - cacheChangingModulesFor 5, 'minutes' - } - } -} - -configure(['worldedit-core', 'worldedit-bukkit'].collect { project("$it") }) { - apply plugin: 'java' - apply plugin: 'maven' -// apply plugin: 'checkstyle' - apply plugin: 'com.github.johnrengelman.shadow' -// apply plugin: 'com.jfrog.artifactory' -// Enable this requires putting license header files in many, many FAWE files -// apply plugin: 'net.minecrell.licenser' - - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - -// checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml") -// checkstyle.toolVersion = '7.6.1' - - clean.doFirst { - delete "../target" - } - - if (JavaVersion.current().isJava8Compatible()) { - // Java 8 turns on doclint which we fail - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - if (name == "worldedit-core" || name == "worldedit-bukkit") { - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - artifacts { - archives sourcesJar - } - build.dependsOn(sourcesJar) - } - -// build.dependsOn(checkstyleMain) -// build.dependsOn(checkstyleTest) -// build.dependsOn(javadocJar) -// -// artifactoryPublish { -// publishConfigs('archives') -// } - - dependencies { - compileOnly 'org.jetbrains:annotations:17.0.0' - } -} - -configure(['bukkit'].collect { project(":worldedit-$it") }) { - shadowJar { - getArchiveClassifier().set('dist') - dependencies { - include(project(":worldedit-libs:core")) - include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) - include(project(":worldedit-core")) - include(dependency('com.github.luben:zstd-jni:1.1.1')) - include(dependency('co.aikar:fastutil-lite:1.0')) - } - exclude 'GradleStart**' - exclude '.cache' - exclude 'LICENSE*' - } - - // Enable this requires putting license header files in many, many FAWE files - //license { - // header = rootProject.file("HEADER.txt") - // include '**/*.java' - //} -} - - - -task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { - destinationDir = file("./docs/javadoc") - title = "$project.name $version API" - options.author true - options.links 'http://docs.spring.io/spring/docs/4.3.x/javadoc-api/', 'http://docs.oracle.com/javase/8/docs/api/', 'http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/', 'http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/' - options.addStringOption('Xdoclint:none', '-quiet') - - delete "./docs" - - subprojects.each { proj -> - proj.tasks.withType(Javadoc).each { javadocTask -> - source += javadocTask.source - classpath += javadocTask.classpath - excludes += javadocTask.excludes - includes += javadocTask.includes - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..21be27e98 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,84 @@ +import org.ajoberstar.grgit.Grgit +import java.time.format.DateTimeFormatter + +plugins { + id("com.gradle.build-scan") version "2.4.1" +} + +logger.lifecycle(""" +******************************************* + You are building FastAsyncWorldEdit! + + If you encounter trouble: + 1) Read COMPILING.md if you haven't yet + 2) Try running 'build' in a separate Gradle run + 3) Use gradlew and not gradle + 4) If you still need help, ask on Discord! https://discord.gg/cSMxtGn + + Output files will be in [subproject]/build/libs +******************************************* +""") +//TODO FIX THIS WHEN I FEEL LIKE IT +var rootVersion = "1.14" +var revision: String = "" +var buildNumber = "" +var date: String = "" +ext { + val git: Grgit = Grgit.open { + dir = File(rootDir.toString() + "/.git"); + } + ext["date"] = git.head().dateTime.format(DateTimeFormatter.ofPattern("yy.MM.dd")); + ext["revision"] = "-${git.head().abbreviatedId}"; + var parents: MutableList? = git.head().parentIds; + if (project.hasProperty("buildnumber")) { + buildNumber = project.properties["buildnumber"] as String; + } else { + var index = -2109; // Offset to match CI + while (parents != null && parents.isNotEmpty()) { + parents = git.getResolve().toCommit(parents.get(0)).getParentIds() + index++; + } + buildNumber = index.toString(); + } +} +//def rootVersion = "1.13" +//def revision = "" +//def buildNumber = "" +//def date = "" +//ext { +// git = Grgit.open(dir: new File(rootDir.toString()+"/.git")) +// date = git.head().getDate().format("yy.MM.dd") +// revision = "-${git.head().abbreviatedId}" +// parents = git.head().parentIds; +// if (project.hasProperty("buildnumber")) { +// buildNumber = "$buildnumber" +// } else { +// index = -2109; // Offset to match CI +// for (; parents != null && !parents.isEmpty(); index++) { +// parents = git.getResolve().toCommit(parents.get(0)).getParentIds() +// } +// buildNumber = "${index}" +// } +//} +// +//version = String.format("%s.%s", rootVersion, buildNumber) + +version = String.format("%s-%s", rootVersion, buildNumber) + +if (!project.hasProperty("gitCommitHash")) { + apply(plugin = "org.ajoberstar.grgit") + ext["gitCommitHash"] = try { + (ext["grgit"] as Grgit?)?.head()?.abbreviatedId + } catch (e: Exception) { + logger.warn("Error getting commit hash", e) + + "no_git_id" + } +} + +buildScan { + setTermsOfServiceUrl("https://gradle.com/terms-of-service") + setTermsOfServiceAgree("yes") + + publishAlways() +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..53c14fc9e --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version embeddedKotlinVersion +} + +repositories { + jcenter() + gradlePluginPortal() +} + +configurations.all { + resolutionStrategy { + // Fabric needs this. + force( + "commons-io:commons-io:2.5", + "org.ow2.asm:asm:7.1", + "org.ow2.asm:asm-commons:7.1" + ) + } +} + +dependencies { + implementation(gradleApi()) + implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1") + implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0") + implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21") + implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21") + implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7") +} diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt new file mode 100644 index 000000000..718b33213 --- /dev/null +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -0,0 +1,27 @@ +import org.gradle.api.Project +import org.gradle.kotlin.dsl.repositories + +fun Project.applyCommonConfiguration() { + group = rootProject.group + version = rootProject.version + + repositories { + mavenCentral() + mavenLocal() + maven { url = uri("http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/") } + maven { url = uri("https://maven.sk89q.com/repo/") } + maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } + maven { url = uri("http://empcraft.com/maven2") } + maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") } + maven { url = uri("https://ci.athion.net/job/FAWE-Piston/ws/") } + ivy { url = uri("https://ci.athion.net/job") + patternLayout { + artifact("/[organisation]/[revision]/artifact/[module].[ext]") + }} + } + configurations.all { + resolutionStrategy { + cacheChangingModulesFor(5, "minutes") + } + } +} diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/buildSrc/src/main/kotlin/GradleExtras.kt new file mode 100644 index 000000000..e7d1e0ede --- /dev/null +++ b/buildSrc/src/main/kotlin/GradleExtras.kt @@ -0,0 +1,12 @@ +import org.gradle.api.Project +import org.gradle.api.plugins.ExtraPropertiesExtension +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.SourceSetContainer +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.the + +val Project.ext: ExtraPropertiesExtension + get() = extensions.getByType() + +val Project.sourceSets: SourceSetContainer + get() = the().sourceSets diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt new file mode 100644 index 000000000..2ab16095b --- /dev/null +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -0,0 +1,97 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.api.Project +import org.gradle.api.artifacts.ModuleDependency +import org.gradle.api.internal.HasConvention +import org.gradle.api.plugins.MavenRepositoryHandlerConvention +import org.gradle.api.tasks.Upload +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getPlugin +import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.register + +fun Project.applyLibrariesConfiguration() { + applyCommonConfiguration() + apply(plugin = "java-base") + apply(plugin = "maven") + apply(plugin = "com.github.johnrengelman.shadow") + apply(plugin = "com.jfrog.artifactory") + + configurations { + create("shade") + getByName("archives").extendsFrom(getByName("default")) + } + + group = "${rootProject.group}.worldedit-libs" + + tasks.register("jar") { + configurations = listOf(project.configurations["shade"]) + archiveClassifier.set("") + + dependencies { + exclude(dependency("com.google.guava:guava")) + exclude(dependency("com.google.code.gson:gson")) + exclude(dependency("org.checkerframework:checker-qual")) + } + + relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text") + } + val altConfigFiles = { artifactType: String -> + val deps = configurations["shade"].incoming.dependencies + .filterIsInstance() + .map { it.copy() } + .map { dependency -> + dependency.artifact { + name = dependency.name + type = artifactType + extension = "jar" + classifier = artifactType + } + dependency + } + + files(configurations.detachedConfiguration(*deps.toTypedArray()) + .resolvedConfiguration.lenientConfiguration.artifacts + .filter { it.classifier == artifactType } + .map { zipTree(it.file) }) + } + tasks.register("sourcesJar") { + from({ + altConfigFiles("sources") + }) + val filePattern = Regex("(.*)net/kyori/text((?:/|$).*)") + val textPattern = Regex("net\\.kyori\\.text") + eachFile { + filter { + it.replaceFirst(textPattern, "com.sk89q.worldedit.util.formatting.text") + } + path = path.replaceFirst(filePattern, "$1com/sk89q/worldedit/util/formatting/text$2") + } + archiveClassifier.set("sources") + } + + tasks.named("assemble").configure { + dependsOn("jar", "sourcesJar") + } + + artifacts { + val jar = tasks.named("jar") + add("default", jar) { + builtBy(jar) + } + val sourcesJar = tasks.named("sourcesJar") + add("archives", sourcesJar) { + builtBy(sourcesJar) + } + } + + tasks.register("install") { + configuration = configurations["archives"] + (repositories as HasConvention).convention.getPlugin().mavenInstaller { + pom.version = project.version.toString() + pom.artifactId = project.name + } + } + +} diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt new file mode 100644 index 000000000..e33302f03 --- /dev/null +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -0,0 +1,109 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.quality.CheckstyleExtension +import org.gradle.api.tasks.bundling.Jar +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.api.tasks.testing.Test +import org.gradle.external.javadoc.CoreJavadocOptions +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getByName +import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType + +fun Project.applyPlatformAndCoreConfiguration() { + applyCommonConfiguration() + apply(plugin = "java") + apply(plugin = "eclipse") + apply(plugin = "idea") + apply(plugin = "maven") + //apply(plugin = "checkstyle") + apply(plugin = "com.github.johnrengelman.shadow") + apply(plugin = "com.jfrog.artifactory") + + ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}" + + configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + +// configure { +// configFile = rootProject.file("config/checkstyle/checkstyle.xml") +// toolVersion = "7.6.1" +// } + + tasks.withType().configureEach { + useJUnitPlatform() + } + + dependencies { + "compileOnly"("org.jetbrains:annotations:17.0.0") + "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") + "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}") + "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}") + "testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}") + "testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}") + } + + // Java 8 turns on doclint which we fail + tasks.withType().configureEach { + (options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") + } + + tasks.register("javadocJar") { + dependsOn("javadoc") + archiveClassifier.set("javadoc") + from(tasks.getByName("javadoc").destinationDir) + } + + tasks.named("assemble").configure { + dependsOn("javadocJar") + } + + artifacts { + add("archives", tasks.named("jar")) + add("archives", tasks.named("javadocJar")) + } + + if (name == "worldedit-core" || name == "worldedit-bukkit") { + tasks.register("sourcesJar") { + dependsOn("classes") + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) + } + + artifacts { + add("archives", tasks.named("sourcesJar")) + } + tasks.named("assemble").configure { + dependsOn("sourcesJar") + } + } + +// tasks.named("check").configure { +// dependsOn("checkstyleMain", "checkstyleTest") +// } + +} + +fun Project.applyShadowConfiguration() { + tasks.named("shadowJar") { +// archiveClassifier.set("dist") + dependencies { + include(project(":worldedit-libs:core")) + include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) + include(project(":worldedit-core")) + } + archiveName = "FastAsyncWorldEdit-${project.version}.jar" + exclude("GradleStart**") + exclude(".cache") + exclude("LICENSE*") + minimize() + } +} diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 000000000..a4570bd5a --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,8 @@ +object Versions { + const val TEXT = "3.0.1" + const val TEXT_EXTRAS = "3.0.2" + const val PISTON = "0.4.4-SNAPSHOT" + const val AUTO_VALUE = "1.6.5" + const val JUNIT = "5.5.0" + const val MOCKITO = "3.0.0" +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index bef46365f..7e9784556 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -65,10 +65,6 @@ - - - - diff --git a/contrib/craftscripts/README.txt b/contrib/craftscripts/README.txt index 7638e67ed..61dd01128 100644 --- a/contrib/craftscripts/README.txt +++ b/contrib/craftscripts/README.txt @@ -6,10 +6,9 @@ Example usage: You may or may not install these scripts -- it is optional. If you are, however, place the entire craftscripts/ folder into the respective directory for the platform -that you have installed WorldEdit for -(see http://wiki.sk89q.com/wiki/WorldEdit/Installation). +that you have installed WorldEdit. In order to be able to use CraftScripts, you must install the Rhino JavaScript library. The installation page linked above has information about that. More information about scripts in general can be found at -http://wiki.sk89q.com/wiki/WorldEdit/Scripting \ No newline at end of file +https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/ diff --git a/gradle.properties b/gradle.properties index 878bf1f7e..5432e7cfb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +group=com.sk89q.worldedit +#version=7.1.0-SNAPSHOT + +org.gradle.jvmargs=-Xmx1G diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index b29efe82f..000000000 --- a/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -rootProject.name = 'FastAsyncWorldEdit' - -include 'worldedit-libs' - -['core', 'bukkit'].forEach { - include "worldedit-libs:$it" - include "worldedit-$it" -} -include "worldedit-libs:core:ap" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..56f98fe6a --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,9 @@ +rootProject.name = "FastAsyncWorldEdit" + +include("worldedit-libs") + +listOf("bukkit", "core").forEach { + include("worldedit-libs:$it") + include("worldedit-$it") +} +include("worldedit-libs:core:ap") diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle deleted file mode 100644 index 137ffd8b4..000000000 --- a/worldedit-bukkit/build.gradle +++ /dev/null @@ -1,118 +0,0 @@ -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'maven' -apply plugin: 'java-library' - -repositories { - maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } - maven { url "https://repo.codemc.org/repository/maven-public" } - maven { url "https://papermc.io/repo/repository/maven-public/" } -} - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("it.unimi.dsi:fastutil:8.2.1") - } -} - -dependencies { - compile ('net.milkbowl.vault:VaultAPI:1.7') - api project(':worldedit-core') - api project(':worldedit-libs:core') // TODO remove once core can compile - api project(':worldedit-libs:bukkit') - compileOnly 'com.sk89q:dummypermscompat:1.10' - compile "it.unimi.dsi:fastutil:8.2.1" - testCompile 'org.mockito:mockito-core:1.9.0-rc1' - implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'){transitive = false} - compile 'com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT' - implementation('io.papermc:paperlib:1.0.2'){transitive = false} - compileOnly 'BuildTools:spigot-1.14.4:lastSuccessfulBuild@jar' - implementation('com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39'){transitive = false} - implementation('com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39'){transitive = false} - implementation('com.massivecraft:factions:2.8.0'){transitive = false} - implementation('com.drtshock:factions:1.6.9.5'){transitive = false} - implementation('com.factionsone:FactionsOne:1.2.2'){transitive = false} - implementation('me.ryanhamshire:GriefPrevention:11.5.2'){transitive = false} - implementation('com.massivecraft:mcore:7.0.1'){transitive = false} - implementation('net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT'){transitive = false} - implementation('net.jzx7:regios:5.9.9'){transitive = false} - implementation('com.bekvon.bukkit.residence:Residence:4.5._13.1'){transitive = false} - implementation('com.palmergames.bukkit:towny:0.84.0.9'){transitive = false} - implementation('com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'){transitive = false} - implementation('com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'){transitive = false} - implementation('com.wasteofplastic:askyblock:3.0.8.2'){transitive = false} -} - -shadowJar { - dependencies { - relocate "org.slf4j", "com.sk89q.worldedit.slf4j" - relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" - include(dependency(':worldedit-core')) - include(dependency(':worldedit-libs:core')) - include(dependency(':worldedit-libs:bukkit')) - include(dependency('org.slf4j:slf4j-api')) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) - relocate("it.unimi.dsi.fastutil", "com.sk89q.worldedit.bukkit.fastutil") { - include("it.unimi.dsi:fastutil") - } - } - archiveName = "${parent.name}-${project.name.replaceAll("worldedit-", "")}-${parent.version}.jar" - destinationDir = file '../target' -} - -processResources { - from('src/main/resources') { - expand( - name: project.parent.name, - version: project.parent.version - ) - include 'plugin.yml' - } -// from (zipTree('src/main/resources/worldedit-adapters.jar').matching { -// exclude 'META-INF/' -// }) -// exclude '**/worldedit-adapters.jar' -} - -jar.archiveName="fawe-bukkit-${project.parent.version}.jar" -jar.destinationDir = file '../mvn/com/boydti/fawe-bukkit/' + project.parent.version -task createPom { - doLast { - pom { - project { - groupId 'com.boydti' - artifactId 'fawe-bukkit' - version project.parent.version - } - } - .getEffectivePom() - .setDependencies(new ArrayList<>()) - .writeTo("../mvn/com/boydti/fawe-bukkit/${project.parent.version}/fawe-bukkit-${project.parent.version}.pom") - pom { - project { - groupId 'com.boydti' - artifactId 'fawe-bukkit' - version 'latest' - } - } - .getEffectivePom() - .setDependencies(new ArrayList<>()) - .writeTo("../mvn/com/boydti/fawe-bukkit/latest/fawe-bukkit-latest.pom") - } -} -task copyFiles { - doLast { - copy { - from "../mvn/com/boydti/fawe-bukkit/${project.parent.version}/" - into '../mvn/com/boydti/fawe-bukkit/latest/' - include('*.jar') - rename ("fawe-bukkit-${project.parent.version}.jar", 'fawe-bukkit-latest.jar') - } - } -} -build.dependsOn(shadowJar) -build.finalizedBy(copyFiles) -copyFiles.dependsOn(createPom) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts new file mode 100644 index 000000000..bf07b7bb6 --- /dev/null +++ b/worldedit-bukkit/build.gradle.kts @@ -0,0 +1,95 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + `java-library` +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +repositories { + maven { url = uri("https://hub.spigotmc.org/nexus/content/groups/public") } + maven { url = uri("https://repo.codemc.org/repository/maven-public") } + maven { url = uri("https://papermc.io/repo/repository/maven-public/") } + maven { url = uri("http://empcraft.com/maven2") } + maven { url = uri("http://ci.frostcast.net/plugin/repository/everything") } + maven { url = uri("http://dl.bintray.com/tastybento/maven-repo") } + maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") } + maven { url = uri("https://libraries.minecraft.net") } + maven { url = uri("https://repo.destroystokyo.com/repository/maven-public//") } + maven { url = uri("http://repo.dmulloy2.net/content/groups/public/") } +} + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "compile"("net.milkbowl.vault:VaultAPI:1.7") { isTransitive = false } + "api"(project(":worldedit-core")) + "api"(project(":worldedit-libs:bukkit")) + "compile"("it.unimi.dsi:fastutil:8.2.1") + "api"("com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT") { + exclude("junit", "junit") + } + "compileOnly"("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") + "implementation"("io.papermc:paperlib:1.0.2") + "compileOnly"("com.sk89q:dummypermscompat:1.10") + "implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") + "implementation"("org.bstats:bstats-bukkit:1.5") + "testCompile"("org.mockito:mockito-core:1.9.0-rc1") + "implementation"("com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39") { isTransitive = false } + "implementation"("com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39") { isTransitive = false } + "implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false } + "implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false } + "implementation"("com.factionsone:FactionsOne:1.2.2") { isTransitive = false } + "implementation"("me.ryanhamshire:GriefPrevention:11.5.2") { isTransitive = false } + "implementation"("com.massivecraft:mcore:7.0.1") { isTransitive = false } + "implementation"("net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT") { isTransitive = false } + "implementation"("net.jzx7:regios:5.9.9") { isTransitive = false } + "implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false } + "implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false } + "implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false } + "implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false } + "implementation"("com.wasteofplastic:askyblock:3.0.8.2") { isTransitive = false } +} + +tasks.named("processResources") { + filesMatching("plugin.yml") { + expand("internalVersion" to project.ext["internalVersion"]) + } +} + +tasks.named("jar") { + manifest { + attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", + "WorldEdit-Version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + relocate("org.slf4j", "com.sk89q.worldedit.slf4j") + relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + include(dependency(":worldedit-core")) + include(dependency(":worldedit-libs:core")) + include(dependency(":worldedit-libs:bukkit")) + include(dependency("org.slf4j:slf4j-api")) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { + include(dependency("org.bstats:bstats-bukkit:1.5")) + } + relocate("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") { + include(dependency("io.papermc:paperlib:1.0.2")) + } + relocate("it.unimi.dsi.fastutil", "com.sk89q.worldedit.bukkit.fastutil") { + include(dependency("it.unimi.dsi:fastutil")) + } + } +} + +tasks.named("assemble").configure { + dependsOn("shadowJar") +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index cbad81464..e0b76da4a 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -3,24 +3,22 @@ package com.boydti.fawe.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.IFawe; import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.bukkit.beta.BukkitQueueHandler; +import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener; import com.boydti.fawe.bukkit.listener.RenderListener; import com.boydti.fawe.bukkit.regions.*; -import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.VaultUtil; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; -import com.boydti.fawe.bukkit.v0.ChunkListener_8; -import com.boydti.fawe.bukkit.v0.ChunkListener_9; +import com.boydti.fawe.bukkit.listener.ChunkListener_8; +import com.boydti.fawe.bukkit.listener.ChunkListener_9; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.Jars; -import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; @@ -39,18 +37,13 @@ import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.FileOutputStream; -import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.function.Consumer; import java.util.function.Supplier; public class FaweBukkit implements IFawe, Listener { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueueHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java similarity index 92% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueueHandler.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java index fbace1507..0822b5385 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueueHandler.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java @@ -1,19 +1,13 @@ -package com.boydti.fawe.bukkit.beta; +package com.boydti.fawe.bukkit.adapter; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.bukkit.v0.ChunkListener; +import com.boydti.fawe.bukkit.listener.ChunkListener; import java.lang.reflect.Field; import java.lang.reflect.Method; public class BukkitQueueHandler extends QueueHandler { - @Override - public IQueueExtent create() { - return new BukkitQueue(); - } - private volatile boolean timingsEnabled; private static boolean alertTimingsChange = true; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/DelegateLock.java similarity index 94% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/DelegateLock.java index 6d79d967e..de3c8bfe8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/DelegateLock.java @@ -1,11 +1,7 @@ -package com.boydti.fawe.bukkit.beta; +package com.boydti.fawe.bukkit.adapter; -import org.apache.commons.lang.mutable.MutableInt; - -import java.util.Collection; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/FaweAdapter_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java similarity index 100% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/FaweAdapter_All.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/FaweAdapter_All.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BlockMaterial_1_14.java similarity index 98% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BlockMaterial_1_14.java index 149d0c3b9..babcd1675 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BlockMaterial_1_14.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.bukkit.v1_14.adapter; +package com.boydti.fawe.bukkit.adapter.mc1_14; import com.sk89q.util.ReflectionUtil; import com.sk89q.worldedit.world.registry.BlockMaterial; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java similarity index 87% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java index c5f701d28..4a491ef8d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitAdapter_1_14.java @@ -1,20 +1,12 @@ -package com.boydti.fawe.bukkit.beta; +package com.boydti.fawe.bukkit.adapter.mc1_14; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.implementation.SimpleCharQueueExtent; -import com.boydti.fawe.beta.implementation.IChunkCache; -import com.boydti.fawe.bukkit.v1_14.adapter.BlockMaterial_1_14; +import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; -import com.boydti.fawe.wrappers.WorldWrapper; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; @@ -31,8 +23,6 @@ import net.minecraft.server.v1_14_R1.GameProfileSerializer; import net.minecraft.server.v1_14_R1.IBlockData; import net.minecraft.server.v1_14_R1.PlayerChunk; import net.minecraft.server.v1_14_R1.PlayerChunkMap; -import net.minecraft.server.v1_14_R1.WorldServer; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; import sun.misc.Unsafe; @@ -45,38 +35,26 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.locks.Lock; import java.util.function.Supplier; -import static com.google.common.base.Preconditions.checkNotNull; - -public class BukkitQueue extends SimpleCharQueueExtent { - private org.bukkit.World bukkitWorld; - private WorldServer nmsWorld; - - public BukkitQueue() { - } - - @Override - public synchronized void init(Extent extent, IChunkCache get, IChunkCache set) { - World world = WorldWrapper.unwrap(extent); - if (world == null) throw new IllegalArgumentException("Get must be a world."); - if (world instanceof BukkitWorld) { - this.bukkitWorld = ((BukkitWorld) world).getWorld(); - } else { - this.bukkitWorld = Bukkit.getWorld(world.getName()); - } - checkNotNull(this.bukkitWorld); - CraftWorld craftWorld = ((CraftWorld) bukkitWorld); - this.nmsWorld = craftWorld.getHandle(); - super.init(extent, get, set); - } - - @Override - protected synchronized void reset() { - super.reset(); - } +public class BukkitAdapter_1_14 { /* - NMS fields - */ + + World world = WorldWrapper.unwrap(extent); + if (world == null) throw new IllegalArgumentException("Get must be a world."); + if (world instanceof BukkitWorld) { + this.bukkitWorld = ((BukkitWorld) world).getWorld(); + } else { + this.bukkitWorld = Bukkit.getWorld(world.getName()); + } + checkNotNull(this.bukkitWorld); + CraftWorld craftWorld = ((CraftWorld) bukkitWorld); + this.nmsWorld = craftWorld.getHandle(); + + */ + + /* + NMS fields + */ public final static Field fieldBits; public final static Field fieldPalette; public final static Field fieldSize; @@ -172,10 +150,6 @@ public class BukkitQueue extends SimpleCharQueueExtent { private static boolean PAPER = true; - public Chunk ensureLoaded(int X, int Z) { - return ensureLoaded(nmsWorld, X, Z); - } - public static Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int X, int Z) { Chunk nmsChunk = nmsWorld.getChunkIfLoaded(X, Z); if (nmsChunk != null) { @@ -251,11 +225,6 @@ public class BukkitQueue extends SimpleCharQueueExtent { return; } - @Override - public void sendChunk(final int X, final int Z, final int mask) { - sendChunk(nmsWorld, X, Z, mask); - } - /* NMS conversion */ diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java similarity index 94% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index f17897891..925b6ff29 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -1,11 +1,11 @@ -package com.boydti.fawe.bukkit.beta; +package com.boydti.fawe.bukkit.adapter.mc1_14; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; -import com.boydti.fawe.bukkit.v1_14.adapter.Spigot_v1_14_R1; +import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; @@ -51,14 +51,14 @@ import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future; -public class BukkitGetBlocks extends CharGetBlocks { +public class BukkitGetBlocks_1_14 extends CharGetBlocks { public ChunkSection[] sections; public Chunk nmsChunk; public CraftWorld world; public int X, Z; private boolean forceLoad; - public BukkitGetBlocks(World world, int X, int Z, boolean forceLoad) { + public BukkitGetBlocks_1_14(World world, int X, int Z, boolean forceLoad) { this.world = (CraftWorld) world; this.X = X; this.Z = Z; @@ -91,7 +91,7 @@ public class BukkitGetBlocks extends CharGetBlocks { return load(layer, null); } - private void updateGet(BukkitGetBlocks get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { + private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { synchronized (get) { if (this.nmsChunk != nmsChunk) { this.nmsChunk = nmsChunk; @@ -117,7 +117,7 @@ public class BukkitGetBlocks extends CharGetBlocks { public > T call(IChunkSet set, Runnable finalizer) { try { WorldServer nmsWorld = world.getHandle(); - Chunk nmsChunk = BukkitQueue.ensureLoaded(nmsWorld, X, Z); + Chunk nmsChunk = BukkitAdapter_1_14.ensureLoaded(nmsWorld, X, Z); // Remove existing tiles @@ -157,8 +157,8 @@ public class BukkitGetBlocks extends CharGetBlocks { ChunkSection newSection; ChunkSection existingSection = sections[layer]; if (existingSection == null) { - newSection = BukkitQueue.newChunkSection(layer, setArr); - if (BukkitQueue.setSectionAtomic(sections, null, newSection, layer)) { + newSection = BukkitAdapter_1_14.newChunkSection(layer, setArr); + if (BukkitAdapter_1_14.setSectionAtomic(sections, null, newSection, layer)) { updateGet(this, nmsChunk, sections, newSection, setArr, layer); continue; } else { @@ -169,7 +169,7 @@ public class BukkitGetBlocks extends CharGetBlocks { } } } - DelegateLock lock = BukkitQueue.applyLock(existingSection); + DelegateLock lock = BukkitAdapter_1_14.applyLock(existingSection); synchronized (this) { synchronized (lock) { lock.untilFree(); @@ -194,8 +194,8 @@ public class BukkitGetBlocks extends CharGetBlocks { getArr[i] = value; } } - newSection = BukkitQueue.newChunkSection(layer, getArr); - if (!BukkitQueue.setSectionAtomic(sections, existingSection, newSection, layer)) { + newSection = BukkitAdapter_1_14.newChunkSection(layer, getArr); + if (!BukkitAdapter_1_14.setSectionAtomic(sections, existingSection, newSection, layer)) { System.out.println("Failed to set chunk section:" + X + "," + Z + " layer: " + layer); continue; } else { @@ -344,7 +344,7 @@ public class BukkitGetBlocks extends CharGetBlocks { nmsChunk.mustNotSave = false; nmsChunk.markDirty(); // send to player - BukkitQueue.sendChunk(nmsWorld, X, Z, finalMask); + BukkitAdapter_1_14.sendChunk(nmsWorld, X, Z, finalMask); if (finalizer != null) finalizer.run(); }; } @@ -397,7 +397,7 @@ public class BukkitGetBlocks extends CharGetBlocks { if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { data = new char[4096]; } - DelegateLock lock = BukkitQueue.applyLock(section); + DelegateLock lock = BukkitAdapter_1_14.applyLock(section); synchronized (lock) { lock.untilFree(); lock.setModified(false); @@ -406,8 +406,8 @@ public class BukkitGetBlocks extends CharGetBlocks { Spigot_v1_14_R1 adapter = ((Spigot_v1_14_R1) WorldEditPlugin.getInstance().getBukkitImplAdapter()); final DataPaletteBlock blocks = section.getBlocks(); - final DataBits bits = (DataBits) BukkitQueue.fieldBits.get(blocks); - final DataPalette palette = (DataPalette) BukkitQueue.fieldPalette.get(blocks); + final DataBits bits = (DataBits) BukkitAdapter_1_14.fieldBits.get(blocks); + final DataPalette palette = (DataPalette) BukkitAdapter_1_14.fieldPalette.get(blocks); final int bitsPerEntry = bits.c(); final long[] blockStates = bits.a(); @@ -506,7 +506,7 @@ public class BukkitGetBlocks extends CharGetBlocks { synchronized (this) { tmp = nmsChunk; if (tmp == null) { - nmsChunk = tmp = BukkitQueue.ensureLoaded(this.world.getHandle(), X, Z); + nmsChunk = tmp = BukkitAdapter_1_14.ensureLoaded(this.world.getHandle(), X, Z); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R1.java similarity index 99% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R1.java index 6fb99229e..7e5bb11c2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R1.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.boydti.fawe.bukkit.v1_14.adapter; +package com.boydti.fawe.bukkit.adapter.mc1_14; import com.boydti.fawe.Fawe; import com.google.common.collect.ImmutableList; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkCache.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkCache.java new file mode 100644 index 000000000..115740f29 --- /dev/null +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkCache.java @@ -0,0 +1,4 @@ +package com.boydti.fawe.bukkit.listener; + +public class ChunkCache { +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java similarity index 99% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java index 56af3100c..26e494ae1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.bukkit.v0; +package com.boydti.fawe.bukkit.listener; import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8.java similarity index 90% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8.java index 528fd42f8..66c72c857 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.bukkit.v0; +package com.boydti.fawe.bukkit.listener; import sun.misc.SharedSecrets; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java similarity index 92% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java index ab419aa7b..35e37e5a5 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_8Plus.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.bukkit.v0; +package com.boydti.fawe.bukkit.listener; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java similarity index 98% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java index 53ccbe1ca..accc84b90 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener_9.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.bukkit.v0; +package com.boydti.fawe.bukkit.listener; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java index e2542ae8a..2e709913c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/ItemUtil.java @@ -1,12 +1,9 @@ package com.boydti.fawe.bukkit.util; -import com.boydti.fawe.bukkit.beta.BukkitQueue; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index 6514912a8..68903f9c3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -57,10 +57,6 @@ public class PermissionsResolverManager implements PermissionsResolver { "# into WEPIF, paste it into http://yaml-online-parser.appspot.com/\r\n" + "# and see if it gives \"ERROR:\".\r\n" + "# - Lines starting with # are comments and so they are ignored.\r\n" + - "#\r\n" + - "# About Configuration Permissions\r\n" + - "# - See http://wiki.sk89q.com/wiki/WorldEdit/Permissions/Bukkit\r\n" + - "# - Now with multiworld support (see example)\r\n" + "\r\n"; private static PermissionsResolverManager instance; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 317dd17f4..e0b37df63 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -28,6 +28,7 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; @@ -36,6 +37,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.biome.BiomeType; @@ -252,9 +254,6 @@ public class BukkitWorld extends AbstractWorld { @Override public boolean clearContainerBlockContents(BlockVector3 pt) { Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); - if (block == null) { - return false; - } BlockState state = block.getState(); if (!(state instanceof InventoryHolder)) { return false; @@ -321,14 +320,12 @@ public class BukkitWorld extends AbstractWorld { public void checkLoadedChunk(BlockVector3 pt) { World world = getWorld(); - if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) { - world.loadChunk(pt.getBlockX() >> 4, pt.getBlockZ() >> 4); - } + world.getChunkAt(pt.getBlockX() >> 4, pt.getBlockZ() >> 4); } @Override public boolean equals(Object other) { - World ref = worldRef.get(); + final World ref = worldRef.get(); if (ref == null) { return false; } else if (other == null) { @@ -337,7 +334,7 @@ public class BukkitWorld extends AbstractWorld { World otherWorld = ((BukkitWorld) other).worldRef.get(); return ref.equals(otherWorld); } else if (other instanceof com.sk89q.worldedit.world.World) { - return ((com.sk89q.worldedit.world.World) other).getName().equals(getName()); + return ((com.sk89q.worldedit.world.World) other).getName().equals(ref.getName()); } else { return false; } 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 d56e7fc63..23bb23acb 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 @@ -37,16 +37,24 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.internal.command.CommandUtil; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.entity.EntityType; +import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.weather.WeatherTypes; import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -214,7 +222,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter PaperLib.suggestPaper(this); } - public void setupRegistries() { + private void setupRegistries() { // Biome for (Biome biome : Biome.values()) { String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT); @@ -259,6 +267,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId)); } } + // ... :| + GameModes.get(""); + WeatherTypes.get(""); } private void setupTags() { @@ -428,7 +439,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = "/" + cmd.getName(); + split[0] = "/" + commandLabel; CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); getWorldEdit().getEventBus().post(event); @@ -443,7 +454,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = "/" + cmd.getName(); + split[0] = "/" + commandLabel; String arguments = Joiner.on(" ").join(split); CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); @@ -577,9 +588,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter if (!event.isCommand()) return; String buffer = event.getBuffer(); - final String[] parts = buffer.split(" "); - if (parts.length < 1) return; - final String label = parts[0]; + int firstSpace = buffer.indexOf(' '); + if (firstSpace < 0) return; + final String label = buffer.substring(0, firstSpace); final Optional command = WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label); if (!command.isPresent()) return; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index 085c88226..dd68d75df 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -54,7 +54,7 @@ public class BukkitImplLoader { "** will be blank, and so on. There will be no support for entity\n" + "** and block property-related functions.\n" + "**\n" + - "** Please see https://worldedit.rtfd.io/en/latest/faq/#bukkit-adapters\n" + + "** Please see https://worldedit.enginehub.org/en/latest/faq/#bukkit-adapters\n" + "**********************************************\n"; /** diff --git a/worldedit-bukkit/src/main/resources/plugin.yml b/worldedit-bukkit/src/main/resources/plugin.yml index 8c514eaa2..d9dbe048d 100644 --- a/worldedit-bukkit/src/main/resources/plugin.yml +++ b/worldedit-bukkit/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ name: WorldEdit main: com.sk89q.worldedit.bukkit.WorldEditPlugin -version: ${version} +version: "${internalVersion}" +load: STARTUP api-version: 1.13 description: Fast Async WorldEdit plugin -authors: [Empire92] -load: STARTUP +authors: [Empire92, MattBDev] loadbefore: [BannerBoard, WorldGuard, PlotSquared, AsyncWorldEdit, AsyncWorldEditInjector] database: false permissions: @@ -153,4 +153,4 @@ permissions: worldedit.green: true worldedit.extinguish: true worldedit.calc: true - worldedit.fill: true \ No newline at end of file + worldedit.fill: true diff --git a/worldedit-bukkit/src/test/java/com/sk89q/wepif/DinnerPermsResolverTest.java b/worldedit-bukkit/src/test/java/com/sk89q/wepif/DinnerPermsResolverTest.java index e207e7b8d..37deab330 100644 --- a/worldedit-bukkit/src/test/java/com/sk89q/wepif/DinnerPermsResolverTest.java +++ b/worldedit-bukkit/src/test/java/com/sk89q/wepif/DinnerPermsResolverTest.java @@ -19,26 +19,26 @@ package com.sk89q.wepif; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import org.bukkit.Server; import org.bukkit.plugin.PluginManager; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class DinnerPermsResolverTest { private DinnerPermsResolver resolver; - @Before + @BeforeEach public void setUp() { Server server = mock(Server.class); when(server.getPluginManager()).thenReturn(mock(PluginManager.class)); resolver = new DinnerPermsResolver(server); } - + @Test public void testBasicResolving() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); @@ -49,7 +49,7 @@ public class DinnerPermsResolverTest { assertFalse(resolver.hasPermission(permissible, "completely.unrelated")); permissible.clearPermissions(); } - + @Test public void testBasicWildcardResolution() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); @@ -59,7 +59,7 @@ public class DinnerPermsResolverTest { assertTrue(resolver.hasPermission(permissible, "commandbook.spawnmob.spider.skeleton")); permissible.clearPermissions(); } - + @Test public void testNegatingNodes() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); @@ -67,16 +67,16 @@ public class DinnerPermsResolverTest { permissible.setPermission("commandbook.cuteasianboys", false); permissible.setPermission("commandbook.warp.*", false); permissible.setPermission("commandbook.warp.create", true); - + assertTrue(resolver.hasPermission(permissible, "commandbook.motd")); assertFalse(resolver.hasPermission(permissible, "commandbook.cuteasianboys")); assertFalse(resolver.hasPermission(permissible, "commandbook.warp.remove")); assertTrue(resolver.hasPermission(permissible, "commandbook.warp.create")); - + permissible.clearPermissions(); } - - + + @Test public void testInGroup() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); diff --git a/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java b/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java index 685baafc6..f75e3a634 100644 --- a/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java +++ b/worldedit-bukkit/src/test/java/com/sk89q/wepif/TestOfflinePermissible.java @@ -30,6 +30,7 @@ import org.bukkit.plugin.Plugin; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -37,7 +38,7 @@ import java.util.UUID; public class TestOfflinePermissible implements OfflinePlayer, Permissible { private boolean op; private UUID randomUuid = UUID.randomUUID(); - + private final Map assignedPermissions = new HashMap<>(); @Override @@ -52,7 +53,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { @Override public boolean isPermissionSet(String s) { - return assignedPermissions.containsKey(s.toLowerCase()); + return assignedPermissions.containsKey(s.toLowerCase(Locale.ROOT)); } @Override @@ -63,7 +64,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { @Override public boolean hasPermission(String s) { if (isPermissionSet(s)) { - return assignedPermissions.get(s.toLowerCase()); + return assignedPermissions.get(s.toLowerCase(Locale.ROOT)); } return false; } @@ -111,19 +112,19 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { } return ret; } - + public void setPermission(String permission, boolean value) { - assignedPermissions.put(permission.toLowerCase(), value); + assignedPermissions.put(permission.toLowerCase(Locale.ROOT), value); } - + public void unsetPermission(String permission) { - assignedPermissions.remove(permission.toLowerCase()); + assignedPermissions.remove(permission.toLowerCase(Locale.ROOT)); } public void clearPermissions() { assignedPermissions.clear(); } - + // -- Unneeded OfflinePlayer methods @Override diff --git a/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java b/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java index e6776cf8c..8851fb926 100644 --- a/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java +++ b/worldedit-bukkit/src/test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java @@ -20,15 +20,16 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.worldedit.util.TreeGenerator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; public class BukkitWorldTest { @Test public void testTreeTypeMapping() { for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { - Assert.assertNotNull("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type)); + assertNotNull(BukkitWorld.toBukkitTreeType(type), "No mapping for: " + type); } } diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle deleted file mode 100644 index 53e79bbda..000000000 --- a/worldedit-core/build.gradle +++ /dev/null @@ -1,129 +0,0 @@ -plugins { - id("java-library") - id("eclipse") - id("idea") - id("net.ltgt.apt") version "0.21" apply false - id "net.ltgt.apt-eclipse" version "0.21" - id "net.ltgt.apt-idea" version "0.21" -} - -repositories { - maven {url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/"} -} - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("it.unimi.dsi:fastutil:8.2.1") - } -} - -dependencies { - compile project(':worldedit-libs:core') - compile 'de.schlichtherle:truezip:6.8.3' - compile 'rhino:js:1.7R2' - compile 'org.yaml:snakeyaml:1.23' - compile 'com.google.guava:guava:21.0' - compile 'com.google.code.findbugs:jsr305:1.3.9' - compile 'com.thoughtworks.paranamer:paranamer:2.6' - compile 'com.google.code.gson:gson:2.8.0' - compile 'com.googlecode.json-simple:json-simple:1.1.1' - compile 'org.slf4j:slf4j-api:1.7.26' - compile "it.unimi.dsi:fastutil:8.2.1" - - compileOnly project(':worldedit-libs:core:ap') - annotationProcessor project(':worldedit-libs:core:ap') - annotationProcessor "com.google.guava:guava:21.0" - def avVersion = "1.6.5" - compileOnly "com.google.auto.value:auto-value-annotations:$avVersion" - annotationProcessor "com.google.auto.value:auto-value:$avVersion" - //compile 'net.sf.trove4j:trove4j:3.0.3' - testCompile 'org.mockito:mockito-core:1.9.0-rc1' - - // Fawe depends - compileOnly 'net.fabiozumbi12:redprotect:1.9.6' - compileOnly ("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { - transitive = false - } - compile 'com.mojang:datafixerupper:1.0.20' - compile 'com.github.luben:zstd-jni:1.1.1' - compile 'co.aikar:fastutil-lite:1.0' - testImplementation ("org.junit.jupiter:junit-jupiter-api:5.5.0") - testImplementation ("org.junit.jupiter:junit-jupiter-params:5.5.0") - testImplementation ("org.mockito:mockito-core:3.0.0") - testImplementation ("org.mockito:mockito-junit-jupiter:3.0.0") - testRuntime ("org.junit.jupiter:junit-jupiter-engine:5.5.0") -} - -tasks.withType(JavaCompile).configureEach { - dependsOn(":worldedit-libs:build") - it.options.compilerArgs << "-Xmaxerrs" << "10000" - it.options.compilerArgs.add("-Aarg.name.key.prefix=") -} - -sourceSets { - main { - java { - srcDir 'src/main/java' - srcDir 'src/legacy/java' - } - resources { - srcDir 'src/main/resources' - } - } -} - -processResources { - from('src/main/resources') { - include 'fawe.properties' - expand( - version: "${project.parent.version}", - name: project.parent.name, - commit: "${git.head().abbreviatedId}", - date: "${git.head().getDate().format("yy.MM.dd")}" -) - } -} - -jar.archiveName="fawe-api-${project.parent.version}.jar" -jar.destinationDir = file '../mvn/com/boydti/fawe-api/' + project.parent.version -task createPom { - doLast { - pom { - project { - groupId 'com.boydti' - artifactId 'fawe-api' - version project.parent.version - } - } - .getEffectivePom() - .setDependencies(new ArrayList<>()) - .writeTo("../mvn/com/boydti/fawe-api/${project.parent.version}/fawe-api-${project.parent.version}.pom") - pom { - project { - groupId 'com.boydti' - artifactId 'fawe-api' - version 'latest' - } - } - .getEffectivePom() - .setDependencies(new ArrayList<>()) - .writeTo("../mvn/com/boydti/fawe-api/latest/fawe-api-latest.pom") - } -} -task copyFiles { - doLast { - copy { - from "../mvn/com/boydti/fawe-api/${project.parent.version}/" - into '../mvn/com/boydti/fawe-api/latest/' - include('*.jar') - rename ("fawe-api-${project.parent.version}.jar", 'fawe-api-latest.jar') - } - } -} - -build.dependsOn(shadowJar) -build.finalizedBy(copyFiles) -copyFiles.dependsOn(createPom) diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts new file mode 100644 index 000000000..2363ab57f --- /dev/null +++ b/worldedit-core/build.gradle.kts @@ -0,0 +1,72 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("java-library") + id("net.ltgt.apt-eclipse") + id("net.ltgt.apt-idea") +} + +applyPlatformAndCoreConfiguration() + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "compile"(project(":worldedit-libs:core")) + "compile"("de.schlichtherle:truezip:6.8.3") + "compile"("rhino:js:1.7R2") + "compile"("org.yaml:snakeyaml:1.23") + "compile"("com.google.guava:guava:21.0") + "compile"("com.google.code.findbugs:jsr305:3.0.2") + "compile"("com.google.code.gson:gson:2.8.0") + "compile"("org.slf4j:slf4j-api:1.7.26") + "compile"("it.unimi.dsi:fastutil:8.2.1") + "compile"("com.googlecode.json-simple:json-simple:1.1.1") { isTransitive = false } + "compileOnly"(project(":worldedit-libs:core:ap")) + "annotationProcessor"(project(":worldedit-libs:core:ap")) + // ensure this is on the classpath for the AP + "annotationProcessor"("com.google.guava:guava:21.0") + "compileOnly"("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}") + "annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}") + "compile"("co.aikar:fastutil-lite:1.0") + "compile"("com.github.luben:zstd-jni:1.4.3-1") + //"compile"("com.mojang:datafixerupper:1.0.20") + "compileOnly"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { + isTransitive = false + } + "compileOnly"("net.fabiozumbi12:redprotect:1.9.6") +} + +tasks.withType().configureEach { + dependsOn(":worldedit-libs:build") + options.compilerArgs.add("-Aarg.name.key.prefix=") +} + +sourceSets { + main { + java { + srcDir("src/main/java") + srcDir("src/legacy/java") + } + resources { + srcDir("src/main/resources") + } + } +} + +tasks.named("processResources") { + filesMatching("fawe.properties") { + expand("version" to "$version", + "commit" to "${rootProject.ext["revision"]}", + "date" to "${rootProject.ext["date"]}") + } +} +tasks.named("shadowJar") { + dependencies { + include(dependency("com.github.luben:zstd-jni:1.4.3-1")) + + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java index 03219aded..5791345b1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java @@ -159,11 +159,6 @@ public interface IDelegateQueueExtent extends IQueueExtent { return getParent().isEmpty(); } - @Override - default void sendChunk(int chunkX, int chunkZ, int bitMask) { - getParent().sendChunk(chunkX, chunkZ, bitMask); - } - @Override default boolean trim(boolean aggressive) { return getParent().trim(aggressive); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index 3dd0fe6a9..becbb7b65 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -182,14 +182,4 @@ public interface IQueueExtent extends Flushable, Trimable, Extent { * @return If queue is empty */ boolean isEmpty(); - - /** - * Refresh a specific chunk with a bitMask (0 = default, 65535 = all block sections) - * Note: only 0 is guaranteed to send all tiles / entities - * Note: Only 65535 is guaranteed to send all blocks - * @param chunkX - * @param chunkZ - * @param bitMask - */ - void sendChunk(int chunkX, int chunkZ, int bitMask); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java index 70b859358..9090d128f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java @@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.ChunkFilterBlock; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; @@ -213,7 +214,9 @@ public abstract class QueueHandler implements Trimable, Runnable { } } - public abstract IQueueExtent create(); + public IQueueExtent create() { + return new SingleThreadQueueExtent(); + } public abstract void startSet(boolean parallel); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java deleted file mode 100644 index 4112521a7..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.boydti.fawe.beta.implementation; - -import com.boydti.fawe.beta.CharFilterBlock; -import com.boydti.fawe.beta.ChunkFilterBlock; - -public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent { - - @Override - public ChunkFilterBlock initFilterBlock() { - return new CharFilterBlock(this); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java index 0622f26c9..d8bc114e2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java @@ -1,6 +1,8 @@ package com.boydti.fawe.beta.implementation; import com.boydti.fawe.Fawe; +import com.boydti.fawe.beta.CharFilterBlock; +import com.boydti.fawe.beta.ChunkFilterBlock; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; @@ -25,7 +27,7 @@ import java.util.concurrent.Future; *

* This queue is reusable {@link #init(IChunkCache)} */ -public abstract class SingleThreadQueueExtent implements IQueueExtent { +public class SingleThreadQueueExtent implements IQueueExtent { // // Pool discarded chunks for reuse (can safely be cleared by another thread) // private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); @@ -299,4 +301,9 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { pollSubmissions(0, true); reset(); } + + @Override + public ChunkFilterBlock initFilterBlock() { + return new CharFilterBlock(this); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java index 1999fdaf3..390f48ed3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java @@ -42,7 +42,7 @@ public class CFICommand extends CommandProcessor { } @Override - public Object process(InjectedValueAccess context, List args, Object result) { + public int process(InjectedValueAccess context, List args, int result) { return result; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CommandProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CommandProcessor.java index 348eff575..973f75433 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CommandProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CommandProcessor.java @@ -67,13 +67,13 @@ public abstract class CommandProcessor implements CommandManager { } @Override - public final O /* Need to recompile with FAWE-piston */ execute(InjectedValueAccess context, List args) { + public final int execute(InjectedValueAccess context, List args) { args = preprocess(context, args); if (args != null) { - I result = (I) parent.execute(context, args); + int result = parent.execute(context, args); return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston) } else { - return null; + return 0; } } @@ -89,5 +89,5 @@ public abstract class CommandProcessor implements CommandManager { public abstract List preprocess(InjectedValueAccess context, List args); - public abstract O process(InjectedValueAccess context, List args, I result); -} \ No newline at end of file + public abstract int process(InjectedValueAccess context, List args, int result); +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index bb2c17763..c3f05f308 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -2,9 +2,7 @@ package com.boydti.fawe.object.brush.visualization.cfi; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.FallbackChunkGet; import com.boydti.fawe.object.FaweInputStream; @@ -16,7 +14,6 @@ import com.boydti.fawe.object.change.StreamChange; import com.boydti.fawe.object.changeset.CFIChangeSet; import com.boydti.fawe.object.collection.DifferentialArray; import com.boydti.fawe.object.collection.DifferentialBlockBuffer; -import com.boydti.fawe.object.collection.IterableThreadLocal; import com.boydti.fawe.object.collection.LocalBlockVector2DSet; import com.boydti.fawe.object.collection.SummedAreaTable; import com.boydti.fawe.object.exception.FaweException; @@ -47,14 +44,16 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; + +import javax.annotation.Nullable; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; @@ -64,9 +63,7 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; -import javax.annotation.Nullable; // TODO FIXME public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld { @@ -321,6 +318,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr // } } + @Override + public void sendChunk(int X, int Z, int mask) { + throw new UnsupportedOperationException("TODO NOT IMPLEMENTED"); // add method to adapter to send custom chunk + } + public TextureUtil getRawTextureUtil() { if (textureUtil == null) { textureUtil = Fawe.get().getTextureUtil(); @@ -849,7 +851,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public void close(boolean update) { if (chunkOffset != null && player != null && update) { - IQueueExtent packetQueue = Fawe.get().getQueueHandler().getQueue(player.getWorld()); + World world = player.getWorld(); int lenCX = (getWidth() + 15) >> 4; int lenCZ = (getLength() + 15) >> 4; @@ -868,7 +870,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int cz = scz; cz <= ecz; cz++) { for (int cx = scx; cx <= ecx; cx++) { - packetQueue.sendChunk(cx + OX, cz + OZ, 0); + world.sendChunk(cx + OX, cz + OZ, 0); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java index e248035d3..621d43b90 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java @@ -121,7 +121,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue { @Override public void refreshChunk(int x, int z) { - IMP.sendChunk(x, z, 0); + world.sendChunk(x, z, 0); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java index 36e7e6d9b..ea0381916 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java @@ -59,9 +59,9 @@ public class PlotSetBiome extends Command { Collection knownBiomes = BiomeTypes.values(); final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry); if (biome == null) { - String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATER.s()); + String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATER.toString()); Captions.NEED_BIOME.send(player); - MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes); + MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes); return; } confirm.run(this, new Runnable() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/DocumentationPrinter.java b/worldedit-core/src/main/java/com/boydti/fawe/util/DocumentationPrinter.java index d4537cbc3..cd679e35c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/DocumentationPrinter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/DocumentationPrinter.java @@ -34,9 +34,9 @@ import com.sk89q.worldedit.command.ChunkCommands; import com.sk89q.worldedit.command.ClipboardCommands; import com.sk89q.worldedit.command.GenerationCommands; import com.sk89q.worldedit.command.HistoryCommands; -import com.sk89q.worldedit.command.MaskCommands; +//import com.sk89q.worldedit.command.MaskCommands; import com.sk89q.worldedit.command.NavigationCommands; -import com.sk89q.worldedit.command.PatternCommands; +//import com.sk89q.worldedit.command.PatternCommands; import com.sk89q.worldedit.command.RegionCommands; import com.sk89q.worldedit.command.SchematicCommands; import com.sk89q.worldedit.command.ScriptingCommands; @@ -45,7 +45,7 @@ import com.sk89q.worldedit.command.SnapshotCommands; import com.sk89q.worldedit.command.SnapshotUtilCommands; import com.sk89q.worldedit.command.SuperPickaxeCommands; import com.sk89q.worldedit.command.ToolCommands; -import com.sk89q.worldedit.command.TransformCommands; +//import com.sk89q.worldedit.command.TransformCommands; import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.command.WorldEditCommands; import org.enginehub.piston.annotation.param.Arg; @@ -127,9 +127,9 @@ public final class DocumentationPrinter { writePermissionsWikiTable(stream, builder, "/", BrushOptionsCommands.class); writePermissionsWikiTable(stream, builder, "/tool ", ToolCommands.class); writePermissionsWikiTable(stream, builder, "/brush ", BrushCommands.class); - writePermissionsWikiTable(stream, builder, "", MaskCommands.class, "/Masks"); - writePermissionsWikiTable(stream, builder, "", PatternCommands.class, "/Patterns"); - writePermissionsWikiTable(stream, builder, "", TransformCommands.class, "/Transforms"); + //writePermissionsWikiTable(stream, builder, "", MaskCommands.class, "/Masks"); + //writePermissionsWikiTable(stream, builder, "", PatternCommands.class, "/Patterns"); + //writePermissionsWikiTable(stream, builder, "", TransformCommands.class, "/Transforms"); writePermissionsWikiTable(stream, builder, "/cfi ", CFICommands.class, "Create From Image"); stream.println(); stream.print("#### Uncategorized\n"); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/RegionCacheUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/RegionCacheUtil.java new file mode 100644 index 000000000..f5c02d65e --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/RegionCacheUtil.java @@ -0,0 +1,27 @@ +package com.boydti.fawe.util; + +import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; + +import java.util.Iterator; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class RegionCacheUtil { + public RegionCacheUtil() { + + } + + public void cache(Region region) { + Iterator iter = region.iterator(); + } + + public void run() { + TaskManager.IMP.async(new Runnable() { + @Override + public void run() { + + } + }); + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index 839205736..ed3245f05 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -228,6 +228,11 @@ public class WorldWrapper extends AbstractWorld { return parent.hashCode(); } + @Override + public void sendChunk(int X, int Z, int mask) { + parent.sendChunk(X, Z, mask); + } + @Override public List getEntities(final Region region) { return TaskManager.IMP.sync(new RunnableVal>() { diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java index 2a7e07f00..69bd40894 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -26,8 +26,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; public class CommandContext { @@ -256,8 +254,11 @@ public class CommandContext { } public String getString(int start, int end) { - return IntStream.range(start + 1, end + 1).mapToObj(i -> " " + parsedArgs.get(i)) - .collect(Collectors.joining("", parsedArgs.get(start), "")); + StringBuilder buffer = new StringBuilder(parsedArgs.get(start)); + for (int i = start + 1; i < end + 1; ++i) { + buffer.append(" ").append(parsedArgs.get(i)); + } + return buffer.toString(); } public int getInteger(int index) throws NumberFormatException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 21f38c0fa..dbdaf32cd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -72,6 +72,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.HandSide; +import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -395,7 +396,7 @@ public class LocalSession implements TextureHolder { return null; } - public synchronized void remember(Player player, World world, ChangeSet changeSet, FaweLimit limit) { + public synchronized void remember(Identifiable player, World world, ChangeSet changeSet, FaweLimit limit) { if (Settings.IMP.HISTORY.USE_DISK) { LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE; } @@ -438,7 +439,7 @@ public class LocalSession implements TextureHolder { } } - public synchronized void remember(final EditSession editSession, final boolean append, int limitMb) { + public synchronized void remember(EditSession editSession, boolean append, int limitMb) { if (Settings.IMP.HISTORY.USE_DISK) { LocalSession.MAX_HISTORY_SIZE = Integer.MAX_VALUE; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 64d759ac8..4111cc83c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -81,7 +81,6 @@ import java.util.Map; import javax.annotation.Nullable; import javax.script.ScriptException; -import org.mozilla.javascript.NativeJavaObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -109,7 +108,8 @@ public final class WorldEdit { private final PlatformManager platformManager = new PlatformManager(this); private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus); private final SessionManager sessions = new SessionManager(this); - private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));; + private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator( + EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s")); private final Supervisor supervisor = new SimpleSupervisor(); private final BlockFactory blockFactory = new BlockFactory(this); @@ -635,14 +635,14 @@ public final class WorldEdit { * @param args arguments for the script * @throws WorldEditException */ - public Object runScript(Player player, File f, String[] args) throws WorldEditException { + public void runScript(Player player, File f, String[] args) throws WorldEditException { String filename = f.getPath(); int index = filename.lastIndexOf('.'); String ext = filename.substring(index + 1); if (!ext.equalsIgnoreCase("js")) { player.printError("Only .js scripts are currently supported"); - return null; + return; } String script; @@ -655,7 +655,7 @@ public final class WorldEdit { if (file == null) { player.printError("Script does not exist: " + filename); - return null; + return; } } else { file = new FileInputStream(f); @@ -668,7 +668,7 @@ public final class WorldEdit { script = new String(data, 0, data.length, StandardCharsets.UTF_8); } catch (IOException e) { player.printError("Script read error: " + e.getMessage()); - return null; + return; } LocalSession session = getSessionManager().get(player); @@ -681,8 +681,8 @@ public final class WorldEdit { engine = new RhinoCraftScriptEngine(); } catch (NoClassDefFoundError ignored) { player.printError("Failed to find an installed script engine."); - player.printError("Please see https://worldedit.readthedocs.io/en/latest/usage/other/craftscripts/"); - return null; + player.printError("Please see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/"); + return; } engine.setTimeLimit(getConfiguration().scriptTimeout); @@ -693,11 +693,7 @@ public final class WorldEdit { vars.put("player", player); try { - Object result = engine.evaluate(script, filename, vars); - if (result instanceof NativeJavaObject) { - result = ((NativeJavaObject) result).unwrap(); - } - return result; + engine.evaluate(script, filename, vars); } catch (ScriptException e) { player.printError("Failed to execute:"); player.printRaw(e.getMessage()); @@ -714,7 +710,6 @@ public final class WorldEdit { session.remember(editSession); } } - return null; } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 3ea584ea9..3a118b100 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -53,6 +53,7 @@ import com.boydti.fawe.object.brush.StencilBrush; import com.boydti.fawe.object.brush.SurfaceSphereBrush; import com.boydti.fawe.object.brush.SurfaceSpline; import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap; +import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap.Shape; import com.boydti.fawe.object.brush.sweep.SweepBrush; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.mask.IdMask; @@ -152,11 +153,11 @@ public class BrushCommands { "Pic: https://i.imgur.com/cNUQUkj.png -> https://i.imgur.com/hFOFsNf.png" ) @CommandPermissions("worldedit.brush.blendball") - public BrushSettings blendBallBrush(Player player, LocalSession session, + public void blendBallBrush(Player player, LocalSession session, @Arg(desc = "The radius to sample for blending", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new BlendBall()).setSize(radius); + set(session, context, new BlendBall()).setSize(radius); } @Command( @@ -164,11 +165,11 @@ public class BrushCommands { desc = "Erodes terrain" ) @CommandPermissions("worldedit.brush.erode") - public BrushSettings erodeBrush(Player player, LocalSession session, + public void erodeBrush(Player player, LocalSession session, @Arg(desc = "The radius for eroding", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new ErodeBrush()).setSize(radius); + set(session, context, new ErodeBrush()).setSize(radius); } @Command( @@ -176,11 +177,11 @@ public class BrushCommands { desc = "Pull terrain towards you" ) @CommandPermissions("worldedit.brush.pull") - public BrushSettings pullBrush(Player player, LocalSession session, + public void pullBrush(Player player, LocalSession session, @Arg(desc = "The radius to sample for blending", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new RaiseBrush()).setSize(radius); + set(session, context, new RaiseBrush()).setSize(radius); } @Command( @@ -188,11 +189,11 @@ public class BrushCommands { desc = "Creates a circle which revolves around your facing direction" ) @CommandPermissions("worldedit.brush.sphere") - public BrushSettings circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, + public void circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill); + set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill); } @Command( @@ -203,18 +204,15 @@ public class BrushCommands { "Note: Set a mask to recurse along specific blocks" ) @CommandPermissions("worldedit.brush.recursive") - public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, + public void recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "5") Expression radius, @Switch(name = 'd', desc = "Apply in depth first order") boolean depthFirst, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, - new RecurseBrush(depthFirst)) - .setSize(radius) - .setFill(fill) - .setMask(new IdMask(editSession)); + set(session, context, new RecurseBrush(depthFirst)) + .setSize(radius).setFill(fill).setMask(new IdMask(editSession)); } @Command( @@ -223,7 +221,7 @@ public class BrushCommands { desc = "Create lines" ) @CommandPermissions("worldedit.brush.line") - public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill, + public void lineBrush(Player player, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "0") Expression radius, @Switch(name = 'h', desc = "Create only a shell") @@ -233,10 +231,7 @@ public class BrushCommands { @Switch(name = 'f', desc = "Create a flat line") boolean flat, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, - new LineBrush(shell, select, flat)) - .setSize(radius) - .setFill(fill); + set(session, context, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill); } @Command( @@ -250,12 +245,12 @@ public class BrushCommands { "Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/" ) @CommandPermissions("worldedit.brush.spline") - public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, + public void splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "25") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); player.print(BBC.BRUSH_SPLINE.format(radius)); - return set(session, context, + set(session, context, new SplineBrush(player, session)) .setSize(radius) .setFill(fill); @@ -270,9 +265,9 @@ public class BrushCommands { "Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve" ) @CommandPermissions("worldedit.brush.sweep") - public BrushSettings sweepBrush(Player player, LocalSession session, @Arg(name = "copies", desc = "int", def = "-1") int copies, InjectedValueAccess context) throws WorldEditException { + public void sweepBrush(Player player, LocalSession session, @Arg(name = "copies", desc = "int", def = "-1") int copies, InjectedValueAccess context) throws WorldEditException { player.print(BBC.BRUSH_SPLINE.s()); - return set(session, context, new SweepBrush(copies)); + set(session, context, new SweepBrush(copies)); } @Command( @@ -281,7 +276,7 @@ public class BrushCommands { desc = "Create a hanging line between two points" ) @CommandPermissions("worldedit.brush.spline") - public BrushSettings catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor, + public void catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor, @Arg(desc = "The radius to sample for blending", def = "0") Expression radius, @Switch(name = 'h', desc = "Create only a shell") @@ -293,7 +288,7 @@ public class BrushCommands { InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor); - return set(session, context, + set(session, context, new CatenaryBrush(shell, select, facingDirection, lengthFactor)) .setSize(radius) .setFill(fill); @@ -307,12 +302,12 @@ public class BrushCommands { "Video: https://www.youtube.com/watch?v=zSN-2jJxXlM" ) @CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0, - public BrushSettings surfaceSpline(Player player, LocalSession session, Pattern fill, + public void surfaceSpline(Player player, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "0") Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException { player.print(BBC.BRUSH_SPLINE.format(radius)); worldEdit.checkMaxBrushRadius(radius); - return set(session, context, + set(session, context, new SurfaceSpline(tension, bias, continuity, quality)) .setSize(radius) .setFill(fill); @@ -324,14 +319,11 @@ public class BrushCommands { desc = "Creates a distorted sphere" ) @CommandPermissions("worldedit.brush.rock") - public BrushSettings blobBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Vector3", def = "10") Vector3 radius, @Arg(name = "sphericity", desc = "double", def = "100") double sphericity, @Arg(name = "frequency", desc = "double", def = "30") double frequency, @Arg(name = "amplitude", desc = "double", def = "50") double amplitude, InjectedValueAccess context) throws WorldEditException { + public void blobBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Vector3", def = "10") Vector3 radius, @Arg(name = "sphericity", desc = "double", def = "100") double sphericity, @Arg(name = "frequency", desc = "double", def = "30") double frequency, @Arg(name = "amplitude", desc = "double", def = "50") double amplitude, InjectedValueAccess context) throws WorldEditException { double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); worldEdit.checkMaxBrushRadius(max); Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100); - return set(session, context, - brush) - .setSize(max) - .setFill(fill); + set(session, context, brush).setSize(max).setFill(fill); } @Command( @@ -340,7 +332,7 @@ public class BrushCommands { desc = "Choose the sphere brush" ) @CommandPermissions("worldedit.brush.sphere") - public BrushSettings sphereBrush(Player player, LocalSession session, + public void sphereBrush(Player player, LocalSession session, @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the sphere", def = "2") @@ -370,7 +362,7 @@ public class BrushCommands { } } - return set(session, context, + set(session, context, brush) .setSize(radius) .setFill(pattern); @@ -384,12 +376,12 @@ public class BrushCommands { "Pic: https://i.imgur.com/2xKsZf2.png" ) @CommandPermissions("worldedit.brush.shatter") - public BrushSettings shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, + public void shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "10") Expression radius, @Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, + set(session, context, new ShatterBrush(count)) .setSize(radius) .setFill(fill) @@ -402,7 +394,7 @@ public class BrushCommands { descFooter = "Use a height map to paint any surface.\n" ) @CommandPermissions("worldedit.brush.stencil") - public BrushSettings stencilBrush(Player player, LocalSession session, Pattern fill, + public void stencilBrush(Player player, LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @@ -421,7 +413,7 @@ public class BrushCommands { if (randomRotate) { brush.setRandomRotate(true); } - return set(session, context, + set(session, context, brush) .setSize(radius) .setFill(fill); @@ -433,7 +425,7 @@ public class BrushCommands { desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.\n") @CommandPermissions("worldedit.brush.stencil") - public BrushSettings imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, + public void imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, ProvideBindings.ImageUri imageUri, @Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @@ -450,7 +442,7 @@ public class BrushCommands { alpha = true; } ImageBrush brush = new ImageBrush(image, session, alpha); - return set(session, context, + set(session, context, brush) .setSize(radius); } @@ -464,12 +456,12 @@ public class BrushCommands { "The -r flag will apply random rotation" ) @CommandPermissions("worldedit.brush.surface") - public BrushSettings surfaceBrush(LocalSession session, Pattern fill, + public void surfaceBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius); + set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius); } @Command( @@ -479,7 +471,7 @@ public class BrushCommands { "Video: https://youtu.be/RPZIaTbqoZw?t=34s" ) @CommandPermissions("worldedit.brush.scatter") - public BrushSettings scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "5") double pointsOpt, @Arg(name = "distance", desc = "double", def = "1") double distanceOpt, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException { + public void scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "5") double pointsOpt, @Arg(name = "distance", desc = "double", def = "1") double distanceOpt, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Brush brush; if (overlay) { @@ -487,7 +479,7 @@ public class BrushCommands { } else { brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt); } - return set(session, context, + set(session, context, brush) .setSize(radius) .setFill(fill); @@ -499,21 +491,21 @@ public class BrushCommands { desc = "Scatter a schematic on a surface" ) @CommandPermissions("worldedit.brush.populateschematic") - public BrushSettings scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radius, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException { + public void scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radius, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); try { MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); if (clipboards == null) { BBC.SCHEMATIC_NOT_FOUND.send(player, clipboardStr); - return null; + return; } List holders = clipboards.getHolders(); if (holders == null) { BBC.SCHEMATIC_NOT_FOUND.send(player, clipboardStr); - return null; + return; } - return set(session, context, + set(session, context, new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius); } catch (IOException e) { throw new RuntimeException(e); @@ -528,9 +520,9 @@ public class BrushCommands { "Pic: https://i.imgur.com/XV0vYoX.png" ) @CommandPermissions("worldedit.brush.layer") - public BrushSettings surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List blockLayers, InjectedValueAccess context) throws WorldEditException { + public void surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List blockLayers, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius); + set(session, context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius); } @Command( @@ -542,9 +534,9 @@ public class BrushCommands { "Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block." ) @CommandPermissions("worldedit.brush.splatter") - public BrushSettings splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double pointsOpt, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException { + public void splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double pointsOpt, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill); + set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill); } @Command( @@ -558,9 +550,9 @@ public class BrushCommands { " - Placeholders: {x}, {y}, {z}, {world}, {size}" ) @CommandPermissions("worldedit.brush.scattercommand") - public BrushSettings scatterCommandBrush(Player player, EditSession editSession, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, double points, double distance, List commandStr, InjectedValueAccess context) throws WorldEditException { + public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, double points, double distance, List commandStr, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, + set(session, context, new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " "))) .setSize(radius); } @@ -571,7 +563,7 @@ public class BrushCommands { desc = "Choose the cylinder brush" ) @CommandPermissions("worldedit.brush.cylinder") - public BrushSettings cylinderBrush(Player player, LocalSession session, + public void cylinderBrush(Player player, LocalSession session, @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the cylinder", def = "2") @@ -592,7 +584,6 @@ public class BrushCommands { } settings.setSize(radius) .setFill(pattern); - return settings; } @Command( @@ -605,7 +596,7 @@ public class BrushCommands { ) @Deprecated @CommandPermissions("worldedit.brush.clipboard") - public BrushSettings clipboardBrush(Player player,LocalSession session, + public void clipboardBrush(Player player,LocalSession session, @Switch(name = 'a', desc = "Don't paste air from the clipboard") boolean ignoreAir, @Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it") @@ -629,7 +620,7 @@ public class BrushCommands { worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1); worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1); - return set(session, context, new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask)); + set(session, context, new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask)); } @Command( @@ -638,7 +629,7 @@ public class BrushCommands { descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'" ) @CommandPermissions("worldedit.brush.smooth") - public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession, + public void smoothBrush(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The radius to sample for softening", def = "2") Expression radius, @Arg(desc = "The number of iterations to perform", def = "4") @@ -651,7 +642,7 @@ public class BrushCommands { FaweLimit limit = Settings.IMP.getLimit(fp); iterations = Math.min(limit.MAX_ITERATIONS, iterations); - return set(session, context, + set(session, context, new SmoothBrush(iterations, maskOpt)) .setSize(radius); } @@ -662,14 +653,14 @@ public class BrushCommands { desc = "Shortcut fire extinguisher brush" ) @CommandPermissions("worldedit.brush.ex") - public BrushSettings extinguishBrush(Player player, LocalSession session, EditSession editSession, + public void extinguishBrush(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The radius to extinguish", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Pattern fill = BlockTypes.AIR.getDefaultState(); - return set(session, context, + set(session, context, new SphereBrush()) .setSize(radius) .setFill(fill) @@ -682,7 +673,7 @@ public class BrushCommands { desc = "Gravity brush, simulates the effect of gravity" ) @CommandPermissions("worldedit.brush.gravity") - public BrushSettings gravityBrush(Player player, LocalSession session, + public void gravityBrush(Player player, LocalSession session, @Arg(desc = "The radius to apply gravity in", def = "5") Expression radius, @Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius") @@ -690,7 +681,7 @@ public class BrushCommands { InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, + set(session, context, new GravityBrush(fromMaxY)) .setSize(radius); } @@ -707,8 +698,8 @@ public class BrushCommands { "Snow Pic: https://i.imgur.com/Hrzn0I4.png" ) @CommandPermissions("worldedit.brush.height") - public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + public void heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { + terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); } @Command( @@ -718,7 +709,7 @@ public class BrushCommands { descFooter = "This brush flattens terrain and creates cliffs." ) @CommandPermissions("worldedit.brush.height") - public BrushSettings cliffBrush(Player player, LocalSession session, + public void cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") @@ -733,7 +724,7 @@ public class BrushCommands { boolean layers, @Switch(name = 's', desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); + terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); } @Command( @@ -742,17 +733,17 @@ public class BrushCommands { desc = "This brush raises or lowers land towards the clicked point" ) @CommandPermissions("worldedit.brush.height") - public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, + public void flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "Enables random off-axis rotation") boolean randomRotate, @Switch(name = 'l', desc = "Will work on snow layers") boolean layers, @Switch(name = 's', desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); } - private BrushSettings terrainBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, ScalableHeightMap.Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { + private void terrainBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { worldEdit.checkMaxBrushRadius(radius); InputStream stream = getHeightmapStream(image); HeightBrush brush; @@ -772,9 +763,9 @@ public class BrushCommands { if (randomRotate) { brush.setRandomRotate(true); } - return set(session, context, - brush) - .setSize(radius); + set(session, context, + brush) + .setSize(radius); } private InputStream getHeightmapStream(String filename) throws FileNotFoundException { @@ -789,7 +780,7 @@ public class BrushCommands { @Command( name = "copypaste", - aliases = {"copy", "paste", "cp", "copypasta"}, + aliases = {"cp", "copypasta"}, desc = "Copy Paste brush", descFooter = "Left click the base of an object to copy.\n" + "Right click to paste\n" + @@ -797,11 +788,11 @@ public class BrushCommands { "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw" ) @CommandPermissions("worldedit.brush.copy") - public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException { + public void copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); player.print(BBC.BRUSH_COPY.format(radius)); - return set(session, context, + set(session, context, new CopyPastaBrush(player, session, randomRotate, autoRotate)) .setSize(radius); } @@ -815,10 +806,10 @@ public class BrushCommands { " - Placeholders: {x}, {y}, {z}, {world}, {size}" ) @CommandPermissions("worldedit.brush.command") - public BrushSettings command(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, @Arg(desc = "Command to run") List input, InjectedValueAccess context) throws WorldEditException { + public void command(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, @Arg(desc = "Command to run") List input, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); String cmd = StringMan.join(input, " "); - return set(session, context, + set(session, context, new CommandBrush(cmd)) .setSize(radius); } @@ -829,7 +820,7 @@ public class BrushCommands { desc = "Butcher brush, kills mobs within a radius" ) @CommandPermissions("worldedit.brush.butcher") - public BrushSettings butcherBrush(Player player, LocalSession session, InjectedValueAccess context, + public void butcherBrush(Player player, LocalSession session, InjectedValueAccess context, @Arg(desc = "Radius to kill mobs in", def = "5") Expression radius, @Switch(name = 'p', desc = "Also kill pets") @@ -860,9 +851,7 @@ public class BrushCommands { flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged"); flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands"); - return set(session, context, - new ButcherBrush(flags)) - .setSize(radius); + set(session, context, new ButcherBrush(flags)).setSize(radius); } public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index c4e78042a..5fcae45ed 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -1,448 +1,448 @@ -package com.sk89q.worldedit.command; - -import com.boydti.fawe.object.mask.AdjacentAnyMask; -import com.boydti.fawe.object.mask.AdjacentMask; -import com.boydti.fawe.object.mask.AngleMask; -import com.boydti.fawe.object.mask.BiomeMask; -import com.boydti.fawe.object.mask.BlockLightMask; -import com.boydti.fawe.object.mask.BrightnessMask; -import com.boydti.fawe.object.mask.DataMask; -import com.boydti.fawe.object.mask.ExtremaMask; -import com.boydti.fawe.object.mask.IdDataMask; -import com.boydti.fawe.object.mask.IdMask; -import com.boydti.fawe.object.mask.LightMask; -import com.boydti.fawe.object.mask.OpacityMask; -import com.boydti.fawe.object.mask.ROCAngleMask; -import com.boydti.fawe.object.mask.RadiusMask; -import com.boydti.fawe.object.mask.RandomMask; -import com.boydti.fawe.object.mask.SimplexMask; -import com.boydti.fawe.object.mask.SkyLightMask; -import com.boydti.fawe.object.mask.SurfaceMask; -import com.boydti.fawe.object.mask.WallMask; -import com.boydti.fawe.object.mask.XAxisMask; -import com.boydti.fawe.object.mask.YAxisMask; -import com.boydti.fawe.object.mask.ZAxisMask; -import com.sk89q.worldedit.IncompleteRegionException; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; -import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.function.mask.BlockMaskBuilder; -import com.sk89q.worldedit.function.mask.ExistingBlockMask; -import com.sk89q.worldedit.function.mask.ExpressionMask; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.MaskIntersection; -import com.sk89q.worldedit.function.mask.MaskUnion; -import com.sk89q.worldedit.function.mask.Masks; -import com.sk89q.worldedit.function.mask.OffsetMask; -import com.sk89q.worldedit.function.mask.RegionMask; -import com.sk89q.worldedit.function.mask.SolidBlockMask; -import com.sk89q.worldedit.internal.expression.Expression; -import com.sk89q.worldedit.internal.expression.ExpressionException; -import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; -import com.sk89q.worldedit.session.request.RequestSelection; -import com.sk89q.worldedit.world.biome.BiomeType; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.Switch; - -//@Command(aliases = {"masks"}, -// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)", -// descFooter = "Masks determine if a block can be placed\n" + -// " - Use [brackets] for arguments\n" + -// " - Use , to OR multiple\n" + -// " - Use & to AND multiple\n" + -// "e.g. >[stone,dirt],#light[0][5],$jungle\n" + -// "More Info: https://git.io/v9r4K" +//package com.sk89q.worldedit.command; +// +//import com.boydti.fawe.object.mask.AdjacentAnyMask; +//import com.boydti.fawe.object.mask.AdjacentMask; +//import com.boydti.fawe.object.mask.AngleMask; +//import com.boydti.fawe.object.mask.BiomeMask; +//import com.boydti.fawe.object.mask.BlockLightMask; +//import com.boydti.fawe.object.mask.BrightnessMask; +//import com.boydti.fawe.object.mask.DataMask; +//import com.boydti.fawe.object.mask.ExtremaMask; +//import com.boydti.fawe.object.mask.IdDataMask; +//import com.boydti.fawe.object.mask.IdMask; +//import com.boydti.fawe.object.mask.LightMask; +//import com.boydti.fawe.object.mask.OpacityMask; +//import com.boydti.fawe.object.mask.ROCAngleMask; +//import com.boydti.fawe.object.mask.RadiusMask; +//import com.boydti.fawe.object.mask.RandomMask; +//import com.boydti.fawe.object.mask.SimplexMask; +//import com.boydti.fawe.object.mask.SkyLightMask; +//import com.boydti.fawe.object.mask.SurfaceMask; +//import com.boydti.fawe.object.mask.WallMask; +//import com.boydti.fawe.object.mask.XAxisMask; +//import com.boydti.fawe.object.mask.YAxisMask; +//import com.boydti.fawe.object.mask.ZAxisMask; +//import com.sk89q.worldedit.IncompleteRegionException; +//import com.sk89q.worldedit.LocalSession; +//import com.sk89q.worldedit.WorldEdit; +//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; +//import com.sk89q.worldedit.entity.Player; +//import com.sk89q.worldedit.extent.Extent; +//import com.sk89q.worldedit.function.mask.BlockMaskBuilder; +//import com.sk89q.worldedit.function.mask.ExistingBlockMask; +//import com.sk89q.worldedit.function.mask.ExpressionMask; +//import com.sk89q.worldedit.function.mask.Mask; +//import com.sk89q.worldedit.function.mask.MaskIntersection; +//import com.sk89q.worldedit.function.mask.MaskUnion; +//import com.sk89q.worldedit.function.mask.Masks; +//import com.sk89q.worldedit.function.mask.OffsetMask; +//import com.sk89q.worldedit.function.mask.RegionMask; +//import com.sk89q.worldedit.function.mask.SolidBlockMask; +//import com.sk89q.worldedit.internal.expression.Expression; +//import com.sk89q.worldedit.internal.expression.ExpressionException; +//import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; +//import com.sk89q.worldedit.math.BlockVector3; +//import com.sk89q.worldedit.math.Vector3; +//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; +//import com.sk89q.worldedit.session.request.RequestSelection; +//import com.sk89q.worldedit.world.biome.BiomeType; +//import org.enginehub.piston.annotation.Command; +//import org.enginehub.piston.annotation.CommandContainer; +//import org.enginehub.piston.annotation.param.Arg; +//import org.enginehub.piston.annotation.param.Switch; +// +////@Command(aliases = {"masks"}, +//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)", +//// descFooter = "Masks determine if a block can be placed\n" + +//// " - Use [brackets] for arguments\n" + +//// " - Use , to OR multiple\n" + +//// " - Use & to AND multiple\n" + +//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" + +//// "More Info: https://git.io/v9r4K" +////) +//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) +//public class MaskCommands { +// private final WorldEdit worldEdit; +// +// public MaskCommands(WorldEdit worldEdit) { +// this.worldEdit = worldEdit; +// } +// +// @Command( +// name = "#simplex", +// desc = "Use simplex noise as the mask" +// ) +// public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// scale = 1d / Math.max(1, scale); +// minInt = (minInt - 50) / 50; +// maxInt = (maxInt - 50) / 50; +// return new SimplexMask(scale, minInt, maxInt); +// } +// +// @Command( +// name = "#light", +// desc = "Restrict to specific light levels" +// ) +// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// return new LightMask(extent, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "#false", +// desc = "Always false" +// ) +// public Mask falseMask(Extent extent) { +// return Masks.alwaysFalse(); +// } +// +// @Command( +// name = "#true", +// desc = "Always true" +// ) +// public Mask trueMask(Extent extent) { +// return Masks.alwaysTrue(); +// } +// +// @Command( +// name = "#skylight", +// desc = "Restrict to specific sky light levels" +// ) +// public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// return new SkyLightMask(extent, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "#blocklight", +// aliases = {"#emittedlight"}, +// desc = "Restrict to specific block light levels" +// ) +// public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// return new BlockLightMask(extent, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "#opacity", +// desc = "Restrict to specific opacity levels" +// ) +// public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// return new OpacityMask(extent, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "#brightness", +// desc = "Restrict to specific block brightness" +// ) +// public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { +// return new BrightnessMask(extent, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "#offset", +// desc = "Offset a mask" +// ) +// public Mask offset(double x, double y, double z, Mask mask) { +// return new OffsetMask(mask, BlockVector3.at(x, y, z)); +// } +// +// @Command( +// name = "#haslight", +// desc = "Restricts to blocks with light (sky or emitted)" +// ) +// public Mask haslight(Extent extent) { +// return new LightMask(extent, 1, Integer.MAX_VALUE); +// } +// +// @Command( +// name = "#nolight", +// desc = "Restrict to blocks without light (sky or emitted)" +// ) +// public Mask nolight(Extent extent) { +// return new LightMask(extent, 0, 0); +// } +// +// @Command( +// name = "#existing", +// desc = "If there is a non air block" +// ) +// public Mask existing(Extent extent) { +// return new ExistingBlockMask(extent); +// } +// +// @Command( +// name = "#solid", +// desc = "If there is a solid block" +// ) +// public Mask solid(Extent extent) { +// return new SolidBlockMask(extent); +// } +// +// @Command( +// name = "#liquid", +// desc = "If there is a solid block" +// ) +// public Mask liquid(Extent extent) { +// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent); +// } +// +// @Command( +// name = "#dregion", +// aliases = {"#dselection", "#dsel"}, +// desc = "inside the player's selection" +// ) +// public Mask dregion() { +// return new RegionMask(new RequestSelection()); +// } +// +// @Command( +// name = "#region", +// aliases = {"#selection", "#sel"}, +// desc = "inside the provided selection" +// ) +// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException { +// return new RegionMask(session.getSelection(player.getWorld()).clone()); +// } +// +// @Command( +// name = "#xaxis", +// desc = "Restrict to initial x axis" +// ) +// public Mask xaxis() { +// return new XAxisMask(); +// } +// +// @Command( +// name = "#yaxis", +// desc = "Restrict to initial y axis" +// ) +// public Mask yaxis() { +// return new YAxisMask(); +// } +// +// @Command( +// name = "#zaxis", +// desc = "Restrict to initial z axis" +// ) +// public Mask zaxis() { +// return new ZAxisMask(); +// } +// +// @Command( +// name = "#id", +// desc = "Restrict to initial id" +// ) +// public Mask id(Extent extent) { +// return new IdMask(extent); +// } +// +// @Command( +// name = "#data", +// desc = "Restrict to initial data" +// ) +// public Mask data(Extent extent) { +// return new DataMask(extent); +// } +// +// @Command( +// name = "#iddata", +// desc = "Restrict to initial block id and data" +// ) +// public Mask iddata(Extent extent) { +// return new IdDataMask(extent); +// } +// +// @Command( +// name = "#air", +// desc = "Restrict to types of air" +// ) +// public Mask air(Extent extent) { +// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent); +// } +// +// @Command( +// name = "#wall", +// desc = "Restrict to walls (any block n,e,s,w of air)" +// ) +// public Mask wall(Extent extent) { +// Mask blockMask = air(extent); +// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8)); +// } +// +// @Command( +// name = "#surface", +// desc = "Restrict to surfaces (any solid block touching air)" +// ) +// public Mask surface(Extent extent) { +// return new SurfaceMask(extent); +// } +// +// @Command( +// name = "\\", +// aliases = {"/", "#angle", "#\\", "#/"}, +// desc = "Restrict to specific terrain angle", +// descFooter = "Restrict to specific terrain angle\n" + +// "The -o flag will only overlay\n" + +// "Example: /[0d][45d]\n" + +// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" + +// "Example: /[3][20]\n" + +// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below" //) -@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) -public class MaskCommands { - private final WorldEdit worldEdit; - - public MaskCommands(WorldEdit worldEdit) { - this.worldEdit = worldEdit; - } - - @Command( - name = "#simplex", - desc = "Use simplex noise as the mask" -) - public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - scale = 1d / Math.max(1, scale); - minInt = (minInt - 50) / 50; - maxInt = (maxInt - 50) / 50; - return new SimplexMask(scale, minInt, maxInt); - } - - @Command( - name = "#light", - desc = "Restrict to specific light levels" -) - public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new LightMask(extent, (int) minInt, (int) maxInt); - } - - @Command( - name = "#false", - desc = "Always false" - ) - public Mask falseMask(Extent extent) { - return Masks.alwaysFalse(); - } - - @Command( - name = "#true", - desc = "Always true" - ) - public Mask trueMask(Extent extent) { - return Masks.alwaysTrue(); - } - - @Command( - name = "#skylight", - desc = "Restrict to specific sky light levels" - ) - public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new SkyLightMask(extent, (int) minInt, (int) maxInt); - } - - @Command( - name = "#blocklight", - aliases = {"#emittedlight"}, - desc = "Restrict to specific block light levels" -) - public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new BlockLightMask(extent, (int) minInt, (int) maxInt); - } - - @Command( - name = "#opacity", - desc = "Restrict to specific opacity levels" -) - public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new OpacityMask(extent, (int) minInt, (int) maxInt); - } - - @Command( - name = "#brightness", - desc = "Restrict to specific block brightness" -) - public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new BrightnessMask(extent, (int) minInt, (int) maxInt); - } - - @Command( - name = "#offset", - desc = "Offset a mask" -) - public Mask offset(double x, double y, double z, Mask mask) { - return new OffsetMask(mask, BlockVector3.at(x, y, z)); - } - - @Command( - name = "#haslight", - desc = "Restricts to blocks with light (sky or emitted)" - ) - public Mask haslight(Extent extent) { - return new LightMask(extent, 1, Integer.MAX_VALUE); - } - - @Command( - name = "#nolight", - desc = "Restrict to blocks without light (sky or emitted)" - ) - public Mask nolight(Extent extent) { - return new LightMask(extent, 0, 0); - } - - @Command( - name = "#existing", - desc = "If there is a non air block" - ) - public Mask existing(Extent extent) { - return new ExistingBlockMask(extent); - } - - @Command( - name = "#solid", - desc = "If there is a solid block" - ) - public Mask solid(Extent extent) { - return new SolidBlockMask(extent); - } - - @Command( - name = "#liquid", - desc = "If there is a solid block" - ) - public Mask liquid(Extent extent) { - return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent); - } - - @Command( - name = "#dregion", - aliases = {"#dselection", "#dsel"}, - desc = "inside the player's selection" - ) - public Mask dregion() { - return new RegionMask(new RequestSelection()); - } - - @Command( - name = "#region", - aliases = {"#selection", "#sel"}, - desc = "inside the provided selection" - ) - public Mask selection(Player player, LocalSession session) throws IncompleteRegionException { - return new RegionMask(session.getSelection(player.getWorld()).clone()); - } - - @Command( - name = "#xaxis", - desc = "Restrict to initial x axis" - ) - public Mask xaxis() { - return new XAxisMask(); - } - - @Command( - name = "#yaxis", - desc = "Restrict to initial y axis" - ) - public Mask yaxis() { - return new YAxisMask(); - } - - @Command( - name = "#zaxis", - desc = "Restrict to initial z axis" - ) - public Mask zaxis() { - return new ZAxisMask(); - } - - @Command( - name = "#id", - desc = "Restrict to initial id" - ) - public Mask id(Extent extent) { - return new IdMask(extent); - } - - @Command( - name = "#data", - desc = "Restrict to initial data" - ) - public Mask data(Extent extent) { - return new DataMask(extent); - } - - @Command( - name = "#iddata", - desc = "Restrict to initial block id and data" - ) - public Mask iddata(Extent extent) { - return new IdDataMask(extent); - } - - @Command( - name = "#air", - desc = "Restrict to types of air" - ) - public Mask air(Extent extent) { - return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent); - } - - @Command( - name = "#wall", - desc = "Restrict to walls (any block n,e,s,w of air)" - ) - public Mask wall(Extent extent) { - Mask blockMask = air(extent); - return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8)); - } - - @Command( - name = "#surface", - desc = "Restrict to surfaces (any solid block touching air)" - ) - public Mask surface(Extent extent) { - return new SurfaceMask(extent); - } - - @Command( - name = "\\", - aliases = {"/", "#angle", "#\\", "#/"}, - desc = "Restrict to specific terrain angle", - descFooter = "Restrict to specific terrain angle\n" + - "The -o flag will only overlay\n" + - "Example: /[0d][45d]\n" + - "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" + - "Example: /[3][20]\n" + - "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below" -) - public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException { - double y1, y2; - boolean override; - if (maxStr.endsWith("d")) { - double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); - double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); - y1 = Math.tan(y1d * (Math.PI / 180)); - y2 = Math.tan(y2d * (Math.PI / 180)); - } else { - y1 = Expression.compile(minStr).evaluate(); - y2 = Expression.compile(maxStr).evaluate(); - } - return new AngleMask(extent, y1, y2, overlay, distanceOpt); - } - - @Command( - name = "(", - aliases = {")", "#roc", "#(", "#)"}, - desc = "Restrict to near specific terrain slope rate of change", - descFooter = "Restrict to near specific terrain slope rate of change\n" + - "The -o flag will only overlay\n" + - "Example: ([0d][45d][5]\n" + - "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" + - "Note: Use negatives for decreasing slope" -) - public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { - double y1, y2; - boolean override; - if (maxStr.endsWith("d")) { - double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); - double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); - y1 = Math.tan(y1d * (Math.PI / 180)); - y2 = Math.tan(y2d * (Math.PI / 180)); - } else { - y1 = Expression.compile(minStr).evaluate(); - y2 = Expression.compile(maxStr).evaluate(); - } - return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt); - } - - @Command( - name = "^", - aliases = {"#extrema", "#^"}, - desc = "Restrict to near specific terrain extrema", - descFooter = "Restrict to near specific terrain extrema\n" + - "The -o flag will only overlay\n" + - "Example: ([0d][45d][5]\n" + - "Explanation: Restrict to near 45 degrees of local maxima\n" + - "Note: Use negatives for local minima" -) - public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { - double y1, y2; - boolean override; - if (maxStr.endsWith("d")) { - double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); - double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); - y1 = Math.tan(y1d * (Math.PI / 180)); - y2 = Math.tan(y2d * (Math.PI / 180)); - } else { - y1 = Expression.compile(minStr).evaluate(); - y2 = Expression.compile(maxStr).evaluate(); - } - return new ExtremaMask(extent, y1, y2, overlay, distanceOpt); - } - - @Command( - name = "{", - aliases = {"#{"}, - desc = "Restricts blocks to within a specific radius range of the initial block" -) - public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { - return new RadiusMask((int) minInt, (int) maxInt); - } - - @Command( - name = "|", - aliases = {"#|", "#side"}, - desc = "sides with a specific number of other blocks" -) - public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { - return new WallMask(mask, (int) minInt, (int) maxInt); - } - - @Command( - name = "~", - aliases = {"#~", "#adjacent"}, - desc = "Adjacent to a specific number of other blocks" -) - public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException { - if (min == -1 && max == -1) { - min = 1; - max = 8; - } else if (max == -1) max = min; - if (max >= 8 && min == 1) { - return new AdjacentAnyMask(mask); - } - return new AdjacentMask(mask, (int) min, (int) max); - } - - @Command( - name = "<", - aliases = {"#<", "#below"}, - desc = "below a specific block" -) - public Mask below(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0)); - return new MaskIntersection(offsetMask, Masks.negate(mask)); - } - - @Command( - name = ">", - aliases = {"#>", "#above"}, - desc = "above a specific block" -) - public Mask above(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0)); - return new MaskIntersection(offsetMask, Masks.negate(mask)); - } - - @Command( - name = "$", - aliases = {"#biome", "#$"}, - desc = "in a specific biome", - descFooter = "in a specific biome. For a list of biomes use //biomelist" -) - public Mask biome(Extent extent, BiomeType biome) throws ExpressionException { - return new BiomeMask(extent, biome); - } - - @Command( - name = "%", - aliases = {"#%", "#percent"}, - desc = "percentage chance" -) - public Mask random(double chance) throws ExpressionException { - chance = chance / 100; - return new RandomMask(chance); - } - - @Command( - name = "=", - aliases = {"#=", "#expression"}, - desc = "expression mask" -) - public Mask expression(Extent extent, String input) throws ExpressionException { - Expression exp = Expression.compile(input, "x", "y", "z"); - ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO); - exp.setEnvironment(env); - return new ExpressionMask(exp); - } - - @Command( - name = "!", - aliases = {"#not", "#negate", "#!"}, - desc = "Negate another mask" -) - public Mask expression(Mask mask) throws ExpressionException { - return Masks.negate(mask); - } -} +// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException { +// double y1, y2; +// boolean override; +// if (maxStr.endsWith("d")) { +// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); +// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); +// y1 = Math.tan(y1d * (Math.PI / 180)); +// y2 = Math.tan(y2d * (Math.PI / 180)); +// } else { +// y1 = Expression.compile(minStr).evaluate(); +// y2 = Expression.compile(maxStr).evaluate(); +// } +// return new AngleMask(extent, y1, y2, overlay, distanceOpt); +// } +// +// @Command( +// name = "(", +// aliases = {")", "#roc", "#(", "#)"}, +// desc = "Restrict to near specific terrain slope rate of change", +// descFooter = "Restrict to near specific terrain slope rate of change\n" + +// "The -o flag will only overlay\n" + +// "Example: ([0d][45d][5]\n" + +// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" + +// "Note: Use negatives for decreasing slope" +//) +// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { +// double y1, y2; +// boolean override; +// if (maxStr.endsWith("d")) { +// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); +// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); +// y1 = Math.tan(y1d * (Math.PI / 180)); +// y2 = Math.tan(y2d * (Math.PI / 180)); +// } else { +// y1 = Expression.compile(minStr).evaluate(); +// y2 = Expression.compile(maxStr).evaluate(); +// } +// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt); +// } +// +// @Command( +// name = "^", +// aliases = {"#extrema", "#^"}, +// desc = "Restrict to near specific terrain extrema", +// descFooter = "Restrict to near specific terrain extrema\n" + +// "The -o flag will only overlay\n" + +// "Example: ([0d][45d][5]\n" + +// "Explanation: Restrict to near 45 degrees of local maxima\n" + +// "Note: Use negatives for local minima" +//) +// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { +// double y1, y2; +// boolean override; +// if (maxStr.endsWith("d")) { +// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); +// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); +// y1 = Math.tan(y1d * (Math.PI / 180)); +// y2 = Math.tan(y2d * (Math.PI / 180)); +// } else { +// y1 = Expression.compile(minStr).evaluate(); +// y2 = Expression.compile(maxStr).evaluate(); +// } +// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt); +// } +// +// @Command( +// name = "{", +// aliases = {"#{"}, +// desc = "Restricts blocks to within a specific radius range of the initial block" +//) +// public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { +// return new RadiusMask((int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "|", +// aliases = {"#|", "#side"}, +// desc = "sides with a specific number of other blocks" +//) +// public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { +// return new WallMask(mask, (int) minInt, (int) maxInt); +// } +// +// @Command( +// name = "~", +// aliases = {"#~", "#adjacent"}, +// desc = "Adjacent to a specific number of other blocks" +//) +// public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException { +// if (min == -1 && max == -1) { +// min = 1; +// max = 8; +// } else if (max == -1) max = min; +// if (max >= 8 && min == 1) { +// return new AdjacentAnyMask(mask); +// } +// return new AdjacentMask(mask, (int) min, (int) max); +// } +// +// @Command( +// name = "<", +// aliases = {"#<", "#below"}, +// desc = "below a specific block" +//) +// public Mask below(Mask mask) throws ExpressionException { +// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0)); +// return new MaskIntersection(offsetMask, Masks.negate(mask)); +// } +// +// @Command( +// name = ">", +// aliases = {"#>", "#above"}, +// desc = "above a specific block" +//) +// public Mask above(Mask mask) throws ExpressionException { +// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0)); +// return new MaskIntersection(offsetMask, Masks.negate(mask)); +// } +// +// @Command( +// name = "$", +// aliases = {"#biome", "#$"}, +// desc = "in a specific biome", +// descFooter = "in a specific biome. For a list of biomes use //biomelist" +//) +// public Mask biome(Extent extent, BiomeType biome) throws ExpressionException { +// return new BiomeMask(extent, biome); +// } +// +// @Command( +// name = "%", +// aliases = {"#%", "#percent"}, +// desc = "percentage chance" +//) +// public Mask random(double chance) throws ExpressionException { +// chance = chance / 100; +// return new RandomMask(chance); +// } +// +// @Command( +// name = "=", +// aliases = {"#=", "#expression"}, +// desc = "expression mask" +//) +// public Mask expression(Extent extent, String input) throws ExpressionException { +// Expression exp = Expression.compile(input, "x", "y", "z"); +// ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO); +// exp.setEnvironment(env); +// return new ExpressionMask(exp); +// } +// +// @Command( +// name = "!", +// aliases = {"#not", "#negate", "#!"}, +// desc = "Negate another mask" +//) +// public Mask expression(Mask mask) throws ExpressionException { +// return Masks.negate(mask); +// } +//} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java index 83999afa1..caaf29da6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.command.argument; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.command.util.SuggestionHelper; +import com.sk89q.worldedit.registry.IRegistry; import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.registry.Registry; import com.sk89q.worldedit.util.formatting.text.Component; @@ -28,6 +29,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.fluid.FluidCategory; import com.sk89q.worldedit.world.fluid.FluidType; @@ -52,7 +54,7 @@ public final class RegistryConverter implements ArgumentConvert @SuppressWarnings("unchecked") public static void register(CommandManager commandManager) { ImmutableList.of( - BlockType.class, + BlockTypes.class, BlockCategory.class, ItemType.class, ItemCategory.class, @@ -73,7 +75,7 @@ public final class RegistryConverter implements ArgumentConvert private static RegistryConverter from(Class registryType) { try { Field registryField = registryType.getDeclaredField("REGISTRY"); - Registry registry = (Registry) registryField.get(null); + IRegistry registry = (IRegistry) registryField.get(null); return new RegistryConverter<>(registry); } catch (NoSuchFieldException e) { throw new IllegalArgumentException("Not a registry-backed type: " + registryType.getName()); @@ -82,10 +84,10 @@ public final class RegistryConverter implements ArgumentConvert } } - private final Registry registry; + private final IRegistry registry; private final TextComponent choices; - private RegistryConverter(Registry registry) { + private RegistryConverter(IRegistry registry) { this.registry = registry; this.choices = TextComponent.of("any " + registry.getName()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java index 6985eba1d..8b284e8d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java @@ -61,7 +61,7 @@ public class DelegateCommandManager implements CommandManager { } @Override - public Object execute(InjectedValueAccess context, List args) { + public int execute(InjectedValueAccess context, List args) { return parent.execute(context, args); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java index dab0aae2b..0be89351b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/SuggestionHelper.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.command.util; +import com.sk89q.worldedit.registry.IRegistry; import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.registry.NamespacedRegistry; import com.sk89q.worldedit.registry.Registry; @@ -138,7 +139,7 @@ public final class SuggestionHelper { return Stream.empty(); } - public static Stream getRegistrySuggestions(Registry registry, String input) { + public static Stream getRegistrySuggestions(IRegistry registry, String input) { if (registry instanceof NamespacedRegistry) { return getNamespacedRegistrySuggestions(((NamespacedRegistry) registry), input); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultTransformParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultTransformParser.java index 0626d4a33..54ef4986f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultTransformParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultTransformParser.java @@ -10,7 +10,7 @@ import com.boydti.fawe.util.StringMan; import com.google.common.collect.Iterables; import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.command.TransformCommands; +//import com.sk89q.worldedit.command.TransformCommands; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java index 1c828ab9e..41359b87d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/DefaultPatternParser.java @@ -28,7 +28,7 @@ import com.google.common.collect.Iterables; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.command.PatternCommands; +//import com.sk89q.worldedit.command.PatternCommands; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 29bb01a2a..50d42f20f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -88,6 +88,7 @@ import com.sk89q.worldedit.command.ToolUtilCommands; import com.sk89q.worldedit.command.ToolUtilCommandsRegistration; import com.sk89q.worldedit.command.TransformCommands; import com.sk89q.worldedit.command.TransformCommandsRegistration; +import com.sk89q.worldedit.command.TransformCommandsRegistration; import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.command.UtilityCommandsRegistration; import com.sk89q.worldedit.command.WorldEditCommands; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index b438f4ba3..4e12d9d31 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -72,7 +72,9 @@ public class PlatformManager { private static final Logger logger = LoggerFactory.getLogger(PlatformManager.class); private final WorldEdit worldEdit; - private final PlatformCommandManager platformCommandManager; + + private PlatformCommandManager platformCommandManager; + private final List platforms = new ArrayList<>(); private final Map preferences = new EnumMap<>(Capability.class); private @Nullable String firstSeenVersion; @@ -87,7 +89,6 @@ public class PlatformManager { public PlatformManager(WorldEdit worldEdit) { checkNotNull(worldEdit); this.worldEdit = worldEdit; - this.platformCommandManager = new PlatformCommandManager(worldEdit, this); // Register this instance for events worldEdit.getEventBus().register(this); @@ -117,6 +118,10 @@ public class PlatformManager { } else { firstSeenVersion = platform.getVersion(); } + + if (this.platformCommandManager == null) { + this.platformCommandManager = new PlatformCommandManager(worldEdit, this); + } } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java index c74afd0dc..bdcd8e541 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java @@ -19,14 +19,12 @@ package com.sk89q.worldedit.internal.command; -import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import static java.util.stream.Collectors.toList; import org.enginehub.piston.Command; import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.inject.InjectedValueAccess; @@ -40,6 +38,9 @@ import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkState; +import static java.util.stream.Collectors.toList; + public class CommandUtil { public static Map getSubCommands(Command currentCommand) { @@ -64,20 +65,37 @@ public class CommandUtil { * Fix {@code suggestions} to replace the last space-separated word in {@code arguments}. */ public static List fixSuggestions(String arguments, List suggestions) { - Substring lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments)); + Substring lastArg = Iterables.getLast( + CommandArgParser.spaceSplit(arguments) + ); return suggestions.stream() - .map(suggestion -> CommandUtil.suggestLast(lastArg, suggestion)) + // Re-map suggestions to only operate on the last non-quoted word + .map(suggestion -> onlyOnLastQuotedWord(lastArg, suggestion)) + .map(suggestion -> suggestLast(lastArg, suggestion)) .filter(Optional::isPresent) .map(Optional::get) .collect(toList()); } + private static Substring onlyOnLastQuotedWord(Substring lastArg, Substring suggestion) { + if (suggestion.getSubstring().startsWith(lastArg.getSubstring())) { + // This is already fine. + return suggestion; + } + String substr = suggestion.getSubstring(); + int sp = substr.lastIndexOf(' '); + if (sp < 0) { + return suggestion; + } + return Substring.wrap(substr.substring(sp + 1), suggestion.getStart() + sp + 1, suggestion.getEnd()); + } + /** * Given the last word of a command, mutate the suggestion to replace the last word, if * possible. */ private static Optional suggestLast(Substring last, Substring suggestion) { - if (suggestion.getStart() == last.getEnd()) { + if (suggestion.getStart() == last.getEnd() && !last.getSubstring().equals("\"")) { // this suggestion is for the next argument. if (last.getSubstring().isEmpty()) { return Optional.of(suggestion.getSubstring()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java index 5a13140db..2ca8f3bd3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; @@ -114,11 +115,12 @@ public class ServerCUIHandler { } // Borrowed this math from FAWE - double rotX = player.getLocation().getYaw(); - double rotY = player.getLocation().getPitch(); + final Location location = player.getLocation(); + double rotX = location.getYaw(); + double rotY = location.getPitch(); double xz = Math.cos(Math.toRadians(rotY)); - int x = (int) (player.getLocation().getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12); - int z = (int) (player.getLocation().getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12); + int x = (int) (location.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12); + int z = (int) (location.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12); int y = Math.max(0, Math.min(Math.min(255, posY + 32), posY + 3)); Map structureTag = new HashMap<>(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/IRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/IRegistry.java new file mode 100644 index 000000000..a8e7c094c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/IRegistry.java @@ -0,0 +1,33 @@ +package com.sk89q.worldedit.registry; + +import javax.annotation.Nullable; + +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Locale; +import java.util.Set; +import java.util.stream.Stream; + +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; +import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; + +public interface IRegistry extends Iterable { + String getName(); + + V get(final String key); + + Set keySet(); + + Collection values(); + + @Override + default Iterator iterator() { + return values().iterator(); + } + + default Stream getSuggestions(String input) { + return limitByPrefix(keySet().stream(), input).stream(); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java index 1fe5d6862..56bd0b831 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java @@ -19,30 +19,39 @@ package com.sk89q.worldedit.registry; +import com.google.common.collect.Maps; + import static com.google.common.base.Preconditions.checkState; import static java.util.Objects.requireNonNull; import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; -public class Registry implements Iterable { - private final Map map = new HashMap<>(); +public class Registry implements IRegistry { + private final Map map; private final String name; - public Registry(final String name) { + public Registry(String name, Map map) { this.name = name; + this.map = map; + } + + public Registry(final String name) { + this(name, Maps.newHashMap()); } public String getName() { return name; } + public Map getMap() { + return map; + } + @Nullable public V get(final String key) { checkState(key.equals(key.toLowerCase(Locale.ROOT)), "key must be lowercase"); @@ -66,9 +75,4 @@ public class Registry implements Iterable { return Collections.unmodifiableCollection(this.map.values()); } - @Override - public Iterator iterator() { - return this.map.values().iterator(); - } - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java index 08ad67ff3..70dd62256 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java @@ -71,7 +71,7 @@ public class SessionManager { private static final Logger log = LoggerFactory.getLogger(SessionManager.class); private static boolean warnedInvalidTool; - private final Timer timer = new Timer(); + private final Timer timer = new Timer("WorldEdit Session Manager"); private final WorldEdit worldEdit; private final Map sessions = new HashMap<>(); private SessionStore store = new VoidStore(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/concurrency/EvenMoreExecutors.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/concurrency/EvenMoreExecutors.java index 5272039a1..1c40c9454 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/concurrency/EvenMoreExecutors.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/concurrency/EvenMoreExecutors.java @@ -19,8 +19,10 @@ package com.sk89q.worldedit.util.concurrency; -import java.util.concurrent.ArrayBlockingQueue; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -39,15 +41,33 @@ public final class EvenMoreExecutors { * * @param minThreads the minimum number of threads to have at a given time * @param maxThreads the maximum number of threads to have at a given time - * @param queueSize the size of the queue before new submissions are rejected + * @param queueSize the size of the queue before new submissions are rejected * @return the newly created thread pool */ public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize) { + return newBoundedCachedThreadPool(minThreads, maxThreads, queueSize, null); + } + + /** + * Creates a thread pool that creates new threads as needed up to + * a maximum number of threads, but will reuse previously constructed + * threads when they are available. + * + * @param minThreads the minimum number of threads to have at a given time + * @param maxThreads the maximum number of threads to have at a given time + * @param queueSize the size of the queue before new submissions are rejected + * @param threadFormat thread name formatter + * @return the newly created thread pool + */ + public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize, String threadFormat) { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( minThreads, maxThreads, 60L, TimeUnit.SECONDS, - new ArrayBlockingQueue<>(queueSize)); + new LinkedBlockingDeque<>(queueSize)); threadPoolExecutor.allowCoreThreadTimeOut(true); + if (threadFormat != null) { + threadPoolExecutor.setThreadFactory(new ThreadFactoryBuilder().setNameFormat(threadFormat).build()); + } return threadPoolExecutor; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java index ac7484846..ab8ebe029 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java @@ -19,8 +19,9 @@ package com.sk89q.worldedit.util.paste; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.util.net.HttpRequest; -import org.json.simple.JSONValue; import java.io.IOException; import java.net.URL; @@ -33,6 +34,8 @@ public class EngineHubPaste implements Paster { private static final Pattern URL_PATTERN = Pattern.compile("https?://.+$"); + private static final Gson GSON = new Gson(); + @Override public Callable paste(String content) { return new PasteTask(content); @@ -59,10 +62,10 @@ public class EngineHubPaste implements Paster { .returnContent() .asString("UTF-8").trim(); - Object object = JSONValue.parse(result); - if (object instanceof Map) { - @SuppressWarnings("unchecked") - String urlString = String.valueOf(((Map) object).get("url")); + Map object = GSON.fromJson(result, new TypeToken>() { + }.getType()); + if (object != null) { + String urlString = String.valueOf(object.get("url")); Matcher m = URL_PATTERN.matcher(urlString); if (m.matches()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 5cc38068d..b547a1c2e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -134,6 +134,11 @@ public class NullWorld extends AbstractWorld { return BlockVector3.ZERO; } + @Override + public void sendChunk(int X, int Z, int mask) { + + } + @Override public IChunkGet get(int x, int z) { return NullChunkGet.INSTANCE; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index eb44b59d1..010c97412 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -72,7 +72,6 @@ public interface World extends Extent, Keyed, IChunkCache { * * @return the maximum Y */ - @Override int getMaxY(); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index 0465bc21d..439498b80 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -29,6 +29,7 @@ import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.Keyed; +import com.sk89q.worldedit.registry.NamespacedRegistry; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; @@ -36,6 +37,7 @@ import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; + import java.util.Collections; import java.util.List; import java.util.Map; @@ -45,6 +47,9 @@ import java.util.stream.IntStream; import javax.annotation.Nullable; public class BlockType implements FawePattern, Keyed { + + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("block type"); + private final String id; private final BlockTypes.Settings settings; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 2abc4d052..8f1fb9343 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -26,11 +26,17 @@ import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.registry.IRegistry; +import com.sk89q.worldedit.registry.NamespacedRegistry; +import com.sk89q.worldedit.registry.Registry; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.registry.BlockMaterial; +import com.sk89q.worldedit.world.registry.BlockRegistry; import com.sk89q.worldedit.world.registry.LegacyMapper; +import com.sk89q.worldedit.world.registry.Registries; import javax.annotation.Nullable; import java.lang.reflect.Field; @@ -871,18 +877,22 @@ public final class BlockTypes { public static final int BIT_OFFSET; // Used internally protected static final int BIT_MASK; // Used internally - private static final Map $REGISTRY = new HashMap<>(); +// private static final Map $REGISTRY = new HashMap<>(); +// public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("block type", $REGISTRY); public static final BlockType[] values; public static final BlockState[] states; - private static final Set $NAMESPACES = new LinkedHashSet(); + private static final Set $NAMESPACES = new LinkedHashSet<>(); static { try { ArrayList stateList = new ArrayList<>(); - Collection blocks = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().registerBlocks(); + Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS); + Registries registries = platform.getRegistries(); + BlockRegistry blockReg = registries.getBlockRegistry(); + Collection blocks = blockReg.registerBlocks(); Map blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('[')) : item, item -> item)); int size = blockMap.size(); @@ -928,7 +938,7 @@ public final class BlockTypes { // Add to $Registry for (BlockType type : values) { - $REGISTRY.put(type.getId().toLowerCase(Locale.ROOT), type); + BlockType.REGISTRY.register(type.getId().toLowerCase(Locale.ROOT), type); } states = stateList.toArray(new BlockState[stateList.size()]); @@ -954,15 +964,13 @@ public final class BlockTypes { try { Field field = BlockTypes.class.getDeclaredField(enumName); ReflectionUtils.setFailsafeFieldValue(field, null, existing); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } // register states - if (typeName.startsWith("minecraft:")) $REGISTRY.put(typeName.substring(10), existing); - $REGISTRY.put(typeName, existing); + if (typeName.startsWith("minecraft:")) BlockType.REGISTRY.register(typeName.substring(10), existing); + BlockType.REGISTRY.register(typeName, existing); String nameSpace = typeName.substring(0, typeName.indexOf(':')); $NAMESPACES.add(nameSpace); return existing; @@ -980,7 +988,7 @@ public final class BlockTypes { String input = inputLower; if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input; - BlockType result = $REGISTRY.get(input); + BlockType result = BlockType.REGISTRY.get(input); if (result != null) return result; try { @@ -1002,11 +1010,11 @@ public final class BlockTypes { } public static @Nullable BlockType get(final String id) { - return $REGISTRY.get(id); + return BlockType.REGISTRY.getMap().get(id); } public static @Nullable BlockType get(final CharSequence id) { - return $REGISTRY.get(id); + return BlockType.REGISTRY.getMap().get(id); } @Deprecated diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 8da5e576b..1327c99ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -22,6 +22,8 @@ package com.sk89q.worldedit.world.registry; import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonPrimitive; import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; @@ -76,6 +78,15 @@ public final class BundledBlockData { private void loadFromResource() throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); + gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer) (json, typeOfT, context) -> { + JsonPrimitive primitive = (JsonPrimitive) json; + if (primitive.isString()) { + String value = primitive.getAsString(); + if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16); + return Integer.parseInt(value); + } + return primitive.getAsInt(); + }); Gson gson = gsonBuilder.create(); URL url = null; final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java index 3399cb9cd..d13663427 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java @@ -66,13 +66,13 @@ public class SnapshotRepository { } /** - * Get a list of snapshots in a directory. The newest snapshot is near the top of the array. + * Get a list of snapshots in a directory. The newest snapshot is + * near the top of the array. * * @param newestFirst true to get the newest first * @return a list of snapshots */ - public List getSnapshots(boolean newestFirst, String worldName) - throws MissingWorldException { + public List getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException { FilenameFilter filter = (dir, name) -> { File f = new File(dir, name); return isValidSnapshot(f); @@ -116,8 +116,7 @@ public class SnapshotRepository { * @return a snapshot or null */ @Nullable - public Snapshot getSnapshotAfter(ZonedDateTime date, String world) - throws MissingWorldException { + public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException { List snapshots = getSnapshots(true, world); Snapshot last = null; @@ -139,8 +138,7 @@ public class SnapshotRepository { * @return a snapshot or null */ @Nullable - public Snapshot getSnapshotBefore(ZonedDateTime date, String world) - throws MissingWorldException { + public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException { List snapshots = getSnapshots(false, world); Snapshot last = null; @@ -206,8 +204,7 @@ public class SnapshotRepository { * @return whether it is a valid snapshot */ protected boolean isValidSnapshot(File file) { - if (!file.getName() - .matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) { + if (!file.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) { return false; } diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json index d5f98648d..1c3009b6b 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json @@ -283,7 +283,7 @@ "hardness": 2.0, "resistance": 3.0, "ticksRandomly": false, - "fullCube": true, + "fullCube": false, "slipperiness": 0.6, "liquid": false, "solid": true, @@ -758,7 +758,7 @@ "hardness": 3.0, "resistance": 3.0, "ticksRandomly": false, - "fullCube": true, + "fullCube": false, "slipperiness": 0.6, "liquid": false, "solid": true, @@ -771,7 +771,7 @@ "unpushable": false, "mapColor": "#000000", "isTranslucent": false, - "hasContainer": false + "hasContainer": true } }, { @@ -1133,7 +1133,7 @@ "hardness": 2.0, "resistance": 3.0, "ticksRandomly": false, - "fullCube": true, + "fullCube": false, "slipperiness": 0.6, "liquid": false, "solid": true, @@ -1246,7 +1246,7 @@ "unpushable": false, "mapColor": "#8f7748", "isTranslucent": false, - "hasContainer": false + "hasContainer": true } }, { @@ -1383,7 +1383,7 @@ "hardness": 2.0, "resistance": 2.0, "ticksRandomly": false, - "fullCube": true, + "fullCube": false, "slipperiness": 0.6, "liquid": false, "solid": true, @@ -1391,10 +1391,10 @@ "burnable": false, "opaque": true, "replacedDuringPlacement": false, - "toolRequired": false, + "toolRequired": true, "fragileWhenPushed": false, "unpushable": false, - "mapColor": "#7f3fb2", + "mapColor": "#707070", "isTranslucent": true, "hasContainer": true } @@ -1408,7 +1408,7 @@ "hardness": 0.3, "resistance": 0.3, "ticksRandomly": false, - "fullCube": true, + "fullCube": false, "slipperiness": 0.6, "liquid": false, "solid": true, @@ -16899,4 +16899,4 @@ "hasContainer": false } } -] \ No newline at end of file +] diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json index 9ba596968..1996d1b2c 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json @@ -316,16 +316,11 @@ "47:0": "minecraft:bookshelf", "48:0": "minecraft:mossy_cobblestone", "49:0": "minecraft:obsidian", - "50:0": "minecraft:torch", "50:1": "minecraft:wall_torch[facing=east]", "50:2": "minecraft:wall_torch[facing=west]", "50:3": "minecraft:wall_torch[facing=south]", "50:4": "minecraft:wall_torch[facing=north]", - "50:9": "minecraft:wall_torch[facing=east]", - "50:10": "minecraft:wall_torch[facing=west]", - "50:11": "minecraft:wall_torch[facing=south]", - "50:12": "minecraft:wall_torch[facing=north]", - "50:13": "minecraft:torch", + "50:5": "minecraft:torch", "51:0": "minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=0]", "51:1": "minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=1]", "51:2": "minecraft:fire[east=false,south=false,north=false,west=false,up=false,age=2]", @@ -351,15 +346,10 @@ "53:5": "minecraft:oak_stairs[half=top,shape=outer_right,facing=west]", "53:6": "minecraft:oak_stairs[half=top,shape=outer_right,facing=south]", "53:7": "minecraft:oak_stairs[half=top,shape=outer_right,facing=north]", - "54:0": "minecraft:chest", "54:2": "minecraft:chest[facing=north,type=single]", "54:3": "minecraft:chest[facing=south,type=single]", "54:4": "minecraft:chest[facing=west,type=single]", "54:5": "minecraft:chest[facing=east,type=single]", - "54:10": "minecraft:chest[facing=north]", - "54:11": "minecraft:chest[facing=south]", - "54:12": "minecraft:chest[facing=west]", - "54:13": "minecraft:chest[facing=east]", "55:0": "minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=0]", "55:1": "minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=1]", "55:2": "minecraft:redstone_wire[east=none,south=none,north=none,west=none,power=2]", @@ -395,40 +385,30 @@ "60:5": "minecraft:farmland[moisture=5]", "60:6": "minecraft:farmland[moisture=6]", "60:7": "minecraft:farmland[moisture=7]", - "61:0": "minecraft:furnace", "61:2": "minecraft:furnace[facing=north,lit=false]", "61:3": "minecraft:furnace[facing=south,lit=false]", "61:4": "minecraft:furnace[facing=west,lit=false]", "61:5": "minecraft:furnace[facing=east,lit=false]", - "61:10": "minecraft:furnace[facing=north,lit=false]", - "61:11": "minecraft:furnace[facing=south,lit=false]", - "61:12": "minecraft:furnace[facing=west,lit=false]", - "61:13": "minecraft:furnace[facing=east,lit=false]", - "62:0": "minecraft:furnace[lit=true]", "62:2": "minecraft:furnace[facing=north,lit=true]", "62:3": "minecraft:furnace[facing=south,lit=true]", "62:4": "minecraft:furnace[facing=west,lit=true]", "62:5": "minecraft:furnace[facing=east,lit=true]", - "62:10": "minecraft:furnace[facing=north,lit=true]", - "62:11": "minecraft:furnace[facing=south,lit=true]", - "62:12": "minecraft:furnace[facing=west,lit=true]", - "62:13": "minecraft:furnace[facing=east,lit=true]", - "63:0": "minecraft:oak_sign[rotation=0]", - "63:1": "minecraft:oak_sign[rotation=1]", - "63:2": "minecraft:oak_sign[rotation=2]", - "63:3": "minecraft:oak_sign[rotation=3]", - "63:4": "minecraft:oak_sign[rotation=4]", - "63:5": "minecraft:oak_sign[rotation=5]", - "63:6": "minecraft:oak_sign[rotation=6]", - "63:7": "minecraft:oak_sign[rotation=7]", - "63:8": "minecraft:oak_sign[rotation=8]", - "63:9": "minecraft:oak_sign[rotation=9]", - "63:10": "minecraft:oak_sign[rotation=10]", - "63:11": "minecraft:oak_sign[rotation=11]", - "63:12": "minecraft:oak_sign[rotation=12]", - "63:13": "minecraft:oak_sign[rotation=13]", - "63:14": "minecraft:oak_sign[rotation=14]", - "63:15": "minecraft:oak_sign[rotation=15]", + "63:0": "minecraft:sign[rotation=0]", + "63:1": "minecraft:sign[rotation=1]", + "63:2": "minecraft:sign[rotation=2]", + "63:3": "minecraft:sign[rotation=3]", + "63:4": "minecraft:sign[rotation=4]", + "63:5": "minecraft:sign[rotation=5]", + "63:6": "minecraft:sign[rotation=6]", + "63:7": "minecraft:sign[rotation=7]", + "63:8": "minecraft:sign[rotation=8]", + "63:9": "minecraft:sign[rotation=9]", + "63:10": "minecraft:sign[rotation=10]", + "63:11": "minecraft:sign[rotation=11]", + "63:12": "minecraft:sign[rotation=12]", + "63:13": "minecraft:sign[rotation=13]", + "63:14": "minecraft:sign[rotation=14]", + "63:15": "minecraft:sign[rotation=15]", "64:0": "minecraft:oak_door[hinge=right,half=lower,powered=false,facing=east,open=false]", "64:1": "minecraft:oak_door[hinge=right,half=lower,powered=false,facing=south,open=false]", "64:2": "minecraft:oak_door[hinge=right,half=lower,powered=false,facing=west,open=false]", @@ -441,15 +421,10 @@ "64:9": "minecraft:oak_door[hinge=right,half=upper,powered=false,facing=east,open=false]", "64:10": "minecraft:oak_door[hinge=left,half=upper,powered=true,facing=east,open=false]", "64:11": "minecraft:oak_door[hinge=right,half=upper,powered=true,facing=east,open=false]", - "65:0": "minecraft:ladder", "65:2": "minecraft:ladder[facing=north]", "65:3": "minecraft:ladder[facing=south]", "65:4": "minecraft:ladder[facing=west]", "65:5": "minecraft:ladder[facing=east]", - "65:10": "minecraft:ladder[facing=north]", - "65:11": "minecraft:ladder[facing=south]", - "65:12": "minecraft:ladder[facing=west]", - "65:13": "minecraft:ladder[facing=east]", "66:0": "minecraft:rail[shape=north_south]", "66:1": "minecraft:rail[shape=east_west]", "66:2": "minecraft:rail[shape=ascending_east]", @@ -468,15 +443,10 @@ "67:5": "minecraft:cobblestone_stairs[half=top,shape=straight,facing=west]", "67:6": "minecraft:cobblestone_stairs[half=top,shape=straight,facing=south]", "67:7": "minecraft:cobblestone_stairs[half=top,shape=straight,facing=north]", - "68:0": "minecraft:oak_wall_sign", - "68:2": "minecraft:oak_wall_sign[facing=north]", - "68:3": "minecraft:oak_wall_sign[facing=south]", - "68:4": "minecraft:oak_wall_sign[facing=west]", - "68:5": "minecraft:oak_wall_sign[facing=east]", - "68:10": "minecraft:oak_wall_sign[facing=north]", - "68:11": "minecraft:oak_wall_sign[facing=south]", - "68:12": "minecraft:oak_wall_sign[facing=west]", - "68:13": "minecraft:oak_wall_sign[facing=east]", + "68:2": "minecraft:wall_sign[facing=north]", + "68:3": "minecraft:wall_sign[facing=south]", + "68:4": "minecraft:wall_sign[facing=west]", + "68:5": "minecraft:wall_sign[facing=east]", "69:0": "minecraft:lever[powered=false,facing=north,face=ceiling]", "69:1": "minecraft:lever[powered=false,facing=east,face=wall]", "69:2": "minecraft:lever[powered=false,facing=west,face=wall]", @@ -511,28 +481,16 @@ "72:1": "minecraft:oak_pressure_plate[powered=true]", "73:0": "minecraft:redstone_ore[lit=false]", "74:0": "minecraft:redstone_ore[lit=true]", - "75:0": "minecraft:redstone_torch[lit=false]", "75:1": "minecraft:redstone_wall_torch[facing=east,lit=false]", "75:2": "minecraft:redstone_wall_torch[facing=west,lit=false]", "75:3": "minecraft:redstone_wall_torch[facing=south,lit=false]", "75:4": "minecraft:redstone_wall_torch[facing=north,lit=false]", "75:5": "minecraft:redstone_torch[lit=false]", - "75:9": "minecraft:redstone_wall_torch[facing=east,lit=false]", - "75:10": "minecraft:redstone_wall_torch[facing=west,lit=false]", - "75:11": "minecraft:redstone_wall_torch[facing=south,lit=false]", - "75:12": "minecraft:redstone_wall_torch[facing=north,lit=false]", - "75:13": "minecraft:redstone_wall_torch[lit=false]", - "76:0": "minecraft:redstone_torch[lit=true]", "76:1": "minecraft:redstone_wall_torch[facing=east,lit=true]", "76:2": "minecraft:redstone_wall_torch[facing=west,lit=true]", "76:3": "minecraft:redstone_wall_torch[facing=south,lit=true]", "76:4": "minecraft:redstone_wall_torch[facing=north,lit=true]", - "76:5": "minecraft:redstone_wall_torch[lit=true]", - "76:9": "minecraft:redstone_wall_torch[facing=east,lit=true]", - "76:10": "minecraft:redstone_wall_torch[facing=west,lit=true]", - "76:11": "minecraft:redstone_wall_torch[facing=south,lit=true]", - "76:12": "minecraft:redstone_wall_torch[facing=north,lit=true]", - "76:13": "minecraft:redstone_wall_torch[lit=true]", + "76:5": "minecraft:redstone_torch[lit=true]", "77:0": "minecraft:stone_button[powered=false,facing=east,face=ceiling]", "77:1": "minecraft:stone_button[powered=false,facing=east,face=wall]", "77:2": "minecraft:stone_button[powered=false,facing=west,face=wall]", @@ -598,15 +556,8 @@ "87:0": "minecraft:netherrack", "88:0": "minecraft:soul_sand", "89:0": "minecraft:glowstone", - "90:0": "minecraft:nether_portal", "90:1": "minecraft:nether_portal[axis=x]", "90:2": "minecraft:nether_portal[axis=z]", - "90:5": "minecraft:nether_portal[axis=x]", - "90:6": "minecraft:nether_portal[axis=z]", - "90:9": "minecraft:nether_portal[axis=x]", - "90:10": "minecraft:nether_portal[axis=z]", - "90:13": "minecraft:nether_portal[axis=x]", - "90:14": "minecraft:nether_portal[axis=z]", "91:0": "minecraft:jack_o_lantern[facing=south]", "91:1": "minecraft:jack_o_lantern[facing=west]", "91:2": "minecraft:jack_o_lantern[facing=north]", @@ -866,15 +817,10 @@ "128:6": "minecraft:sandstone_stairs[half=top,shape=straight,facing=south]", "128:7": "minecraft:sandstone_stairs[half=top,shape=straight,facing=north]", "129:0": "minecraft:emerald_ore", - "130:0": "minecraft:ender_chest", "130:2": "minecraft:ender_chest[facing=north]", "130:3": "minecraft:ender_chest[facing=south]", "130:4": "minecraft:ender_chest[facing=west]", "130:5": "minecraft:ender_chest[facing=east]", - "130:10": "minecraft:ender_chest[facing=north]", - "130:11": "minecraft:ender_chest[facing=south]", - "130:12": "minecraft:ender_chest[facing=west]", - "130:13": "minecraft:ender_chest[facing=east]", "131:0": "minecraft:tripwire_hook[powered=false,attached=false,facing=south]", "131:1": "minecraft:tripwire_hook[powered=false,attached=false,facing=west]", "131:2": "minecraft:tripwire_hook[powered=false,attached=false,facing=north]", @@ -1007,15 +953,10 @@ "145:9": "minecraft:damaged_anvil[facing=west]", "145:10": "minecraft:damaged_anvil[facing=north]", "145:11": "minecraft:damaged_anvil[facing=east]", - "146:0": "minecraft:trapped_chest", "146:2": "minecraft:trapped_chest[facing=north,type=single]", "146:3": "minecraft:trapped_chest[facing=south,type=single]", "146:4": "minecraft:trapped_chest[facing=west,type=single]", "146:5": "minecraft:trapped_chest[facing=east,type=single]", - "146:10": "minecraft:trapped_chest[facing=north,type=single]", - "146:11": "minecraft:trapped_chest[facing=south,type=single]", - "146:12": "minecraft:trapped_chest[facing=west,type=single]", - "146:13": "minecraft:trapped_chest[facing=east,type=single]", "147:0": "minecraft:light_weighted_pressure_plate[power=0]", "147:1": "minecraft:light_weighted_pressure_plate[power=1]", "147:2": "minecraft:light_weighted_pressure_plate[power=2]", @@ -1283,15 +1224,10 @@ "176:13": "minecraft:white_banner[rotation=13]", "176:14": "minecraft:white_banner[rotation=14]", "176:15": "minecraft:white_banner[rotation=15]", - "177:0": "minecraft:white_wall_banner", "177:2": "minecraft:white_wall_banner[facing=north]", "177:3": "minecraft:white_wall_banner[facing=south]", "177:4": "minecraft:white_wall_banner[facing=west]", "177:5": "minecraft:white_wall_banner[facing=east]", - "177:10": "minecraft:white_wall_banner[facing=north]", - "177:11": "minecraft:white_wall_banner[facing=south]", - "177:12": "minecraft:white_wall_banner[facing=west]", - "177:13": "minecraft:white_wall_banner[facing=east]", "178:0": "minecraft:daylight_detector[inverted=true,power=0]", "178:1": "minecraft:daylight_detector[inverted=true,power=1]", "178:2": "minecraft:daylight_detector[inverted=true,power=2]", @@ -2196,7 +2132,7 @@ "321:0": "minecraft:painting", "322:0": "minecraft:golden_apple", "322:1": "minecraft:enchanted_golden_apple", - "323:0": "minecraft:oak_sign", + "323:0": "minecraft:sign", "324:0": "minecraft:oak_door", "325:0": "minecraft:bucket", "326:0": "minecraft:water_bucket", diff --git a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java index 555c83889..1a010265b 100644 --- a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java +++ b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java @@ -19,19 +19,20 @@ package com.sk89q.minecraft.util.commands; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.HashSet; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class CommandContextTest { @@ -39,7 +40,7 @@ public class CommandContextTest { private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something"; CommandContext firstCommand; - @Before + @BeforeEach public void setUpTest() { try { firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w'))); @@ -49,10 +50,12 @@ public class CommandContextTest { } } - @Test(expected = CommandException.class) - public void testInvalidFlags() throws CommandException { + @Test + public void testInvalidFlags() { final String failingCommand = "herpderp -opw testers"; + assertThrows(CommandException.class, () -> { new CommandContext(failingCommand, new HashSet<>(Arrays.asList('o', 'w'))); + }); } @Test diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java index 7a1fa379a..f18ec27f4 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java @@ -19,34 +19,29 @@ package com.sk89q.worldedit.extent.transform; -import static org.junit.Assert.assertEquals; - import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - import java.util.HashSet; import java.util.Set; +import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; -@Ignore("A platform is currently required to get properties, preventing this test.") +@Disabled("A platform is currently required to get properties, preventing this test.") public class BlockTransformExtentTest { private static final Transform ROTATE_90 = new AffineTransform().rotateY(-90); private static final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90); private final Set ignored = new HashSet<>(); - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { // BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test")); } @Test - public void testTransform() throws Exception { + public void testTransform() { // for (BlockType type : BlockType.REGISTRY.values()) { // if (ignored.contains(type)) { // continue; @@ -66,4 +61,4 @@ public class BlockTransformExtentTest { // assertEquals(base, rotated); // } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/test/resources/junit-platform.properties b/worldedit-core/src/test/resources/junit-platform.properties new file mode 100644 index 000000000..ee7c4fad3 --- /dev/null +++ b/worldedit-core/src/test/resources/junit-platform.properties @@ -0,0 +1,5 @@ +junit.jupiter.execution.parallel.enabled=true +junit.jupiter.execution.parallel.mode.default=concurrent +junit.jupiter.execution.parallel.mode.classes.default=same_thread +junit.jupiter.execution.parallel.config.strategy=dynamic +junit.jupiter.execution.parallel.config.dynamic.factor=4 diff --git a/worldedit-forge/src/main/resources/META-INF/mods.toml b/worldedit-forge/src/main/resources/META-INF/mods.toml index 07b5ff1a0..1f6e628a7 100644 --- a/worldedit-forge/src/main/resources/META-INF/mods.toml +++ b/worldedit-forge/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ loaderVersion="[24,)" # A URL to refer people to when problems occur with this mod issueTrackerURL="https://discord.gg/enginehub" # A URL for the "homepage" for this mod, displayed in the mod UI -displayURL="http://wiki.sk89q.com/wiki/WorldEdit/" +displayURL="https://worldedit.enginehub.org/" # A file name (in the root of the mod JAR) containing a logo for display logoFile="worldedit-icon.png" # A text field displayed in the mod UI diff --git a/worldedit-libs/build.gradle b/worldedit-libs/build.gradle deleted file mode 100644 index ac6c32f98..000000000 --- a/worldedit-libs/build.gradle +++ /dev/null @@ -1,152 +0,0 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -/* - -This project shades API libraries, i.e. those libraries -whose classes are publicly referenced from `-core` classes. - -This project does not shade implementation libraries, i.e. -those libraries whose classes are internally depended on. - -This is because the main reason for shading those libraries is for -their internal usage in each platform, not because we need them available to -dependents of `-core` to compile and work with WorldEdit's API. - - */ -configure(subprojects + project("core:ap")) { - apply plugin: 'maven' - apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.jfrog.artifactory' - configurations { - create("shade") - getByName("archives").extendsFrom(getByName("default")) - } - - group = rootProject.group + ".worldedit-libs" - - tasks.register("jar", ShadowJar) { - configurations = [project.configurations.shade] - classifier = "" - - dependencies { - exclude(dependency("com.google.guava:guava")) - exclude(dependency("com.google.code.gson:gson")) - exclude(dependency("org.checkerframework:checker-qual")) - } - - relocate('net.kyori.text', 'com.sk89q.worldedit.util.formatting.text') - } - def altConfigFiles = { String artifactType -> - def deps = configurations.shade.incoming.dependencies - .collect { it.copy() } - .collect { dependency -> - dependency.artifact { artifact -> - artifact.name = dependency.name - artifact.type = artifactType - artifact.extension = 'jar' - artifact.classifier = artifactType - } - dependency - } - - return files(configurations.detachedConfiguration(deps as Dependency[]) - .resolvedConfiguration.lenientConfiguration.getArtifacts() - .findAll { it.classifier == artifactType } - .collect { zipTree(it.file) }) - } - tasks.register("sourcesJar", Jar) { - from { - altConfigFiles('sources') - } - def filePattern = ~'(.*)net/kyori/text((?:/|$).*)' - def textPattern = ~/net\.kyori\.text/ - eachFile { - it.filter { String line -> - line.replaceFirst(textPattern, 'com.sk89q.worldedit.util.formatting.text') - } - it.path = it.path.replaceFirst(filePattern, '$1com/sk89q/worldedit/util/formatting/text$2') - } - classifier = "sources" - } - - artifacts { - add("default", jar) - add("archives", sourcesJar) - } - - tasks.register("install", Upload) { - configuration = configurations.archives - repositories.mavenInstaller { - pom.version = project.version - pom.artifactId = project.name - } - } - - artifactoryPublish { - publishConfigs('default') - } - - build.dependsOn(jar, sourcesJar) -} - -def textExtrasVersion = "3.0.2" -project("core") { - def textVersion = "3.0.2" - def pistonVersion = '0.4.4-SNAPSHOT' - - dependencies { - shade "net.kyori:text-api:$textVersion" - shade "net.kyori:text-serializer-gson:$textVersion" - shade "net.kyori:text-serializer-legacy:$textVersion" - shade "net.kyori:text-serializer-plain:$textVersion" - shade "net.kyori:text-feature-pagination:$textVersion" - shade('com.sk89q:jchronic:0.2.4a') { - exclude(group: "junit", module: "junit") - } - shade 'com.thoughtworks.paranamer:paranamer:2.6' - shade 'com.sk89q.lib:jlibnoise:1.0.0' - shade "FAWE-Piston:core/build/libs/core-$pistonVersion:lastSuccessfulBuild@jar" - shade "FAWE-Piston:core-ap/runtime/build/libs/runtime-$pistonVersion:lastSuccessfulBuild@jar" - shade "FAWE-Piston:default-impl/build/libs/default-impl-$pistonVersion:lastSuccessfulBuild@jar" - } - - project("ap") { - dependencies { -// def avVersion = "1.6.5" -// shade "com.google.auto.value:auto-value-annotations:$avVersion" - shade "FAWE-Piston:core/build/libs/core-$pistonVersion:lastSuccessfulBuild@jar" - shade "FAWE-Piston:core-ap/annotations/build/libs/annotations-$pistonVersion:lastSuccessfulBuild@jar" - shade "FAWE-Piston:core-ap/processor/build/libs/processor-$pistonVersion:lastSuccessfulBuild@jar" - - shade "org.enginehub.piston.core-ap:annotations:0.4.3" - shade "org.enginehub.piston.core-ap:processor:0.4.3" - } - } -} -project("bukkit") { - repositories { - maven { - name = "SpigotMC" - url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" - } - } - dependencies { - shade "net.kyori:text-adapter-bukkit:$textExtrasVersion" - } -} -/* -project("sponge") { - repositories { - maven { - name = "Sponge" - url = "https://repo.spongepowered.org/maven" - } - } - dependencies { - shade "net.kyori:text-adapter-spongeapi:$textExtrasVersion" - } -} -*/ - -tasks.register("build") { - dependsOn(subprojects.collect { it.tasks.named("build") }) -} diff --git a/worldedit-libs/build.gradle.kts b/worldedit-libs/build.gradle.kts new file mode 100644 index 000000000..152530cb0 --- /dev/null +++ b/worldedit-libs/build.gradle.kts @@ -0,0 +1,3 @@ +tasks.register("build") { + dependsOn(subprojects.map { it.tasks.named("build") }) +} diff --git a/worldedit-libs/bukkit/build.gradle.kts b/worldedit-libs/bukkit/build.gradle.kts new file mode 100644 index 000000000..247fd9219 --- /dev/null +++ b/worldedit-libs/bukkit/build.gradle.kts @@ -0,0 +1,11 @@ +applyLibrariesConfiguration() + +repositories { + maven { + name = "SpigotMC" + url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + } +} +dependencies { + "shade"("net.kyori:text-adapter-bukkit:${Versions.TEXT_EXTRAS}") +} diff --git a/worldedit-libs/core/ap/build.gradle.kts b/worldedit-libs/core/ap/build.gradle.kts new file mode 100644 index 000000000..10c52bd7b --- /dev/null +++ b/worldedit-libs/core/ap/build.gradle.kts @@ -0,0 +1,9 @@ +applyLibrariesConfiguration() + +dependencies { + "shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar") + "shade"("FAWE-Piston:core-ap/annotations/build/libs/annotations-${Versions.PISTON}:lastSuccessfulBuild@jar") + "shade"("FAWE-Piston:core-ap/processor/build/libs/processor-${Versions.PISTON}:lastSuccessfulBuild@jar") + "shade"("org.enginehub.piston.core-ap:annotations:0.4.3") + "shade"("org.enginehub.piston.core-ap:processor:0.4.3") +} diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts new file mode 100644 index 000000000..01f0d74e1 --- /dev/null +++ b/worldedit-libs/core/build.gradle.kts @@ -0,0 +1,19 @@ +applyLibrariesConfiguration() + +dependencies { + "shade"("net.kyori:text-api:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-gson:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-legacy:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-plain:${Versions.TEXT}") + "shade"("com.sk89q:jchronic:0.2.4a") { + exclude(group = "junit", module = "junit") + } + "shade"("com.github.luben:zstd-jni:1.4.3-1") + "shade"("com.thoughtworks.paranamer:paranamer:2.6") + "shade"("com.sk89q.lib:jlibnoise:1.0.0") + + "shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar") + "shade"("FAWE-Piston:core-ap/runtime/build/libs/runtime-${Versions.PISTON}:lastSuccessfulBuild@jar") + "shade"("FAWE-Piston:default-impl/build/libs/default-impl-${Versions.PISTON}:lastSuccessfulBuild@jar") + +}