【问题标题】:Getting package org.bukkit does not exist When I try to build my jar file(java)当我尝试构建我的 jar 文件(java)时,获取包 org.bukkit 不存在
【发布时间】:2020-12-26 14:36:23
【问题描述】:

我遇到了一个 Bukkit(minecraft) 包问题!

这是https://prnt.sc/wabncu 的截图,我正在使用三十病毒(一个我的世界编码/hypixel skyblock youtuber)模板插件

编辑:可以在github中看到代码templateplugin

【问题讨论】:

    标签: minecraft bukkit


    【解决方案1】:

    首先:GitHub上有无数名为“templateplugin”的repos,所以我们已经需要一个链接了。

    但我认为你的意思是这个:https://github.com/ThirtyVirus/Plugin_Template

    我很确定您只是忘记添加 Bukkit 依赖项。

    Maven

    <repositories>
        <!-- This adds the Spigot Maven repository to the build -->
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>
    
    <dependencies>
        <!--This adds the Spigot API artifact to the build -->
        <dependency>
               <groupId>org.spigotmc</groupId>
               <artifactId>spigot-api</artifactId>
               <version>1.16.4-R0.1-SNAPSHOT</version>
               <scope>provided</scope>
        </dependency>
    </dependencies>
    

    Gradle

    repositories {
      mavenCentral() // This is needed for dependencies.
       /*
       As Spigot-API depends on the Bungeecord ChatComponent-API,
      we need to add the Sonatype OSS repository, as Gradle,
      in comparison to maven, doesn't want to understand the ~/.m2
      directory unless added using mavenLocal(). Maven usually just gets
      it from there, as most people have run the BuildTools at least once.
      This is therefore not needed if you're using the full Spigot/CraftBukkit,
      or if you're using the Bukkit API.
      */
      maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
      maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
      // mavenLocal() // This is needed for CraftBukkit and Spigot.
    }
    
    dependencies {
      // Pick only one of these and read the comment in the repositories block.
      compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT' // The Spigot API with no shadowing. Requires the OSS repo.
      compileOnly 'org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT' // The Bukkit API with no shadowing.
      compileOnly 'org.spigotmc:spigot:1.12.2.-R0.1-SNAPSHOT' // The full Spigot server with no shadowing. Requires mavenLocal.
      compileOnly 'org.bukkit:craftbukkit:1.12.2-R0.1-SNAPSHOT' // The full CraftBukkit server with no shadowing. Requires mavenLocal.
    }
    

    如果你不使用 maven 或 gradle,你应该学习如何使用它们中的至少一个。否则,(不推荐),您可以在本地添加一个jar文件作为库。

    【讨论】:

      【解决方案2】:

      如果您使用的是 Maven 或 Gradle,您可以通过直接实现它们的 repo 来实现 Spigot 和 Bukkit。如果您使用 IntelliJ IDEA 的 Artifact Builder,您可以通过 Build Tools 为自己构建一个 jar,它会为您解决所有问题,抱歉我不了解 Eclipse,因为我还没有使用它

      https://www.spigotmc.org/wiki/buildtools/ 这是一个 Build Tools for Spigot 的链接,它适用于从 1.8 到 1.16.4(最新)的每个版本,如果您从 BuildTools 构建一个 jar,您可以访问许多您无法从直接 repo 获得的工具。

      【讨论】:

        猜你喜欢
        • 2013-12-09
        • 2018-09-11
        • 1970-01-01
        • 1970-01-01
        • 2020-02-05
        • 1970-01-01
        • 2018-03-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多