Introduction

JavaOp2 is completely plugin oriented. Just about anything imaginable can be done with a plugin. Just about everything you see and use while using JavaOp2 is done by a plugin. Plugins are allowed to see, filter, and respond to packets, events, commands, errors, and more.

What software do I need?

The main software you need is the Java SDK. SDK means Software Development Kit. You need to have Java's SDK to do any kind of Java development. It can be downloaded from java.sun.com. I would recommend getting the 1.4.2 J2SE version, because that's what I use.

I strongly recommend you get the Eclipse editor. All the examples I'm giving will require Eclipse. It can be downloaded from Eclipse.org

How to get a copy of JavaOp2 source

You can get JavaOp2's source various ways:

Creating a project

  1. Create a new project.
  2. Make the project depend on javaop2_pub
  3. Create a new class called PluginMain, which extends GenericPluginInterface, and implements other interfaces that you want your plugin to be able to handle. See below for a list of the interfaces and what they do
  4. Fill in PluginMain with the appropriate information.
  5. When you're ready to test it, you need to generate a .jar file. This is a little tricky in Eclipse, so I'll post some screenshots.

The interfaces

When a plugin is written, the PluginMain class has to implement GenericPluginInterface, which identifies it as a plugin and lets JavaOp2's Core glean important information about it (author, version, etc.). However, if you want to be able to do anything useful, you have to implement other interfaces, which are listed below. Note that implementing one of these interfaces isn't sufficient to get notifications when the event occurs -- you also have to register the plugin. See the next section for that.

When you set up your bot, you tell Eclipse which of these interfaces you want to use. Each one is basically a series of functions that your plugin is forced to implement. These functions will be added automatically, ready for you to fill out. Remember, though, that in functions that require a return value, returning "null" or "false" will generally cancel the packet/event/whatever, and it won't go through, so make sure to actually implement them.

Registering Plugins

In the plugin's activate() function, you're passed a variable called "PluginCallbackRegister register". This is what your plugin uses to register itself to receive notifications. You generally call register.registerXXXX(this, ...., null);. The actual parameters depend on which plugin. The last value is called "data", and is passed to your plugin whenever your plugin is called. It's not terribly useful, so I generally set it to null.

You can get a current list of registration functions from here. The comments provided above each function should suffice for documentation.

Public functions

When a plugin is activated, it's given an instance of PublicExposedFunctions called "out". The plugin can use "out" to communicate with other parts of the bot or with battle.net. "out" has a very large number of functions, but they're all commented and it should be clear what they do.

Examples

I haven't written any step-by-step examples, but I'll put links to a couple of my plugins here for now.

Advice/Comments

This is a faq-ish style section where I put any tidbits or random thoughts, as I think of them. As such, it'll probably grow on a regular basis, so check back often.


Valid HTML 4.01! Valid CSS!