[SOLVED] @Inject disallowed for this location

Recently startet to port my bukkit plugins to sponge … but I got some problems …
this code isn’t working because eclipse keeps saying “The annotation @Inject is disallowed for this location”.
but other plugins seems to use it the exact same way.
something wrong with it in the latest version?

public class Plugin {

    private Logger logger;

    @ConfigDir(sharedRoot = false)
    private File configDir;

Seems like SpongeVanilla is a standalone server without forge … i would prefere that … is it available/working? I could not found any download link/page for it?

Can I see your imports? I think you might have imported the wrong Inject.

For debugging and making plugins, you want to use the forge version. The forge version allows hot swapping and real time debugging :smile:.
But if your really want to use it. Follow the instructions for cloning and setup (you can skip the ide part). Than do ./gradlew build (or gradlew build for windows). Normally you will find a SpongeVanilla jar in build/lib

1 Like

SpongeVanilla also has this capability.


ty :smile: the import of course -.-"
i was using

import org.spongepowered.asm.mixin.injection.Inject;

because it came from sponge … ,but

import com.google.inject.Inject;

seems to be the right one … Thank u :slight_smile:

Isn’t it easier on forge? With ForgeGradle?

dunno … never used gradle/maven (simply didn’t found time to read into that topic) and my projects aren’t big enough to really profit from it … even my git is only used to not accidently delete my code …


Trust me it is easier if you use maven or gradle :smile:. For example: You want to update your plugin to SpongeAPI 8.4. You could just change the version in the pom.xml or build.gradle. And it will automatically download the new dependency for you. Also you can do gradle build or mvn build and it will automaticly generate a jar for you ;).

ya i know it can make things a lot easier :wink: probably i should look into it afer i finished my current plugin …

BTW I get an error building Sponge vanilla undter windows with the gradlew.bat

i did unter git bash

git clone --recursive https://github.com/SpongePowered/SpongeVanilla.git
cd SpongeVanilla
cp scripts/pre-commit .git/hooks

and than run gradlew.bat unter windows shell …

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':runtime'.
> Could not resolve :minecraft_SpongeVanilla_bin:1.8.
  Required by:
   > Could not resolve :minecraft_SpongeVanilla_bin:1.8.
      > Could not get resource 'https://libraries.minecraft.net//minecraft_Spong
         > Could not GET 'https://libraries.minecraft.net//minecraft_SpongeVanil
la_bin/1.8/minecraft_SpongeVanilla_bin-1.8.pom'. Received status code 403 from s
erver: Forbidden

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.


well i m new to gradle/ git am I doing it wrong or is there really an issue?

You need to run gradlew setupDecompWorkspace first (before running gradlew to build)


You won’t have that issue if you build against the API instead of an Implementation.

well i dont get it to run …
i did gradlew setupDecompWorkspace and then build it with gradlew … just a waring because i have java 8 and not java 6 but that shouldnt create problems right?
but the generatet jar file is throwing errors after downloading the vanilla server:

[13:34:46 WARN] [mixin]: Method overwrite conflict for getOnlinePlayers, previou
sly written by org.spongepowered.common.mixin.core.server.MixinMinecraftServer.
Skipping method.
[13:34:46 ERROR] [mixin]: Critical injection failure: LVT in net/minecraft/world
/World::func_72838_d has incompatible changes at opcode 34. Expected [I, I, Z] b
ut found [I, I, I]. Callback spawnEntityInject1(Lnet/minecraft/entity/Entity;Lor
[13:34:46 ERROR] [ERR]: Exception in thread "main" java.lang.ExceptionInInitiali
[13:34:46 ERROR] [ERR]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Nati
ve Method)
[13:34:46 ERROR] [ERR]:     at sun.reflect.NativeMethodAccessorImpl.invoke(Unkno
wn Source)
[13:34:46 ERROR] [ERR]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(U
nknown Source)
[13:34:46 ERROR] [ERR]:     at java.lang.reflect.Method.invoke(Unknown Source)
[13:34:46 ERROR] [ERR]:     at net.minecraft.launchwrapper.Launch.launch(Launch.
[13:34:46 ERROR] [ERR]:     at net.minecraft.launchwrapper.Launch.main(Launch.ja
[13:34:46 ERROR] [ERR]:     at org.spongepowered.vanilla.launch.server.VanillaSe
[13:34:46 ERROR] [ERR]: Caused by: com.google.inject.ProvisionException: Unable
to provision, see the following errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: net/minecraft/wo
  at org.spongepowered.vanilla.plugin.VanillaPluginManager.<init>(VanillaPluginM
  at org.spongepowered.vanilla.plugin.VanillaPluginManager.class(VanillaPluginMa
  while locating org.spongepowered.vanilla.plugin.VanillaPluginManager
  at org.spongepowered.vanilla.guice.VanillaGuiceModule.configure(VanillaGuiceMo

seems like you have way more exoerience with this, than i have … could you make a step by step list with the commands?

You’ve done everything correctly, this is an issue on sponge’s side.


SpongeVanilla uses ForgeGradle.