I am trying to write an economy plugin

I am trying to write an economy plugin(not a plugin that uses the economy, one that provides it) and I wasn’t able to find stuff about this in the docs, there’s probably something on google but my google-fu is not the best. So my question is: Can you give me a link to a good documentation tonpeovide the economy?

Are you sure you’re looking at the right Docs? This should be a good primer, although the JavaDocs will also have a lot of what you need.

So if I implement these classes will it automaticlly work?

You still need to provide your EconomyService to the service manager, but after that, AFAIK, yes.

and how would I do that, that is definitely missing in the docs(except if it is hidden in the last corner)


that’s not where I would look for service economy integration. But I’m on mobile rn, thx for the link.

The trick is to, instead of just reading a couple pages, read the entire docs. It’s a really good idea, it’ll help you with plugineering later on, and it’ll avoid questions like this. For example, if you read it you’d know that the economy API is just a service, which Sponge has many of, so making sure it’s properly registered would be under the Services page.


Unless I can figure out how to make the day longer than 24 hours I won’t have the time to read all the docs, but I tried reading themost important ones, I ended up at implementing the economy API at some point, but a few links to the jd is not what I would expect to be a doc page about providing the economy.

I don’t know why I didn’t read the services page.

Ok I am done with implementing the Economy API. I have a few problems tho, I am using this code to register the service:

public void onPreInit(GamePreInitializationEvent e){
    Sponge.getServiceManager().setProvider(this, EconomyService.class, new EconomyServiceKrist());

But I’m getting this error:

[18:06:25 ERROR] [Sponge]: Could not pass GamePreInitializationEvent$Impl to Plugin{id=coolpay, name=CoolPay, version=1.0, description=An example plugin, source=mods/coolpay-all-1.0-SNAPSHOT.jar}
java.lang.NoClassDefFoundError: me/acul/coolpay/economy/EconomyServiceKrist
at me.acul.coolpay.Coolpay.onPreInit(Coolpay.java:72) ~[Coolpay.class:?]
at org.spongepowered.common.event.listener.GamePreInitializationEventListener_Coolpay_onPreInit5.handle(Unknown Source) ~[?:?]
at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:95) ~[RegisteredListener.class:1.8.9-4.2.0-BETA-350]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:261) [SpongeEventManager.class:1.8.9-4.2.0-BETA-350]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:274) [SpongeEventManager.class:1.8.9-4.2.0-BETA-350]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:278) [SpongeEventManager.class:1.8.9-4.2.0-BETA-350]
at org.spongepowered.common.SpongeImpl.postState(SpongeImpl.java:185) [SpongeImpl.class:1.8.9-4.2.0-BETA-350]
at org.spongepowered.server.SpongeVanilla.preInitialize(SpongeVanilla.java:147) [SpongeVanilla.class:1.8.9-4.2.0-BETA-350]
at net.minecraft.server.dedicated.DedicatedServer.handler$onServerLoad$0(SourceFile:60) [ko.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(SourceFile:98) [ko.class:?]
at net.minecraft.server.MinecraftServer.run(SourceFile:421) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_71]
Caused by: java.lang.ClassNotFoundException: me.acul.coolpay.economy.EconomyServiceKrist
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_71]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_71]
... 12 more
Caused by: java.lang.NullPointerException
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ~[launchwrapper-1.12.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_71]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_71]
... 12 more

The class is imported and exists and I have no idea what I’m doing wrong tbh

Can you post your full fml-server-latest.log?

It’s here on pastebin:

I’m not really sure what’s causing this. Can you make sure that me.acul.coolpay.economy.EconomyServiceKrist is actually in your jar?

I just checked and found the problem: In my sources it is located at economy.EconomyServiceKrist, while in the compiled jar it is in Economy.EconomyServiceKrist

… how does that even happen? neither Gradle nor IDEs build like that, at least not without updating the references too (and even then only if you’ve explicitly configured it to do that).

I figured it out, the package was originally called “Economy”, after that I build which created the dir Economy, when I refractored it to “economy” gradle reused the dir, regardless of the problem with capital/not capital letters, doing a clean build fixed it.

1 Like