Author Topic: Plugin Packages  (Read 7196 times)

0 Members and 1 Guest are viewing this topic.

Offline Lance

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Plugin Packages
« on: February 17, 2010, 11:07:30 pm »
The Simple Event Processor, Command, and Channel List plugins are useless without the Battle.net Login one, so why have four plugin files instead of one? The 4-file dilemma is what led me to making this suggestion to create a package-type plugin system. The Simple Event Processor and Channel List plugins have no packages and one class! Surely, the overhead that comes with loading them is not worth it.

One jar (Bnet.jar) would contain the src/plugins package:
-src.plugins.Main (this is not a folder, but a class to retrieve a list of plugins, provide access to PublicExposedFunctions, provide activate(), deactivate(), and load(); and provide an interface to extend)
-src.plugins.LoginProcessor (Formerly BNetLogin.jar)
-src.plugins.SimpleEventProcessor
-src.plugins.Commands
-src.plugins.Channel List

Also, parts of the product could still be disabled individually (like Commands).

This will most likely require a massive rewriting of the bot, but it is just an idea anyway... for now :)

Thanks for reading! :)
« Last Edit: February 19, 2010, 09:28:02 pm by Lance »
Quote from: Joe
[23:55:31] [william@enterprise ~/Documents/Programming/javaop2]$ svn commit -m 'Tried to fix StayConnected. Again.'
Committed revision 63.
StayConnected strikes back!

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Plugin Packages
« Reply #1 on: February 18, 2010, 01:48:47 am »
I think you'll enjoy the plugin restructuring in 2.1.3.

If I understand how it works correctly, there's not a lot of overhead except for having to do four times the work when the bot first starts. This adds maybe a few milliseconds to the loading process, really nothing to lose sleep over. Once loaded, they're all added to the bot's memory in the same way they would be if they're in one jar (albeit, perhaps in a different place) and should function at the same speed.

Currently I don't think you can expose more than one plugin per jar, so it'd be difficult to implement the idea without a major rewriting of the plugin loading process, unless they were all combined into one plugin with all their functionality.

I think that commands should definitely stay separate, because eventually (read: in year 2035), I'd like to add IRC to JavaOp, which would need to interact with the commands just as much as Bnet would. Also, Battle.net 2.0 would have it's own login plugin.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Lance

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Plugin Packages
« Reply #2 on: February 24, 2010, 09:01:22 pm »
I think you'll enjoy the plugin restructuring in 2.1.3.

If I understand how it works correctly, there's not a lot of overhead except for having to do four times the work when the bot first starts. This adds maybe a few milliseconds to the loading process, really nothing to lose sleep over. Once loaded, they're all added to the bot's memory in the same way they would be if they're in one jar (albeit, perhaps in a different place) and should function at the same speed.

Currently I don't think you can expose more than one plugin per jar, so it'd be difficult to implement the idea without a major rewriting of the plugin loading process, unless they were all combined into one plugin with all their functionality.

I think that commands should definitely stay separate, because eventually (read: in year 2035), I'd like to add IRC to JavaOp, which would need to interact with the commands just as much as Bnet would. Also, Battle.net 2.0 would have it's own login plugin.

I cannot get my custom plugin to work even after the namespace "com.javaop.*" changes I made to the packages :<

I took a look at the commands plugin and discovered it is not protocol-specific; sorry I used it as an example in my previous post.
Quote from: Joe
[23:55:31] [william@enterprise ~/Documents/Programming/javaop2]$ svn commit -m 'Tried to fix StayConnected. Again.'
Committed revision 63.
StayConnected strikes back!

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Plugin Packages
« Reply #3 on: February 24, 2010, 10:26:18 pm »
I cannot get my custom plugin to work even after the namespace "com.javaop.*" changes I made to the packages :<

I took a look at the commands plugin and discovered it is not protocol-specific; sorry I used it as an example in my previous post.

Open up build.xml. Under the clean section, add
Code: [Select]
<delete dir="YourPluginsName/bin"/
Under build, add
Code: [Select]
<mkdir dir="YourPluginsName/bin"/>
<javac srcdir="YourPluginsName/src" destdir="YourPluginsName/bin"
classpath="javaop2/bin"/>

Under jar, add
Code: [Select]
<jar destfile="${pluginpath}/YourPluginsName.jar" basedir="YourPluginsName/bin">
<manifest><attribute name="Main-Class" value="com.javaop.YourPluginsName.YourPluginsEntryPoint"/></manifest>
</jar>

..replacing the obvious. That should get your plugin to build with the rest of the bot just by typing ant.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Lance

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Plugin Packages
« Reply #4 on: February 25, 2010, 08:50:13 am »
I cannot get my custom plugin to work even after the namespace "com.javaop.*" changes I made to the packages :<

I took a look at the commands plugin and discovered it is not protocol-specific; sorry I used it as an example in my previous post.

Open up build.xml. Under the clean section, add
Code: [Select]
<delete dir="YourPluginsName/bin"/
Under build, add
Code: [Select]
<mkdir dir="YourPluginsName/bin"/>
<javac srcdir="YourPluginsName/src" destdir="YourPluginsName/bin"
classpath="javaop2/bin"/>

Under jar, add
Code: [Select]
<jar destfile="${pluginpath}/YourPluginsName.jar" basedir="YourPluginsName/bin">
<manifest><attribute name="Main-Class" value="com.javaop.YourPluginsName.YourPluginsEntryPoint"/></manifest>
</jar>

..replacing the obvious. That should get your plugin to build with the rest of the bot just by typing ant.

What if I just want to use eclipse, though? :'(

EDIT: Just had to make the manifest manually and not export source and project files (.classpath, .project) :D It works! :)
« Last Edit: February 25, 2010, 09:07:28 am by Lance »
Quote from: Joe
[23:55:31] [william@enterprise ~/Documents/Programming/javaop2]$ svn commit -m 'Tried to fix StayConnected. Again.'
Committed revision 63.
StayConnected strikes back!

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Plugin Packages
« Reply #5 on: February 25, 2010, 01:50:11 pm »
Excellent! If you'd like, feel free to post a guide on the GoogleCode wiki.

I've quit using Eclipse. It's pretty bulky for my needs.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Lance

  • Full Member
  • ***
  • Posts: 129
    • View Profile
Re: Plugin Packages
« Reply #6 on: February 25, 2010, 02:07:29 pm »
Excellent! If you'd like, feel free to post a guide on the GoogleCode wiki.

I've quit using Eclipse. It's pretty bulky for my needs.
PM'd :)
Quote from: Joe
[23:55:31] [william@enterprise ~/Documents/Programming/javaop2]$ svn commit -m 'Tried to fix StayConnected. Again.'
Committed revision 63.
StayConnected strikes back!