Using Choob with IDEs

Changeset [1022] made it a lot easier to use Choob with your IDE of choice. Specifically, plugins should now be valid Java.

They, however, won't be in their target package, and will all show as in the default package. Note that this means you can see classes in other plugins, which you won't be able to do when they're loaded into the bot (plugins are loaded as plugins.PluginName?.PluginMainClass?, ie. in the PluginName? package). Assuming other plugins are visible via. this method is a terrible idea. Use callAPI instead.

Build paths

Only some folders in the Choob checkout contain valid Java, and some of those need ignore rules inside them.

These can be managed via. Eclipse's "build path" menu option. Right-click a folder in the "Package view", and use "Add to build path" and "Exclude from build path" from the "build path" submenu.

Note that some of these build paths are nested. Eclipse deals nicely when you add, say, /src to the build path, then /src/misc, /src/misc will automatically be added to /src's "ignore" list. Your IDE may not do, or even support, this kind of functionality.

This is necessary because files in /src/misc do not have the package "misc.Foo", just "(default).Foo". This might be fixed eventually.

Paths that will "build"

Paths that need to be excluded:

Debuggers

In Eclipse, you can (kind of) debug plugins.

  1. Change "prefix" in HaxSunPluginManager#L64 to "plugins". This makes the package structure line up with the filesystem, which is always good.
  2. Run the bot and load some plugins.
  3. Refresh the "src" folder (or turn on General -> Workspace -> Refresh automatically, what could possibly go wrong?).
  4. You should have, e.g. plugins.Alias.Alias (and plugins.Alias.AliasObject? etc.) visible. You can breakpoint these as normal.

Caveats:

  • Occasionally refreshing the src folder will try and hot code replace stuff that can't be hot code replaced, and you need to kill the bot.
  • Occasinally local variables won't be available.
    1. Ensure you've got no stopped threads.
    2. Edit the file.(not necessarily any real changes, just add a space)
    3. Save it and wait for it to get hot code replaced
    4. Local variables should now be available.
  • Sometimes, especially after hot code replace (above), plugin loading will break. If this happens, [1157] might print the message below. Sometimes it just doesn't bother. At this point, delete your src/plugins folder and start again, plugin loading won't work at all, even after reloading the bot. I theorise that this might be an Eclipse bug, but, even if it is, it's unlikely anyone is going to care enough to fix it.
    Couldn't create plugins package.  This is probably because your debugger is interfering.  Your plugin probably hasn't been reloaded.
    
    • A better workaround for this is to turn off custom classloading entirely; Eclipse, at least, a) gets very unhappy with it, and b) does all the recompiling for you (with enough refreshes / autorefreshes). Change clazz = around HaxSunPluginManager#L249 to Class.forName(className);