2

I am currently getting into Spigot Pugin developement and need to access GameProfile, because I need it for a plugin (Stuff for changing Skins). I'm using Eclipse.

Now, I've watched a whole ton of tutorials in which GameProfile was used, and all these tutorials just went for

import com.mojang.authlib.GameProfile;

or

import net.minecraft.util.SOMETHINGLONG.GameProfile

without needing to explain anything why this line is possible.

Here is a guy that had the same problem like me with the second command but apparently could solve it with the first one, so im trying to get this one running. https://www.spigotmc.org/threads/how-to-import-net-minecraft-util.252371/.

If I try to include stuff like this, I see com.google.common, com.oracle and com.sun but com.mojang is nowhere to be seen. I found it has to do something with the .jar files you add to your project, but I don't know how to get com.mojang... into the importable files.

monamona
  • 1,195
  • 2
  • 17
  • 43
  • Try downloading JAR from the here http://mvnrepository.com/artifact/com.mojang/minecraft-server/1.4.4 – OneCricketeer Sep 23 '18 at 14:57
  • Error 502, this file is gone... – monamona Sep 23 '18 at 15:02
  • Well, as that spigot blog says, everything should have been moved to `net.minecraft`, probably after Microsoft bought out Minecraft from Mojang. So wherever you download the Minecraft server jars from, that's what you should be using. And you're probably referencing an old tutorial – OneCricketeer Sep 23 '18 at 15:07
  • So this seems to explain the 2 import methods. I actually included the 1.12.2 jar from my ´.minecraft/versions` folder but this ony gives me net.minecraft.servers.* – monamona Sep 23 '18 at 15:17
  • And a ton of stuff seems to be missing, including the utils and the GameProfile – monamona Sep 23 '18 at 15:17
  • Poke - Just for poking – monamona Oct 29 '18 at 13:21
  • 1
    https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/ – OneCricketeer Oct 29 '18 at 14:25

3 Answers3

8

To build up on SPY_me's answer, here is my solution if you're using 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
}

If you want to download this library directly, here is the jar:

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

Lukas
  • 96
  • 2
  • 6
  • 2
    Just want to add on that you can see what libraries a particular version of Minecraft uses by going to `.minecraft/versions//.json` (see [here for more information on the .minecraft folder](https://minecraft.gamepedia.com/.minecraft)). An array of the libraries used is under the property `libraries`. For example, 1.16.4 uses `com.mojang.authlib.2.1.28`. – Lauren Yim Dec 21 '20 at 09:15
4

    <repositories>
        <repository>
            <id>minecraft-repo</id>
            <url>https://libraries.minecraft.net/</url>
        </repository>
    </repositories>

    <dependencies>
       <dependency>
            <groupId>com.mojang</groupId>
            <artifactId>authlib</artifactId>
            <version>1.5.21</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
SPY_me
  • 41
  • 2
  • Please provide more context. Why have you added those two things to the Maven pom? The question does not mention Maven, but only Eclipse. – triplem May 08 '20 at 06:10
2

Since you use Intellij i guess youre using Maven?

If so then paste this in your pom.yml:

<repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>

    <dependencies>
        <!--Spigot API-->
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.8.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <!--Bukkit API-->
        <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.8.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <!--CraftBukkit API-->
        <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>craftbukkit</artifactId>
            <version>1.8.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>