TypeToken cannot be imported/used/found

Sponge Build: spongeforge-1.8.9-1890-4.1.0-BETA-1323
Forge Build: 1890
Java Version: 1.8.0_45

Title pretty much sums it up, I can’t use TypeToken.of() or anything that relates to TypeToken. Here’s what I mean:

I understand Sponge is in development and it could be an issue, but the documentation has this so I would assume it should be working.

Are you depending on spongeforge? And if so, why?

Do you have a pom/build.gradle? If so, please post it.

Although Sponge is in development, this is something wrong with either your configuration or the jar your targeting, TypeToken isn’t even a sponge class, its just packaged with the API.

EDIT: Something may also be wrong with sponge’s shadow configuration

I have the sponge forge jar in my build path because the API jar doesn’t work by itself correctly. I don’t have a pom or build.gradle.

I’ve used the API jar itself multiple times. What do you mean by “it doesn’t work by itself correctly,” does your IDE not load? Do errors occur?

Moreover, I really suggest using gradle or maven, they’re suggest and make the dependency process much easier.

It may help if you look at the first few tutorials here, they’re quite helpful and more descriptive than I:
https://docs.spongepowered.org/master/en/plugin/index.html

I will look into maven, and I’ll retry the API & post the issue.
EDIT: The issue using the API jar is that it’s missing classes I need:

The issue seems to be in 4.1.0, google commons is not there but in 4.0.3 google commons is there so I can use the class I need. Still very weird, but I guess I will need to use 4.0.3 for now.

This is explained in the Build Systems docs page: https://docs.spongepowered.org/master/en/plugin/buildsystem.html

Basically, you will either need to use a build system such as Gradle or Maven for your plugin that will manage the dependencies for you (recommended) or if you really have to, download the shaded API artifact from the Downloads page which is the only one which has all dependency classes included.

1 Like

And I would personally recommend Gradle, as XML is annoying as hell for simple configuration, and Sponge’s SpongeGradle plugin does most of it for you (as well as automatically processing and including mcmod.info when you build).

I went ahead and used maven to import the jar which fixed the issue. I don’t really care for an mcmod.info but I guess I have no idea what it means to me either.

Sponge yells at you if you don’t have it, and it’s required if you want to host it on Ore.

Not sure what Ore is. Anyways, most of my plugins will be private but I will add one anyways.

Remember BukkitDev? The nice way to organize plugins… Ore is that, but 1000 times better. It’s the long term solution to plugin distribution. It’s going to replace the current make-a-thread format of distributing and sorting plugins. You can see it, in beta, at ore-staging.spongepowered.org

Okay, that’s cool. Much better than the forum posting I must admit.

1 Like

I just use gradle for the dependencies, I don’t export the plugin with it. I just have my IDE export it. And it includes the mcmod.info for me.