[INTELLIJ] Issues getting started with plugin development

Hey all. So I followed the Sponge docs (specifically Setting Up Your Workspace and Plugin Debugging, as well as the SpongeForge repo’s readme. I’ve been following any IntelliJ IDEA sections if available.

However I run into some issues when running the client/server. After starting the server (and updating eula/properties), I tried to used the client run config to connect to my localhost server. But it throws the following:

Summary

[19:27:27] [Client thread/FATAL] [minecraft/Minecraft]: Unreported exception thrown!
java.lang.NoSuchMethodError: com.google.common.util.concurrent.Futures.addCallback(Lcom/google/common/util/concurrent/ListenableFuture;Lcom/google/common/util/concurrent/FutureCallback;)V
at net.minecraft.client.renderer.chunk.ChunkRenderWorker.processTask(ChunkRenderWorker.java:177) ~[ChunkRenderWorker.class:?]
at net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.updateChunkNow(ChunkRenderDispatcher.java:172) ~[ChunkRenderDispatcher.class:?]
at net.minecraft.client.renderer.RenderGlobal.setupTerrain(RenderGlobal.java:1012) ~[RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1369) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1312) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1115) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1209) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:442) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:25) [start/:?]

This error also crashes my server.

Steps that I took to setup my plugin project:

  1. Recursively clone SpongeForge
  2. Run ./gradlew setupDecompWorkspace --refresh-dependencies
  3. Run ./gradlew genIntelliJRuns
  4. Add new module to the SpongeForge project (my plugin module)
  5. Add my plugin module (main) to the SpongeForge.main dependencies
  6. Updated the run configurations to use the SpongeForge.main module

Additionally, I added a quick log statement in my onServerStart function along with a breakpoint: the log never prints and the breakpoint never pauses. Which suggests to me that my plugin actually is not being built and/or added to the classpath.

This is my third night now trying to get a project setup and its really starting to annoy me. I tried different permutations of the steps above (such as making SpongeForge a module to my own plugin) but nothing seems to work. What am I missing?

I am running:

OS: Windows 10
SpongeForge Version/Branch: stable-7
Java Version: 1.8
Minecraft Version: 1.12

I have never started the client through the IDE for purposes of plugin testing, since it usually does not need any restart throughout the dev session… unless you’re building a mod, have you tried to start a normal client outside of the IDE?

I would try just a normal client, but now the server run config is giving me a build error:

B:\Coding\devthedevel\SpongeForge\SpongeCommon\build\sources\main\java\org\spongepowered\common\mixin\core\world\chunk\storage\AnvilChunkLoaderMixin.java:313: error: Malformed owner: Lnet/minecraft/world/chunk/storage/AnvilChunkLoader If you are seeing this message unexpectedly and the owner appears to be correct, replace the owner descriptor with formal type LLnet/minecraft/world/chunk/storage/AnvilChunkLoader; to suppress this error
@Redirect(method = "saveChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/storage/AnvilChunkLoader.addChunkToPending"

I tried to update the target, but its a generated file: just gets regenerated on every build :confused:

I would try just a normal client, but now the server run config is giving me a build error:

B:\Coding\devthedevel\SpongeForge\SpongeCommon\build\sources\main\java\org\spongepowered\common\mixin\core\world\chunk\storage\AnvilChunkLoaderMixin.java:313: error: Malformed owner: Lnet/minecraft/world/chunk/storage/AnvilChunkLoader If you are seeing this message unexpectedly and the owner appears to be correct, replace the owner descriptor with formal type LLnet/minecraft/world/chunk/storage/AnvilChunkLoader; to suppress this error
@Redirect(method = "saveChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/storage/AnvilChunkLoader.addChunkToPending"

I tried to update the target, but its a generated file: just gets regenerated on every build

Nevermind, looks like I had my SpongeCommon and SpongeAPI subrepos on the wrong branch. Fixed that. Server runs now.

But I’m still not seeing my plugin’s log nor hitting my breakpoints. I tried using /sponge plugins in game to see what plugins are installed but I’m just given:

Input command plugins was not a valid subcommand!

In fact, none of the sponge commands are working

But I’m still not seeing my plugin’s log nor hitting my breakpoints. I tried using /sponge plugins in game to see what plugins are installed but I’m just given:

Input command plugins was not a valid subcommand!

In fact, none of the sponge commands are working

Scratch that. Needed to OP myself (I’m too tired working on this stuff today lol). Ran sponge plugins and everything was fine. My plugin is still not there though :confused:

Your plugin isnt working. You mentioned that you have a system.out message in your start method. Mind if we see the code to see whats going wrong?

Literally the basics that the Minecraft Development plugin creates:

package xyz.devthedevel.battlegrounds;

import com.google.inject.Inject;
import org.slf4j.Logger;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.plugin.Plugin;

@Plugin(
    id = "battlegrounds",
    name = "Battlegrounds"
)
public class Battlegrounds {

    @Inject
    private Logger logger;

    @Listener
    public void onServerStart(GameStartedServerEvent event) {
        logger.info("onServerStart");
    }
}

My breakpoint is also on the same line as logger.info("onServerStart");

Its not your plugin code then. All of that is fine.

In your run server executor, does it have in the before actions of “gradle build”? Its been a while since I have ran sponge 7 directly from Intelij to test plugins so I cannot remember if that is needed or not

This is after running ./gradlew genIntelliJRuns

Edit: I just noticed the warning at the bottom. I ran into that before on SpongeForge and the solution was just to switch the module classpath to SpongeForge.main. However it looks like SpongeVanilla.main doesn’t have that

Edit 2: Running ./gradlew setupDecompWorkspace again fixes that warning

Edit 3: Running the server config now gives me the following error:

java.lang.NoClassDefFoundError: com/lmax/disruptor/EventTranslatorVararg
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.core.async.AsyncLoggerContextSelector.createContext(AsyncLoggerContextSelector.java:46)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:74)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:227)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
at net.minecraftforge.gradle.GradleStartCommon.<clinit>(GradleStartCommon.java:40)