So you want to write a plugin. First you will need the right tools. Java comes in a few ‘flavours’ – JRE (Java Run-time Environment), JEE (Java Enterprise Edition), and JDK (Java Development Kit). We won’t go into what these are as that is beyond the scope (or need) of our plugin adventure. What we need is JDK version 8. You can download it here.

Do not be tempted to use a newer version of Java like v9 or v10. They don’t work (yet) with NetBeans nor does Rising World support anything higher than v8 on the server side.

Once you’ve installed the JDK you will be able to write and compile Java code (but not very easily). What you really need now is an Integrated Development Environment (fancy talk for a program designed to assist you in writing code). I learned on Eclipse – it’s great. But when I started to write MR I decided to try out NetBeans. NetBeans now, in my opinion, is better – so that’s what we’re going to use moving forwards.

So you’ve got NetBeans and the JDK installed? Great. Time to cook up some code! We’ll not quite. First we need to do a little more setting up so our IDE knows about the Rising World API (Application Programming Interface). Don’t worry about what API means, just think of it as your bridge to get your code to talk to Rising World’s code.

Head over to the RW Plugin Discussion forums. (I can’t provide you a concrete download link as it changes with each API update 🙁 ). Following the link jump into the topmost thread which will be named something similar to API Changelog 0.9.x. Scroll down to the bottom of Red51’s post and you’ll find a link similar to `Latest Download: download.rising-world.net/api/PluginAPI_0.9.x.zip`. Click on it. Download it. Extract it. Inside you’ll find two files. The API file and the associated Javadoc.

Create a directory structure to suit you. I’m going for but feel free to plonk these files anywhere you want.

  • C:\Java\RisingWorld\API\PluginAPI.jar
  • C:\Java\RisingWorld\Javadoc\javadoc.zip

Go ahead now and fire up NetBeans. Then start our new Plugin project with;

File > New Project… then Java > Java Application > Next

Give your project a name “RisingWorldShutdown”, set the Project Location to C:\Java\RisingWorld\ (you’ll see the Project Folder is now C:\Java\RisingWorld\RisingWorldShutdown)

Leave Create Main Class checked (or check it if it isn’t – but it should already be checked). Then Finish.

Next, expand your newly created project tree and right click on your Source Packages directory > New > Folder… > name this new directory “resources” > then click Finish

Now, right click on your newly created resources directory and select > new > Other…   Under the categories panel select Other > File Types: and then select YAML File > Next > enter the name as plugin (this is case sensitive – Plugin is not the same as plugin – and the YAML extension will be added for you. Now click > Finish 

Soup-er. we’ve not got our structure ready. Let’s now flesh out our new plugin.yml file. So let’s enter the following text into plugin.yml – make any changes to match your plugin name.


name: MedievalRealms
main: risingworldshutdown.RisingWorldShutdown
version: 0.0.1
author: Yahwho
team: Team Medieval
description: "Medieval Realms Server Shutdown Plugin"
license: GNU GPLv3
website: https://medievalrealms.co.uk

Add the API and Javadoc

Woop, we’re really cooking on gas here. Now let’s turn up the dial and add the bone stock to liven up our code soup.

Right click on your project name (RisingWorldShutdown) > Properties, under Categories on the left hand panel click on Libraries > Compile Tab > Add Jar/Folder..  Locate your PluginAPI.jar file (remember here it’s C:\Java\RisingWorld\API\PluginAPI.jar) > Open.


Great so far. We just need to add the Rising World Javadoc to aid us with our coding sanity and sweeten up our broth. So go to NetBeans main menu and;

Tools > Java Platforms > Javadoc tab > Add ZIP/Folder and located our javadoc.zip file (remember we put it in C:\Java\RisingWorld\Javadoc\javadoc.zip) > Click Add ZIP/Folder > then Close

Awesome, we’re all setup and cooking on gas. Time to grab a brew and congratulate yourself.

Now, open up your newly main class – in this case RisingWorldShutdown.java and it should look a little like this:


package risingworldshutdown;

public class RisingWorldShutdown {

public static void main(String[] args) {


}

}

The soups stock is close to being ready. We just need now to extend our class from the Plugin class, add a few vegetable imports and, implement a couple of wholesome methods. We can fish out that that main method too – it doesn’t taste very nice.


package risingworldshutdown;

import net.risingworld.api.Plugin;
public class RisingWorldShutdown extends Plugin {

 @Override
 public void onEnable() { }

 @Override
 public void onDisable() { }

}

That my friend is now a fully functional Rising World Plugin. If not a little lacklustre as it actually does bugger all – but at least it doesn’t break anything. And that’s important. 😉

This is now where the fun really starts. We’ll advance further with our code cooking in the next article.