Osmium
Osmium is server API that acts as an abstraction layer for Bukkit and Sponge. This means that any Osmium plugin will run on any Sponge or Bukkit server that has Osmium installed. Which for plugin developers translates to no more having to duplicate all your platform specific code just to support multiple API’s
Osmium is mainly intended to be used for simple plugins in order to target multiple platforms. The focus right now is more so about making it extremely easy to complete common tasks than it is to implement a fully fledged Minecraft API.
This project is completely different from Pore which allowed Bukkit plugins to run on Sponge. With Osmium, plugin developers write code for the Osmium API (different than Bukkit and Sponge) and then when their plugin is compiled, Osmium generates necessary files to make it load and run as if it were a native Sponge or Bukkit plugin.
Osmium also makes it extremely easy to switch to a specific platform if necessary. For many tasks, plugin developers can simply use
if (Platform.isSponge()){
//Sponge specific code
} else if(Platform.isBukkit(){
//Bukkit specific code
}
Main Goals:
- Extremely concise and intuitive API
- Portability: Any Osmium plugin should work on Bukkit or Sponge servers
- Consistency across server platforms
Some Cool Features
Automatic registration of event listeners
@Listener
public void on(PlayerTeleportEvent e) {
//This is all you need for this event to be called. No listener registration
}
Schedule entire methods
@Schedule(async = true, interval = 3, unit = TimeUnit.MINUTE)
public void update() throws IOException {
//This is an async task
}
Save data easily
@Persistent
public static int maxLikes = 0; //This field will be the same across server restarts. Zero is the default value
Automatic registration of commands. Also amazing command API (in progress)
@CommandProperties(aliases = { "test"}, usage = "test <run/info> {player}", admin = true, console = true) //Commands are player-only by default
public class TestCommand extends Command {
@Override
public void configure() {
add("info").setExecutor((e) -> {
e.sendTitle("&aThis is a secret message for admins");
});
add("run").setExecutor((e) -> {
e.getPlayer(0).sendMessage("You have been tested");
});
}
}
Configurations
@Configuration(path = "plugin.conf", header = "Here is the config file for my awesome plugin!")
public class Config {
@Setting(comment = "Set to true to enable debug level logging")
public static boolean debug = false;
public static class Database {
@Setting(comment = "Set to true to store plugin data in a MySQL database instead of SQLite")
public static boolean enableMysql = false;
@Setting(comment = "The address to access the database")
public static String host = "";
...
}
}
Project Details
DISCLAIMER: Osmium is not in a usable state at the moment but feel free to experiment with it if you would like. I’m only posting it here for some feedback and because I intend to be releasing a few plugins which use the API. Any suggestions or constructive criticism would be appreciated
GitHub: GitHub - kmecpp/Osmium: Abstraction layer for Sponge and Bukkit that allows for development on both platforms simultaneously.
CI Server: http://ci.kmecpp.com
Discord: https://discord.gg/jBjYckt