-2

I have a game written in Java and a whish to write a generic ModLoader/AddonLoader application. A separate application/api that would allow you to create mods/addons for my projects that add extra implementation that I do not want in the main application.

However I am not sure how to go about this, i've done some research and im not too sure how to make the mod/addon interact with a loader which interacts with the main application to add new features/modify old

Many Thanks Elliott

Elliott
  • 17
  • 2
  • Too broad for SO. Give some code and a specific aspect of what you're stuck on. – Susannah Potts Sep 23 '16 at 14:21
  • Dear Elliot, what have you tried - as code - until now? See [good questions on SO](http://stackoverflow.com/help/how-to-ask). – Adrian Colomitchi Sep 23 '16 at 14:22
  • My appologies, im more looking for some guidance of how to start it. I'll attempt to do some more reaseach and get some code written before asking anything again. – Elliott Sep 23 '16 at 14:24

1 Answers1

0

Since you're looking for some basic guidance I'll suggest the following:

You need a way to pull in classes after the core application is running. That means you will need these classes on the classpath. The simplest way to do that is probably to have your classpath include a folder like "addons" so that all the jars in that folder are automatically on your application's classpath.

Once you have your classpath set up you will need to somehow make use of the appropriate class(es). This part is hard to speak generically about because it depends heavily on how you intend your addons to work. Some tools use annotations to help with this and you can probably look at some open source projects for examples. One that comes to mind is Maven, it makes use of annotations in its plugin system. The general concept is that you need to decide how many different kinds of addons you have and how you will identify them and make use of them.

Typically making use of an addon involves instantiating that addon which is why it can be tricky. Some plugin systems require that addons be written such that they use a specific package name. They do this so that they can make use of reflection to find all classes in a given package and then process them.

Hope that helps to get you started!

D.B.
  • 4,523
  • 2
  • 19
  • 39