diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61ba80048..28cfbca2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,13 @@ -name: Build +name: SonarQube on: push: branches: - develop - - master pull_request: types: [opened, synchronize, reopened] jobs: build: - name: Build + name: Build and analyze runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -17,31 +16,25 @@ jobs: - name: Set up JDK 21 uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '21' - - name: Cache SonarCloud packages + java-version: 21 + distribution: 'zulu' # Alternative distribution options are available + - name: Cache SonarQube packages uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages + - name: Cache Gradle packages uses: actions/cache@v4 with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_BentoBox - - name: Debug - List target directory - run: ls -la /home/runner/work/BentoBox/BentoBox/target - - run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install - - run: mkdir staging && cp target/*.jar staging - - name: Save artifacts - uses: actions/upload-artifact@v4 - with: - name: Package - path: staging + run: ./gradlew build sonar --info diff --git a/.github/workflows/modrinth-publish.yml b/.github/workflows/modrinth-publish.yml deleted file mode 100644 index e0d2a0a91..000000000 --- a/.github/workflows/modrinth-publish.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Publish - -on: - release: - types: [published] - -jobs: - publish: - name: Publish - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: 21 - distribution: adopt - cache: maven - - # This step will take the version tag from the release and replace it in `pom.xml` before building. - #- name: Set version from release tag - # run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false - - - name: Build and package with Maven - run: mvn -B clean package -DskipTests -Pmaster --file pom.xml - - name: Debug - List target directory - run: ls -la /home/runner/work/BentoBox/BentoBox/target - - name: Upload to Modrinth - uses: cloudnode-pro/modrinth-publish@v2 - with: - token: ${{ secrets.MODRINTH_TOKEN }} - project: aBVLHiAW - name: ${{ github.event.release.name }} - version: ${{ github.event.release.tag_name }} - changelog: ${{ github.event.release.body }} - loaders: |- - paper - spigot - game-versions: |- - 1.21.4 - 1.21.5 - files: /home/runner/work/BentoBox/BentoBox/target/BentoBox-${{ github.event.release.tag_name }}.jar diff --git a/.gitignore b/.gitignore index b31942ce5..f55317af4 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ $RECYCLE.BIN/ *.log *.ctxt .mtj.tmp/ -*.jar *.war *.nar *.ear diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..94284b4d6 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,463 @@ +/** + * BentoBox Gradle Build Configuration + * + * This build script configures the compilation, testing, packaging, and publishing + * of the BentoBox Minecraft plugin. It handles: + * - Java 21 compilation with proper module access + * - Multi-repository dependency resolution + * - JAR shading and minimization + * - Test execution with JUnit 5 + * - Code coverage reporting with JaCoCo + * - Maven publication to the BentoBox repository + */ + +// ============================================================================ +// PLUGINS: Core build functionality +// ============================================================================ +// Apply necessary plugins for Java development, publishing, testing, and shading +plugins { + // Standard Java development plugin - provides compile, test, jar tasks + java + + // Maven Publishing - allows publishing artifacts to Maven repositories + `maven-publish` + + // JaCoCo (Java Code Coverage) - generates code coverage reports for CI/CD + id("jacoco") + + // Shadow Plugin - shades (embeds) dependencies into the final JAR and minimizes unused code + id("com.gradleup.shadow") version "9.3.0" + + // Paperweight UserDev - simplifies development against PaperMC with proper mappings and reobfuscation + id("io.papermc.paperweight.userdev") version "2.0.0-beta.19" + + // Sonarcube + id("org.sonarqube") version "7.2.1.6560" +} + +// Add paperweight reobf configuration so the userdev plugin reobfuscates artifacts +// using the Mojang production mappings as required by paperweight-userdev. +paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION + +// ============================================================================ +// PROJECT COORDINATES & VERSIONING +// ============================================================================ +// These properties define the artifact's identity in the Maven repository +group = "world.bentobox" // From + +// Base properties from +val buildVersion = "3.10.2" +val buildNumberDefault = "-LOCAL" // Local build identifier +val snapshotSuffix = "-SNAPSHOT" // Indicates development/snapshot version + +// CI/CD Logic (Translates Maven ) +// Default version format: 3.10.2-LOCAL-SNAPSHOT +var finalBuildNumber = buildNumberDefault +var finalRevision = "$buildVersion$finalBuildNumber$snapshotSuffix" + +// 'ci' profile logic: Activated by env.BUILD_NUMBER from CI/CD pipeline +// Overrides build number with actual CI build number +val envBuildNumber = System.getenv("BUILD_NUMBER") +if (!envBuildNumber.isNullOrBlank()) { + finalBuildNumber = "-b$envBuildNumber" + finalRevision = "$buildVersion$finalBuildNumber$snapshotSuffix" +} + +// 'master' profile logic: Activated when building from origin/master branch +// Removes -LOCAL and -SNAPSHOT suffixes for release builds +val envGitBranch = System.getenv("GIT_BRANCH") +if (envGitBranch == "origin/master") { + finalBuildNumber = "" // No build number for releases + finalRevision = buildVersion // Clean version number +} + +version = finalRevision + +// ============================================================================ +// DEPENDENCY VERSIONS +// ============================================================================ +// Centralized version management for all external dependencies +val javaVersion = "21" +val junitVersion = "5.10.2" +val mockitoVersion = "5.11.0" +val mockBukkitVersion = "v1.21-SNAPSHOT" +val mongodbVersion = "3.12.12" +val mariadbVersion = "3.0.5" +val mysqlVersion = "8.0.27" +val postgresqlVersion = "42.2.18" +val hikaricpVersion = "5.0.1" +val spigotVersion = "1.21.10-R0.1-SNAPSHOT" +val paperVersion = "1.21.10-R0.1-SNAPSHOT" +val bstatsVersion = "3.0.0" +val vaultVersion = "1.7.1" +val levelVersion = "2.21.3" +val placeholderapiVersion = "2.11.7" +val myworldsVersion = "1.19.3-v1" + +// Store versions in extra properties for resource filtering (used in plugin.yml, config.yml) +extra["java.version"] = javaVersion +extra["junit.version"] = junitVersion +extra["mockito.version"] = mockitoVersion +extra["mock-bukkit.version"] = mockBukkitVersion +extra["mongodb.version"] = mongodbVersion +extra["mariadb.version"] = mariadbVersion +extra["mysql.version"] = mysqlVersion +extra["postgresql.version"] = postgresqlVersion +extra["hikaricp.version"] = hikaricpVersion +extra["spigot.version"] = spigotVersion +extra["paper.version"] = paperVersion +extra["bstats.version"] = bstatsVersion +extra["vault.version"] = vaultVersion +extra["level.version"] = levelVersion +extra["placeholderapi.version"] = placeholderapiVersion +extra["myworlds.version"] = myworldsVersion +extra["build.version"] = buildVersion +extra["build.number"] = finalBuildNumber +extra["revision"] = finalRevision + + +// ============================================================================ +// JAVA CONFIGURATION +// ============================================================================ +// Configures Java compiler and toolchain settings +java { + // Use Java 21 toolchain for compilation (enforced regardless of JVM running Gradle) + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } +} + +tasks.withType { + // Ensure UTF-8 encoding for all source files + options.encoding = "UTF-8" +} + + +// ============================================================================ +// REPOSITORIES +// ============================================================================ +// Defines where dependencies are downloaded from (in order of precedence) +repositories { + // Gradle Plugin Portal - for resolving Gradle plugins + gradlePluginPortal() + // PaperMC Maven Repository - for Paper API and related libraries + maven("https://repo.papermc.io/repository/maven-public/") { name = "PaperMC" } // Paper API + // Standard Maven Central Repository - most common Java libraries + mavenCentral() + + // Custom repositories for Minecraft and plugin-specific libraries + maven("https://jitpack.io") { name = "JitPack" } // GitHub repository packages + maven("https://repo.codemc.org/repository/maven-public") { name = "CodeMC-Public" } + maven("https://libraries.minecraft.net/") { name = "MinecraftLibs" } // Official Minecraft libraries + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") { name = "Spigot-Snapshots" } + maven("https://repo.codemc.io/repository/nms/") { name = "NMS-Repo" } // NMS (internal Minecraft code) + maven("https://ci.mg-dev.eu/plugin/repository/everything") { name = "MG-Dev-CI" } + maven("https://repo.onarandombox.com/multiverse-releases") { name = "Multiverse-Releases" } + maven("https://repo.onarandombox.com/multiverse-snapshots") { name = "Multiverse-Snapshots" } + maven("https://mvn.lumine.io/repository/maven-public/") { name = "Lumine-Releases" } // Mythic mobs + maven("https://repo.clojars.org/") { name = "Clojars" } + maven("https://repo.fancyplugins.de/releases") { name = "FancyPlugins-Releases" } + maven("https://repo.pyr.lol/snapshots") { name = "Pyr-Snapshots" } + maven("https://maven.devs.beer/") { name = "MatteoDev" } + maven("https://repo.oraxen.com/releases") { name = "Oraxen" } // Custom items plugin + maven("https://repo.codemc.org/repository/bentoboxworld/") { name = "BentoBoxWorld-Repo" } + maven("https://repo.extendedclip.com/releases/") { name = "Placeholder-API-Releases" } +} + + +// ============================================================================ +// DEPENDENCIES +// ============================================================================ +// Defines all external libraries needed for compilation and testing + +dependencies { + // --- Test Dependencies: Only used during testing, not in production --- + testImplementation(platform("org.junit:junit-bom:$junitVersion")) + testImplementation("org.junit.jupiter:junit-jupiter-api") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junitVersion") + testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion") // Mocking framework + testImplementation("org.mockito:mockito-core:$mockitoVersion") + testImplementation("com.github.MockBukkit:MockBukkit:$mockBukkitVersion") // Bukkit mock server + testImplementation("org.awaitility:awaitility:4.2.2") // Async testing helper + testImplementation("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") // Paper API for tests + testImplementation("com.github.MilkBowl:VaultAPI:$vaultVersion") + testImplementation("me.clip:placeholderapi:$placeholderapiVersion") + + // --- Provided/Compile-Only Dependencies: Available at compile time but provided by server --- + // These are NOT shaded into the final JAR (the server provides them at runtime) + //compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") // Bukkit/Spigot/Paper API + paperweight.paperDevBundle("1.21.10-R0.1-SNAPSHOT") + + // Spigot NMS - Used for internal Minecraft code (chunk deletion and pasting) + compileOnly("org.spigotmc:spigot:$spigotVersion") { + exclude(group = "org.spigotmc", module = "spigot-api") // Already provided by Paper + } + + // Optional plugins that may be installed on the server + compileOnly("org.mongodb:mongodb-driver:$mongodbVersion") + compileOnly("com.zaxxer:HikariCP:$hikaricpVersion") // Database connection pooling + compileOnly("com.github.MilkBowl:VaultAPI:$vaultVersion") // Economy/permission API + compileOnly("me.clip:placeholderapi:$placeholderapiVersion") // Placeholder API + compileOnly("com.bergerkiller.bukkit:MyWorlds:$myworldsVersion") { + exclude(group = "org.spigotmc", module = "spigot-api") + } + compileOnly("io.lumine:Mythic-Dist:5.9.5") // Mythic Mobs + compileOnly("org.mvplugins.multiverse.core:multiverse-core:5.0.0-SNAPSHOT") + compileOnly("com.onarandombox.multiversecore:multiverse-core:4.3.16") { + exclude(group = "org.spigotmc", module = "spigot-api") + } + compileOnly("com.github.apachezy:LangUtils:3.2.2") + compileOnly("com.github.Slimefun:Slimefun4:RC-37") // Slimefun custom items + compileOnly("dev.lone:api-itemsadder:4.0.2-beta-release-11") // ItemsAdder custom items + compileOnly("de.oliver:FancyNpcs:2.4.4") // NPC plugin + compileOnly("lol.pyr:znpcsplus-api:2.0.0-SNAPSHOT") // Alternative NPC plugin + compileOnly("de.oliver:FancyHolograms:2.4.1") // Hologram plugin + compileOnly("world.bentobox:level:2.21.3-SNAPSHOT") // BentoBox Level addon + + // Apache Commons Lang - utility library + compileOnly("commons-lang:commons-lang:2.6") + testImplementation("commons-lang:commons-lang:2.6") + + // --- Implementation Dependencies: Shaded into final JAR --- + // These are embedded in the final JAR since they're not commonly available + implementation("org.bstats:bstats-bukkit:$bstatsVersion") // Plugin metrics + implementation("javax.xml.bind:jaxb-api:2.3.0") // XML serialization + implementation("com.github.Marcono1234:gson-record-type-adapter-factory:0.3.0") // JSON serialization + implementation("org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.600") // Nullability annotations + implementation("com.github.puregero:multilib:1.1.13") // Multi-library support + + // Oraxen with custom exclusions (embed only what we need) + compileOnly("io.th0rgal:oraxen:1.193.1") { + exclude(group = "me.gabytm.util", module = "actions-spigot") + exclude(group = "org.jetbrains", module = "annotations") + exclude(group = "com.ticxo", module = "PlayerAnimator") + exclude(group = "com.github.stefvanschie.inventoryframework", module = "IF") + exclude(group = "io.th0rgal", module = "protectionlib") + exclude(group = "dev.triumphteam", module = "triumph-gui") + exclude(group = "org.bstats", module = "bstats-bukkit") + exclude(group = "com.jeff-media", module = "custom-block-data") + exclude(group = "com.jeff-media", module = "persistent-data-serializer") + exclude(group = "com.jeff_media", module = "MorePersistentDataTypes") + exclude(group = "gs.mclo", module = "java") + } +} + +paperweight { + addServerDependencyTo = configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME).map { setOf(it) } + javaLauncher = javaToolchains.launcherFor { + // Example scenario: + // Paper 1.17.1 was originally built with JDK 16 and the bundle + // has not been updated to work with 21+ (but we want to compile with a 25 toolchain) + // Use the project's configured Java version for paperweight tools (needs Java 21+) + languageVersion = JavaLanguageVersion.of(javaVersion) + } +} + +sonar { + properties { + property("sonar.projectKey", "BentoBoxWorld_BentoBox") + property("sonar.organization", "bentobox-world") + } +} + + +// ============================================================================ +// RESOURCE PROCESSING +// ============================================================================ +// Filters and copies resources (plugin.yml, config files, locales) to build output + +tasks.processResources { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + + from(sourceSets.main.get().resources.srcDirs) + + // Replace variables in plugin.yml and config.yml with actual version strings + // This allows version info to be read at runtime by the plugin + filesMatching(listOf("plugin.yml", "config.yml")) { + filter { line -> + line.replace("\${mysql.version}", mysqlVersion) + .replace("\${mariadb.version}", mariadbVersion) + .replace("\${postgresql.version}", postgresqlVersion) + .replace("\${mongodb.version}", mongodbVersion) + .replace("\${hikaricp.version}", hikaricpVersion) + .replace("\${build.number}", finalBuildNumber) + .replace("\${project.version}", project.version.toString()) + .replace("\${project.description}", project.description ?: "") + .replace("\${revision}", project.version.toString()) + } + } + + finalizedBy("copyLocales") +} + +// Copy locale files without filtering (prevents corruption of translation files) +tasks.register("copyLocales") { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from("src/main/resources/locales") + into("${tasks.processResources.get().destinationDir}/locales") +} + +// Ensure test compilation waits for locale files to be copied +tasks.compileTestJava { + dependsOn("copyLocales") +} + +// Set the final JAR filename to match project name and version +tasks.jar { + archiveFileName.set("${project.name}-${project.version}.jar") + dependsOn("copyLocales") // Explicit dependency for Gradle 9.0+ strict validation +} + + +// ============================================================================ +// JAR SHADING & MINIMIZATION +// ============================================================================ +// Shadow Plugin: Embeds dependencies into JAR and removes unused code +// This creates a "fat JAR" with all required dependencies + +tasks.named("shadowJar") { + // Enable minimization: removes unused classes/methods from shaded dependencies + // Reduces JAR size significantly + minimize() + + // Exclude these artifacts from being shaded (already provided by server or incompatible) + exclude( + "org.apache.maven:*:*", // Maven tools not needed at runtime + "com.google.code.gson:*:*", // Often provided by server + "org.mongodb:*:*", // Optional dependency + "org.eclipse.jdt:*:*" // Optional dependency + ) + + // Relocate (rename) packages to avoid conflicts with other plugins + // This prevents "duplicate class" errors when multiple plugins have same dependency + relocate("org.bstats", "world.bentobox.bentobox.util.metrics") + relocate("io.papermc.lib", "world.bentobox.bentobox.paperlib") + relocate("com.github.puregero.multilib", "world.bentobox.bentobox.multilib") + + // Remove the "-all" suffix from the shaded JAR filename + archiveClassifier.set("") +} + +// Make the shaded JAR the primary artifact for the 'build' task +tasks.build { + dependsOn(tasks.shadowJar) +} + +// ============================================================================ +// TEST EXECUTION +// ============================================================================ +// Configures JUnit 5 testing with special Java module access for Java 21 + +tasks.test { + // Use JUnit Platform (required for JUnit 5) + useJUnitPlatform() + + // Enable Java 21 preview features and dynamic agent loading + jvmArgs("--enable-preview", "-XX:+EnableDynamicAgentLoading") + + // Add --add-opens: Required for Java 21+ to allow reflection access to restricted modules + // Necessary for mocking frameworks and other testing utilities + val openModules = listOf( + "java.base/java.lang", "java.base/java.math", "java.base/java.io", "java.base/java.util", + "java.base/java.util.stream", "java.base/java.text", "java.base/java.util.regex", + "java.base/java.nio.channels.spi", "java.base/sun.nio.ch", "java.base/java.net", + "java.base/java.util.concurrent", "java.base/sun.nio.fs", "java.base/sun.nio.cs", + "java.base/java.nio.file", "java.base/java.nio.charset", "java.base/java.lang.reflect", + "java.logging/java.util.logging", "java.base/java.lang.ref", "java.base/java.util.jar", + "java.base/java.util.zip", "java.base/java.security", "java.base/jdk.internal.misc" + ) + + for (module in openModules) { + jvmArgs("--add-opens", "$module=ALL-UNNAMED") + } +} + +// ============================================================================ +// CODE COVERAGE (JACOCO) +// ============================================================================ +// Generates code coverage reports to measure test coverage + +tasks.jacocoTestReport { + reports { + xml.required.set(true) // XML format for CI/CD tools like SonarCloud + html.required.set(true) // HTML format for human viewing + } + + // Exclude certain classes from coverage analysis + classDirectories.setFrom( + sourceSets.main.get().output.asFileTree.matching { + exclude("**/*Names*", "org/bukkit/Material*") // Generated/external classes + } + ) +} + +// ============================================================================ +// JAVADOC & SOURCE ARTIFACTS +// ============================================================================ +// Creates additional JARs for publication: sources and javadoc + +tasks.javadoc { + source = sourceSets.main.get().allJava + options { + (this as StandardJavadocDocletOptions).apply { + // Suppress warnings and keep output quiet + addStringOption("Xdoclint:none", "-quiet") + source = javaVersion + } + } +} + +// Creates BentoBox--sources.jar containing all source code +tasks.register("sourcesJar") { + archiveClassifier.set("sources") + from(sourceSets.main.get().allSource) +} + +// Creates BentoBox--javadoc.jar containing generated documentation +tasks.register("javadocJar") { + archiveClassifier.set("javadoc") + from(tasks.javadoc) +} + +// ============================================================================ +// PUBLICATION TO MAVEN REPOSITORY +// ============================================================================ +// Publishes build artifacts to the BentoBox Maven repository + +publishing { + publications { + create("mavenJava") { + // Use the shaded (shadow) JAR as the main artifact, not the plain JAR + artifact(tasks.shadowJar.get()) { + builtBy(tasks.shadowJar) + } + + // Also attach source code and javadoc for developers + artifact(tasks.getByName("sourcesJar")) + artifact(tasks.getByName("javadocJar")) + + // Set Maven coordinates + groupId = project.group as String + artifactId = rootProject.name + version = project.version as String + } + } + + // Configure publication target repository + repositories { + maven { + name = "bentoboxworld" + url = uri("https://repo.codemc.org/repository/bentoboxworld/") // Where artifacts are uploaded + } + } +} + +// ============================================================================ +// ARCHIVE NAMING +// ============================================================================ +// Sets the base name for all generated artifacts + +base { + archivesName.set("BentoBox") // Final JARs will be: BentoBox-.jar, etc. +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..d2b132ebd --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,66 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +com-bergerkiller-bukkit-myworlds = "1.19.3-v1" +com-github-apachezy-langutils = "3.2.2" +com-github-marcono1234-gson-record-type-adapter-factory = "0.3.0" +com-github-milkbowl-vaultapi = "1.7.1" +com-github-mockbukkit-mockbukkit = "v1.21-SNAPSHOT" +com-github-puregero-multilib = "1.1.13" +com-github-slimefun-slimefun4 = "RC-37" +com-onarandombox-multiversecore-multiverse-core = "4.3.16" +com-zaxxer-hikaricp = "5.0.1" +de-oliver-fancyholograms = "2.4.1" +de-oliver-fancynpcs = "2.4.4" +dev-lone-api-itemsadder = "4.0.2-beta-release-11" +io-lumine-mythic-dist = "5.9.5" +io-papermc-paper-paper-api = "1.21.10-R0.1-SNAPSHOT" +io-th0rgal-oraxen = "1.193.1" +javax-xml-bind-jaxb-api = "2.3.0" +lol-pyr-znpcsplus-api = "2.0.0-SNAPSHOT" +me-clip-placeholderapi = "2.10.9" +org-awaitility-awaitility = "4.2.2" +org-bstats-bstats-bukkit = "3.0.0" +org-eclipse-jdt-org-eclipse-jdt-annotation = "2.2.600" +org-junit-jupiter-junit-jupiter-api = "5.10.2" +org-junit-jupiter-junit-jupiter-engine = "5.10.2" +org-mockito-mockito-core = "5.11.0" +org-mockito-mockito-junit-jupiter = "5.11.0" +org-mongodb-mongodb-driver = "3.12.12" +org-mvplugins-multiverse-core-multiverse-core = "5.0.0-SNAPSHOT" +org-spigotmc-spigot = "1.21.10-R0.1-SNAPSHOT" +org-spigotmc-spigot-api = "1.21.10-R0.1-SNAPSHOT" +world-bentobox-level = "2.21.3" + +[libraries] +com-bergerkiller-bukkit-myworlds = { module = "com.bergerkiller.bukkit:MyWorlds", version.ref = "com-bergerkiller-bukkit-myworlds" } +com-github-apachezy-langutils = { module = "com.github.apachezy:LangUtils", version.ref = "com-github-apachezy-langutils" } +com-github-marcono1234-gson-record-type-adapter-factory = { module = "com.github.Marcono1234:gson-record-type-adapter-factory", version.ref = "com-github-marcono1234-gson-record-type-adapter-factory" } +com-github-milkbowl-vaultapi = { module = "com.github.MilkBowl:VaultAPI", version.ref = "com-github-milkbowl-vaultapi" } +com-github-mockbukkit-mockbukkit = { module = "com.github.MockBukkit:MockBukkit", version.ref = "com-github-mockbukkit-mockbukkit" } +com-github-puregero-multilib = { module = "com.github.puregero:multilib", version.ref = "com-github-puregero-multilib" } +com-github-slimefun-slimefun4 = { module = "com.github.Slimefun:Slimefun4", version.ref = "com-github-slimefun-slimefun4" } +com-onarandombox-multiversecore-multiverse-core = { module = "com.onarandombox.multiversecore:multiverse-core", version.ref = "com-onarandombox-multiversecore-multiverse-core" } +com-zaxxer-hikaricp = { module = "com.zaxxer:HikariCP", version.ref = "com-zaxxer-hikaricp" } +de-oliver-fancyholograms = { module = "de.oliver:FancyHolograms", version.ref = "de-oliver-fancyholograms" } +de-oliver-fancynpcs = { module = "de.oliver:FancyNpcs", version.ref = "de-oliver-fancynpcs" } +dev-lone-api-itemsadder = { module = "dev.lone:api-itemsadder", version.ref = "dev-lone-api-itemsadder" } +io-lumine-mythic-dist = { module = "io.lumine:Mythic-Dist", version.ref = "io-lumine-mythic-dist" } +io-papermc-paper-paper-api = { module = "io.papermc.paper:paper-api", version.ref = "io-papermc-paper-paper-api" } +io-th0rgal-oraxen = { module = "io.th0rgal:oraxen", version.ref = "io-th0rgal-oraxen" } +javax-xml-bind-jaxb-api = { module = "javax.xml.bind:jaxb-api", version.ref = "javax-xml-bind-jaxb-api" } +lol-pyr-znpcsplus-api = { module = "lol.pyr:znpcsplus-api", version.ref = "lol-pyr-znpcsplus-api" } +me-clip-placeholderapi = { module = "me.clip:placeholderapi", version.ref = "me-clip-placeholderapi" } +org-awaitility-awaitility = { module = "org.awaitility:awaitility", version.ref = "org-awaitility-awaitility" } +org-bstats-bstats-bukkit = { module = "org.bstats:bstats-bukkit", version.ref = "org-bstats-bstats-bukkit" } +org-eclipse-jdt-org-eclipse-jdt-annotation = { module = "org.eclipse.jdt:org.eclipse.jdt.annotation", version.ref = "org-eclipse-jdt-org-eclipse-jdt-annotation" } +org-junit-jupiter-junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "org-junit-jupiter-junit-jupiter-api" } +org-junit-jupiter-junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "org-junit-jupiter-junit-jupiter-engine" } +org-mockito-mockito-core = { module = "org.mockito:mockito-core", version.ref = "org-mockito-mockito-core" } +org-mockito-mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "org-mockito-mockito-junit-jupiter" } +org-mongodb-mongodb-driver = { module = "org.mongodb:mongodb-driver", version.ref = "org-mongodb-mongodb-driver" } +org-mvplugins-multiverse-core-multiverse-core = { module = "org.mvplugins.multiverse.core:multiverse-core", version.ref = "org-mvplugins-multiverse-core-multiverse-core" } +org-spigotmc-spigot = { module = "org.spigotmc:spigot", version.ref = "org-spigotmc-spigot" } +org-spigotmc-spigot-api = { module = "org.spigotmc:spigot-api", version.ref = "org-spigotmc-spigot-api" } +world-bentobox-level = { module = "world.bentobox:level", version.ref = "world-bentobox-level" } diff --git a/gradle/wrapper/grade-wrapper.properties b/gradle/wrapper/grade-wrapper.properties new file mode 100644 index 000000000..6e2914a22 --- /dev/null +++ b/gradle/wrapper/grade-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..8bdaf60c7 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..2a84e188b --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 000000000..ef07e0162 --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..5eed7ee84 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 000000000..7836372ac --- /dev/null +++ b/plugin.yml @@ -0,0 +1,66 @@ +name: BentoBox +main: world.bentobox.bentobox.BentoBox +version: 3.10.2-LOCAL-SNAPSHOT-LOCAL +api-version: "1.21" + +authors: [tastybento, Poslovitch] +contributors: ["The BentoBoxWorld Community"] +website: https://bentobox.world +description: + +load: STARTUP + +loadbefore: [Pladdon, Multiverse-Core, My_Worlds, Residence] + +softdepend: + - Citizens + - Vault + - PlaceholderAPI + - dynmap + - BsbMongo + - AdvancedChests + - LangUtils + - WildStacker + - LuckPerms + - EconomyPlus + - MythicMobs + - ZNPCsPlus + - FancyNpcs + - FancyHolograms + +libraries: + - mysql:mysql-connector-java:8.0.27 + - org.mariadb.jdbc:mariadb-java-client:3.0.5 + - org.postgresql:postgresql:42.2.18 + - org.mongodb:mongodb-driver:3.12.12 + - com.zaxxer:HikariCP:5.0.1 + +permissions: + bentobox.admin: + description: Allows admin command usage + default: op + children: + bentobox.admin.catalog: + description: Allows to use /bentobox catalog + default: op + bentobox.admin.locale: + description: Allows to use /bentobox locale + default: op + bentobox.admin.manage: + description: Allows to use /bentobox manage + default: op + bentobox.admin.migrate: + description: Allows to use /bentobox migrate + default: op + bentobox.admin.reload: + description: Allows to use /bentobox reload + default: op + bentobox.about: + description: Allows to use /bentobox about + default: true + bentobox.version: + description: Allows to use /bentobox version + default: op + bentobox.perms: + description: Allow use of '/bentobox perms' command + default: op diff --git a/pom.xml b/pom.xml deleted file mode 100644 index dfc1caa5a..000000000 --- a/pom.xml +++ /dev/null @@ -1,718 +0,0 @@ - - - 4.0.0 - - world.bentobox - bentobox - ${revision} - - BentoBox - Highly scalable and customizable Minecraft Spigot plugin that enables you to run island-type gamemodes. - https://github.com/BentoBoxWorld/BentoBox - 2017 - - - - tastybento - tastybento@bentobox.world - -8 - - Developer - - - - - - scm:git:https://github.com/BentoBoxWorld/BentoBox.git - scm:git:git@github.com:BentoBoxWorld/BentoBox.git - https://github.com/BentoBoxWorld/BentoBox - - - - jenkins - https://ci.codemc.org/job/BentoBoxWorld/job/BentoBox - - - - GitHub - https://github.com/BentoBoxWorld/BentoBox/issues - - - - - bentoboxworld - https://repo.codemc.org/repository/bentoboxworld/ - - - - - UTF-8 - UTF-8 - 21 - - 5.10.2 - 5.11.0 - v1.21-SNAPSHOT - - 3.12.12 - 3.0.5 - 8.0.27 - 42.2.18 - 5.0.1 - - 1.21.10-R0.1-SNAPSHOT - - 1.21.10-R0.1-SNAPSHOT - 3.0.0 - 1.7.1 - 2.21.3 - 2.10.9 - d5f5e0bbd8 - 1.19.3-v1 - - ${build.version}-SNAPSHOT - - -LOCAL - - 3.10.2 - bentobox-world - https://sonarcloud.io - ${project.basedir}/lib - - - - - - - - ci - - - env.BUILD_NUMBER - - - - - -b${env.BUILD_NUMBER} - - - - - - - - master - - - env.GIT_BRANCH - origin/master - - - - - - ${build.version} - - - - - - - - - apache.snapshots - https://repository.apache.org/snapshots/ - - - - - - jitpack.io - https://jitpack.io - - - codemc-repo - https://repo.codemc.org/repository/maven-public - - - papermc - https://repo.papermc.io/repository/maven-public/ - - - minecraft-repo - https://libraries.minecraft.net/ - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots - - - nms-repo - https://repo.codemc.io/repository/nms/ - - - - MG-Dev Jenkins CI Maven Repository - https://ci.mg-dev.eu/plugin/repository/everything - - - - multiverse-multiverse-releases - Multiverse Repository - https://repo.onarandombox.com/multiverse-releases - - - multiverse-multiverse-snapshots - Multiverse Repository - https://repo.onarandombox.com/multiverse-snapshots - - - - nexus - Lumine Releases - https://mvn.lumine.io/repository/maven-public/ - - - - clojars - https://repo.clojars.org/ - - - - fancyplugins-releases - FancyPlugins Repository - https://repo.fancyplugins.de/releases - - - - pyr-snapshots - Pyr's Repo - https://repo.pyr.lol/snapshots - - - - matteodev - https://maven.devs.beer/ - - - - oraxen - Oraxen Repository - https://repo.oraxen.com/releases - - - - bentoboxworld - https://repo.codemc.org/repository/bentoboxworld/ - - - - - - - com.github.MockBukkit - MockBukkit - ${mock-bukkit.version} - test - - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.mockito - mockito-junit-jupiter - 5.11.0 - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - - org.awaitility - awaitility - 4.2.2 - test - - - - io.papermc.paper - paper-api - ${paper.version} - provided - - - - org.spigotmc - spigot-api - ${spigot.version} - provided - - - org.spigotmc. - spigot - 1.21.6-R0.1-SNAPSHOT - provided - - - org.spigotmc.. - spigot - 1.21.5-R0.1-SNAPSHOT - provided - - - org.spigotmc... - spigot - 1.21.4-R0.1-SNAPSHOT - provided - - - org.spigotmc.... - spigot - 1.21.3-R0.1-SNAPSHOT - provided - - - - org.bstats - bstats-bukkit - ${bstats.version} - - - - org.mongodb - mongodb-driver - ${mongodb.version} - provided - - - - com.zaxxer - HikariCP - ${hikaricp.version} - provided - - - - - com.github.MilkBowl - VaultAPI - ${vault.version} - provided - - - - me.clip - placeholderapi - ${placeholderapi.version} - provided - - - - com.bergerkiller.bukkit - MyWorlds - ${myworlds.version} - provided - - - io.lumine - Mythic-Dist - 5.9.5 - provided - - - org.mvplugins.multiverse.core - multiverse-core - 5.0.0-SNAPSHOT - provided - - - com.onarandombox.multiversecore - multiverse-core - 4.3.16 - provided - - - - - javax.xml.bind - jaxb-api - 2.3.0 - - - com.github.Marcono1234 - gson-record-type-adapter-factory - 0.3.0 - - - - - org.eclipse.jdt - org.eclipse.jdt.annotation - 2.2.600 - - - - com.github.apachezy - LangUtils - 3.2.2 - provided - - - - org.spigotmc - spigot - ${spigot.version} - provided - - - - com.github.Slimefun - Slimefun4 - RC-37 - provided - - - - dev.lone - api-itemsadder - 4.0.2-beta-release-11 - provided - - - - io.th0rgal - oraxen - 1.193.1 - - - me.gabytm.util - actions-spigot - - - org.jetbrains - annotations - - - com.ticxo - PlayerAnimator - - - com.github.stefvanschie.inventoryframework - IF - - - io.th0rgal - protectionlib - - - dev.triumphteam - triumph-gui - - - org.bstats - bstats-bukkit - - - com.jeff-media - custom-block-data - - - com.jeff-media - persistent-data-serializer - - - com.jeff_media - MorePersistentDataTypes - - - gs.mclo - java - - - provided - - - - com.github.puregero - multilib - 1.1.13 - compile - - - - de.oliver - FancyNpcs - 2.4.4 - provided - - - - lol.pyr - znpcsplus-api - 2.0.0-SNAPSHOT - provided - - - - de.oliver - FancyHolograms - 2.4.1 - provided - - - - world.bentobox - level - ${level.version} - provided - - - - - - - - - - - ${project.name}-${revision}${build.number} - - clean package - - - src/main/resources - true - - - src/main/resources/locales - ./locales - false - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.1.0 - - - org.apache.maven.plugins - maven-resources-plugin - 3.2.0 - - - org.apache.maven.plugins - maven-compiler-plugin - 3.14.1 - - ${java.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.5.4 - - - - -XX:+EnableDynamicAgentLoading - - --add-opens java.base/java.lang=ALL-UNNAMED - --add-opens java.base/java.math=ALL-UNNAMED - --add-opens java.base/java.io=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.stream=ALL-UNNAMED - --add-opens java.base/java.text=ALL-UNNAMED - --add-opens java.base/java.util.regex=ALL-UNNAMED - --add-opens java.base/java.nio.channels.spi=ALL-UNNAMED - --add-opens java.base/sun.nio.ch=ALL-UNNAMED - --add-opens java.base/java.net=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED - --add-opens java.base/sun.nio.fs=ALL-UNNAMED - --add-opens java.base/sun.nio.cs=ALL-UNNAMED - --add-opens java.base/java.nio.file=ALL-UNNAMED - --add-opens java.base/java.nio.charset=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.logging/java.util.logging=ALL-UNNAMED - --add-opens java.base/java.lang.ref=ALL-UNNAMED - --add-opens java.base/java.util.jar=ALL-UNNAMED - --add-opens java.base/java.util.zip=ALL-UNNAMED - --add-opens=java.base/java.security=ALL-UNNAMED - --add-opens java.base/jdk.internal.misc=ALL-UNNAMED - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.1 - - ${java.version} - private - true - false - -Xdoclint:none - - ${java.home}/bin/javadoc - - - - attach-javadocs - package - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - install - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - true - ${project.build.directory}/dependency-reduced-pom.xml - - - org.bstats - world.bentobox.bentobox.util.metrics - - - - io.papermc.lib - world.bentobox.bentobox.paperlib - - - com.github.puregero.multilib - world.bentobox.bentobox.multilib - - - - - org.apache.maven.shared:* - org.apache.maven:* - com.google.code.gson:* - org.mongodb:* - org.eclipse.jdt:* - - - - - - package - - shade - - - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - - default-deploy - deploy - - deploy - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.13 - - true - - - **/*Names* - - org/bukkit/Material* - - - - - prepare-agent - - prepare-agent - - - - report - - report - - - - XML - - - - - - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..52374bf30 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,5 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +rootProject.name = "bentobox" diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/GetMetaData.java deleted file mode 100644 index 530bc966e..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/GetMetaData.java +++ /dev/null @@ -1,22 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_5_R0_1_SNAPSHOT; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_21_R4.CraftWorld; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.entity.TileEntity; -import world.bentobox.bentobox.nms.AbstractMetaData; - -public class GetMetaData extends AbstractMetaData { - - @Override - public String nmsData(Block block) { - Location w = block.getLocation(); - CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one - // for 1.13+ (we have use WorldServer) - TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ())); - return getData(te, "getUpdatePacket", "tag"); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/PasteHandlerImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/PasteHandlerImpl.java deleted file mode 100644 index 6dcdec507..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/PasteHandlerImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_5_R0_1_SNAPSHOT; - -import java.util.concurrent.CompletableFuture; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R4.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock; -import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.nms.PasteHandler; -import world.bentobox.bentobox.util.DefaultPasteUtil; -import world.bentobox.bentobox.util.Util; - -public class PasteHandlerImpl implements PasteHandler { - - protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState(); - - /** - * Set the block to the location - * - * @param island - island - * @param location - location - * @param bpBlock - blueprint block - */ - @Override - public CompletableFuture setBlock(Island island, Location location, BlueprintBlock bpBlock) { - return Util.getChunkAtAsync(location).thenRun(() -> { - Block block = setBlock(location, DefaultPasteUtil.createBlockData(bpBlock)); - DefaultPasteUtil.setBlockState(island, block, bpBlock); - // Set biome - if (bpBlock.getBiome() != null) { - block.setBiome(bpBlock.getBiome()); - } - }); - } - - @Override - public Block setBlock(Location location, BlockData bd) { - Block block = location.getBlock(); - // Set the block data - default is AIR - CraftBlockData craft = (CraftBlockData) bd; - net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4); - BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - // Setting the block to air before setting to another state prevents some console errors - // If the block is a naturally generated tile entity that needs filling, e.g., a chest, then this kind of pasting can cause console errors due to race condition - // so the try's are there to try and catch the errors. - try { - nmsChunk.a(bp, AIR, 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - nmsChunk.a(bp, craft.getState(), 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - block.setBlockData(bd, false); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - return block; - } -} diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/WorldRegeneratorImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/WorldRegeneratorImpl.java deleted file mode 100644 index f50874659..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_5_R0_1_SNAPSHOT/WorldRegeneratorImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_5_R0_1_SNAPSHOT; - -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R4.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.nms.CopyWorldRegenerator; - -public class WorldRegeneratorImpl extends CopyWorldRegenerator { - - @Override - public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, - boolean applyPhysics) { - CraftBlockData craft = (CraftBlockData) blockData; - World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ()); - BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); - // Setting the block to air before setting to another state prevents some console errors - nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics ? 1 : 0); - nmsChunk.a(bp, craft.getState(), applyPhysics ? 1 : 0); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/GetMetaData.java deleted file mode 100644 index c04dd8b72..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/GetMetaData.java +++ /dev/null @@ -1,22 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.entity.TileEntity; -import world.bentobox.bentobox.nms.AbstractMetaData; - -public class GetMetaData extends AbstractMetaData { - - @Override - public String nmsData(Block block) { - Location w = block.getLocation(); - CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one - // for 1.13+ (we have use WorldServer) - TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ())); - return getData(te, "getUpdatePacket", "tag"); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/PasteHandlerImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/PasteHandlerImpl.java deleted file mode 100644 index b25795ee6..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/PasteHandlerImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT; - -import java.util.concurrent.CompletableFuture; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock; -import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.nms.PasteHandler; -import world.bentobox.bentobox.util.DefaultPasteUtil; -import world.bentobox.bentobox.util.Util; - -public class PasteHandlerImpl implements PasteHandler { - - protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState(); - - /** - * Set the block to the location - * - * @param island - island - * @param location - location - * @param bpBlock - blueprint block - */ - @Override - public CompletableFuture setBlock(Island island, Location location, BlueprintBlock bpBlock) { - return Util.getChunkAtAsync(location).thenRun(() -> { - Block block = setBlock(location, DefaultPasteUtil.createBlockData(bpBlock)); - DefaultPasteUtil.setBlockState(island, block, bpBlock); - // Set biome - if (bpBlock.getBiome() != null) { - block.setBiome(bpBlock.getBiome()); - } - }); - } - - @Override - public Block setBlock(Location location, BlockData bd) { - Block block = location.getBlock(); - // Set the block data - default is AIR - CraftBlockData craft = (CraftBlockData) bd; - net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4); - BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - // Setting the block to air before setting to another state prevents some console errors - // If the block is a naturally generated tile entity that needs filling, e.g., a chest, then this kind of pasting can cause console errors due to race condition - // so the try's are there to try and catch the errors. - try { - nmsChunk.a(bp, AIR, 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - nmsChunk.a(bp, craft.getState(), 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - block.setBlockData(bd, false); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - return block; - } -} diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/WorldRegeneratorImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/WorldRegeneratorImpl.java deleted file mode 100644 index 9b07595f3..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_6_R0_1_SNAPSHOT/WorldRegeneratorImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT; - -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.nms.CopyWorldRegenerator; - -public class WorldRegeneratorImpl extends CopyWorldRegenerator { - - @Override - public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, - boolean applyPhysics) { - CraftBlockData craft = (CraftBlockData) blockData; - World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ()); - BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); - // Setting the block to air before setting to another state prevents some console errors - nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics ? 1 : 0); - nmsChunk.a(bp, craft.getState(), applyPhysics ? 1 : 0); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/GetMetaData.java deleted file mode 100644 index 868925046..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/GetMetaData.java +++ /dev/null @@ -1,22 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_7_R0_1_SNAPSHOT; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.entity.TileEntity; -import world.bentobox.bentobox.nms.AbstractMetaData; - -public class GetMetaData extends AbstractMetaData { - - @Override - public String nmsData(Block block) { - Location w = block.getLocation(); - CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one - // for 1.13+ (we have use WorldServer) - TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ())); - return getData(te, "getUpdatePacket", "tag"); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/PasteHandlerImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/PasteHandlerImpl.java deleted file mode 100644 index 6171b4edc..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/PasteHandlerImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_7_R0_1_SNAPSHOT; - -import java.util.concurrent.CompletableFuture; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock; -import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.nms.PasteHandler; -import world.bentobox.bentobox.util.DefaultPasteUtil; -import world.bentobox.bentobox.util.Util; - -public class PasteHandlerImpl implements PasteHandler { - - protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState(); - - /** - * Set the block to the location - * - * @param island - island - * @param location - location - * @param bpBlock - blueprint block - */ - @Override - public CompletableFuture setBlock(Island island, Location location, BlueprintBlock bpBlock) { - return Util.getChunkAtAsync(location).thenRun(() -> { - Block block = setBlock(location, DefaultPasteUtil.createBlockData(bpBlock)); - DefaultPasteUtil.setBlockState(island, block, bpBlock); - // Set biome - if (bpBlock.getBiome() != null) { - block.setBiome(bpBlock.getBiome()); - } - }); - } - - @Override - public Block setBlock(Location location, BlockData bd) { - Block block = location.getBlock(); - // Set the block data - default is AIR - CraftBlockData craft = (CraftBlockData) bd; - net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4); - BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - // Setting the block to air before setting to another state prevents some console errors - // If the block is a naturally generated tile entity that needs filling, e.g., a chest, then this kind of pasting can cause console errors due to race condition - // so the try's are there to try and catch the errors. - try { - nmsChunk.a(bp, AIR, 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - nmsChunk.a(bp, craft.getState(), 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - block.setBlockData(bd, false); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - return block; - } -} diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/WorldRegeneratorImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/WorldRegeneratorImpl.java deleted file mode 100644 index 6f5585293..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_7_R0_1_SNAPSHOT/WorldRegeneratorImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_7_R0_1_SNAPSHOT; - -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.nms.CopyWorldRegenerator; - -public class WorldRegeneratorImpl extends CopyWorldRegenerator { - - @Override - public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, - boolean applyPhysics) { - CraftBlockData craft = (CraftBlockData) blockData; - World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ()); - BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); - // Setting the block to air before setting to another state prevents some console errors - nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics ? 1 : 0); - nmsChunk.a(bp, craft.getState(), applyPhysics ? 1 : 0); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/GetMetaData.java deleted file mode 100644 index ca171de9c..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/GetMetaData.java +++ /dev/null @@ -1,22 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_8_R0_1_SNAPSHOT; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.entity.TileEntity; -import world.bentobox.bentobox.nms.AbstractMetaData; - -public class GetMetaData extends AbstractMetaData { - - @Override - public String nmsData(Block block) { - Location w = block.getLocation(); - CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one - // for 1.13+ (we have use WorldServer) - TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ())); - return getData(te, "getUpdatePacket", "tag"); - } - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/PasteHandlerImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/PasteHandlerImpl.java deleted file mode 100644 index f81385102..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/PasteHandlerImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_8_R0_1_SNAPSHOT; - -import java.util.concurrent.CompletableFuture; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock; -import world.bentobox.bentobox.database.objects.Island; -import world.bentobox.bentobox.nms.PasteHandler; -import world.bentobox.bentobox.util.DefaultPasteUtil; -import world.bentobox.bentobox.util.Util; - -public class PasteHandlerImpl implements PasteHandler { - - protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState(); - - /** - * Set the block to the location - * - * @param island - island - * @param location - location - * @param bpBlock - blueprint block - */ - @Override - public CompletableFuture setBlock(Island island, Location location, BlueprintBlock bpBlock) { - return Util.getChunkAtAsync(location).thenRun(() -> { - Block block = setBlock(location, DefaultPasteUtil.createBlockData(bpBlock)); - DefaultPasteUtil.setBlockState(island, block, bpBlock); - // Set biome - if (bpBlock.getBiome() != null) { - block.setBiome(bpBlock.getBiome()); - } - }); - } - - @Override - public Block setBlock(Location location, BlockData bd) { - Block block = location.getBlock(); - // Set the block data - default is AIR - CraftBlockData craft = (CraftBlockData) bd; - net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4); - BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - // Setting the block to air before setting to another state prevents some console errors - // If the block is a naturally generated tile entity that needs filling, e.g., a chest, then this kind of pasting can cause console errors due to race condition - // so the try's are there to try and catch the errors. - try { - nmsChunk.a(bp, AIR, 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - nmsChunk.a(bp, craft.getState(), 0); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - try { - block.setBlockData(bd, false); - } catch (Exception e) { - e.printStackTrace(); - // Ignore - } - return block; - } -} diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/WorldRegeneratorImpl.java b/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/WorldRegeneratorImpl.java deleted file mode 100644 index ce53ff00a..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_21_8_R0_1_SNAPSHOT/WorldRegeneratorImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package world.bentobox.bentobox.nms.v1_21_8_R0_1_SNAPSHOT; - -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_21_R5.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData; - -import net.minecraft.core.BlockPosition; -import net.minecraft.world.level.World; -import net.minecraft.world.level.chunk.Chunk; -import world.bentobox.bentobox.nms.CopyWorldRegenerator; - -public class WorldRegeneratorImpl extends CopyWorldRegenerator { - - @Override - public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, - boolean applyPhysics) { - CraftBlockData craft = (CraftBlockData) blockData; - World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); - Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ()); - BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); - // Setting the block to air before setting to another state prevents some console errors - nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics ? 1 : 0); - nmsChunk.a(bp, craft.getState(), applyPhysics ? 1 : 0); - } - -} \ No newline at end of file