Plugin Code
1: package org.example; 2: 3: import java.awt.event.ActionEvent; 4: import javax.swing.AbstractAction; 5: 6: import org.jempeg.music.manager.EmplodeContext; 7: import org.jempeg.music.manager.plugins.AbstractJEmplodePlugin; 8: 9: public class TestPlugin extends AbstractAction implements JEmplodePlugin { 10: private EmplodeContext myContext; 11: 12: public TestPlugin(EmplodeContext _context) { 13: myContext = _context; 14: } 15: 16: public void actionPerformed(ActionEvent _event) { 17: System.out.println("Total Free Space: " + myContext.getPlayerDatabase().getTotalFree()); 18: } 19: }Line 9: you need to be a Swing action and implement the JEmplodePlugin interface (basically just a marker interface).
Line 12: If you need an EmplodeContext (i.e. you need access to the PlayerDatabase, etc) then your constructor can optionally take an EmplodeContext and jEmplode will construct you with it.
Line 16: actionPerformed is called when the user clicks on your menu item
Line 17: In this example, TestPlugin just prints the total free space out on the console. From an EmplodeContext, you can get access to the current state of jEmplode (PlayerDatabase, ISynchronizeClient, etc).
To compile this class, you should be able to put jemplode.jar in your classpath. I'll publish javadoc later.
Plugin Manifest
Plugins have to be in a jar file. In the "root directory" of the jar, jEmplode will look for files of the format [yourjarfilename]-1.jmp, [yourjarfilename]-2.jmp, etc. For instance, if your jar file is named "example.jar", it will look for "example-1.jmp", "example-2.jmp", etc. Each -1, or -2 manifest file corresponds to an entry on the Plugins menu in jEmplode. Note that if you only have one action, you still need to name it "jarname-1.jmp" (with the "-1"). The contents of the jmp files are Java Properties format:
Action-Class=org.example.TestPlugin Name=Test Plugin 1 Text=Test Plugin 1 Mnemonic=typed T Accelerator=ctrl T Icon=
Action-Class defines the class name of your JEmplodePlugin implementation. This is the class that will be attached to the menu item.
Name defines the internal name of the plugin.
Text defines the text that will appear on the menu item button
Mnemonic defines the letter that will be underlined on the menu item as the quick way to select your item (this is in java's KeyStroke
format)
Accelerator defines the accelerator for your plugin (KeyStroke format also)
Icon defines the jar resource path to the icon for your plugin
Putting it Together
example.jar org example TestPlugin.class example-1.jmp
This jar file needs to be placed into the "plugins" folder in the jEmplode directory. After that, it should be loaded at startup and attached to the plugins menu.