minecraft - 当我尝试构建我的 jar 文件(java)时,获取包 org.bukkit 不存在

标签 minecraft bukkit

我遇到了 Bukkit(minecraft) 软件包问题!

package org.bukkit does not exist

我正在使用 ThirtyVirus(一款 MineCraft 编码 YouTuber)模板插件。

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

最佳答案

首先:GitHub 上有无数名为“templateplugin”的存储库,因此我们已经需要一个链接。

但我认为你指的是这个: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 文件作为库。

关于minecraft - 当我尝试构建我的 jar 文件(java)时,获取包 org.bukkit 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65457441/

相关文章:

java - 从 ChatColor 转换为颜色代码

java - 如何让 Eclipse 将文件导出到与源不同的位置?

java - 类加载器返回 NoSuchMethodException 错误

java - 运行配置以在 IntelliJ IDEA 中调试 Bukkit/Minecraft 插件?

java - 使用 Maven 导入 Fanciful Library(Minecraft 服务器插件开发)

windows - 我的世界服务器需要批量自动重启脚本

java - Minecraft 启动器登录代码

Kotlin 对象作为 spigot 的注入(inject)点

PHP查询一条SRV记录

java - 这些访问Java中其他类的方法有什么区别?