首页 > 解决方案 > 如何导入 com.mojang.authlib.GameProfile

问题描述

我目前正在进入 Spigot Pugin 开发并需要访问 GameProfile,因为我需要它作为插件(用于更改皮肤的东西)。我正在使用 Eclipse。

现在,我已经看了一大堆使用 GameProfile 的教程,所有这些教程都是为了

import com.mojang.authlib.GameProfile;

或者

import net.minecraft.util.SOMETHINGLONG.GameProfile

无需解释为什么这条线是可能的。

这是一个与我有同样问题的人使用第二个命令,但显然可以用第一个命令解决它,所以我试图让这个命令运行。https://www.spigotmc.org/threads/how-to-import-net-minecraft-util.252371/

如果我尝试包含这样的东西,我会看到,com.google.common但是com.mojang 无处可寻。我发现它与您添加到项目中的 .jar 文件有关,但我不知道如何将 com.mojang... 放入可导入文件中。com.oraclecom.sun

标签: javaminecraft

解决方案


为了建立SPY_me 的答案,如果您使用 Gradle,这是我的解决方案:

repositories {
    // ...
    maven {
        name = 'minecraft-repo'
        url = 'https://libraries.minecraft.net/'
        // this lets gradle know where to look for authlib
    }
}

dependencies {
    // ...
    compile 'com.mojang:authlib:1.5.21'
    // this adds the library to the project and the jar when you compile your project
}

如果你想直接下载这个库,这里是jar:

https://libraries.minecraft.net/com/mojang/authlib/1.5.21/authlib-1.5.21.jar


推荐阅读