One plugin supporting both SpigotMC and Sponge

Im currently maintaining MobHunting for SpigotMC, and I would like support both SpigotMC and Sponge without too much redundant work. So I would like add needed code in MobHunting so it can run on a Sponge/Forge server. I have seen some plugins working this way (ex. CraftConomy) but I dont understand how to write the main class, since Spigot Plugins extends JavaPlugin:

public class MobHunting extends JavaPlugin

and Sponge does it another way?

@Plugin(id = “example”, name = “Example Project”, version = “1.0”)
public class ExampleProject

I dont understand how to make one plugin supporting both servers?

I think I need to devide the plugin in three part.

  • Spigot related code
  • Sponge related code
  • Shared code

But how do I actually do this, could someone maybe give me a hits or an example?

You could make most of your existing classes into interfaces/abstract classes, and implement both using each implementation

1 Like

VoxelSniper does exactly this already, granted, VoxelGunsmith is the base API for VoxelSniper, but the idea is the same.