[Plug-in] Plug-in Central: Common access to plug-in user interface (proposal and implementation)

  • A plug-in which displays a menu of installed (and conforming!) plug-ins to access their GUI in a simple and constant way.


    No need to remember the command(s) of each plug-in! Just the command to call the Central up.


    Version 0.2.0:


    - New to 0.2.0:


    *) Adapted to the latest updates to RWGui.


    -Features:


    *) GUI-only: everything is done via a GUI (of course!).


    *) There is only one chat command (default /pc, but it can be configured in the plug-in settings.properties) which displays, in alphabetical order, a list of all installed plug-ins which conform to a simple API:


    *) The plug-in looked for can be selected with a mouse click and its GUI will be displayed.
    ____________________


    Important - Important - Important - Important:


    In order to work, the plug-in requires the RWGui back-end plug-in ver. 0.5.0 available in this thread.
    ____________________


    - Commands


    There is only one command: /pc (configurable in the plug-in settings.properties) which shows the above main menu.


    Installation


    *) Extract the files in the ZIP placing the whole plugincentral folder into the plugins folder of RW (if the plugins folder does not exist, just create one). The resulting hierarchy shall be:


    Code
    ── RisingWorld
    ├── plugins
    │ ├── plugincentral
    │ │ ├── locale
    │ │ ├── plugincentral.jar
    │ │ └── settings. properties


    *) If it is not already installed, the GUI plug-in available in this thread shall also be installed.


    Making my plug-in to appear in Plug-in Central list


    Only two rather simple methods have to be added to a plug-in to make it compatible the Plug-in Central:


    public String getPublicName() which returns a (constant) string with a human readable name for your plug-in.


    public void mainGui(Player player) which displays the main entry point for your plug-in to player (in practice, this method does what your plug-in already does in response to some specific player command).


    Sample code to add to a plug-in to conform to the proposal:


    The existing chat command to access the plug-in can remain and use the same code:

    Code
    @EventMethod
    public void onPlayerCommand(PlayerCommandEvent event)
    {
    String[] cmd = event.getCommand().split(" ");
    if (cmd[0].equals("/myPluginCommand") )
    mainGui(event.getPlayer());
    }


    Notes:
    *) The code does not require any additional logic to be implemented in the plug-in (it should already have code to display some kind of user interface to the player)


    *) It is not necessary to remove anything from existing plug-ins: all existing features can remain and work as previously.


    *) It is not necessarily limited to GUI-based plug-ins; also chat-based plug-ins can benefit from it: there is no limitation on what the main user interface method can do, each plug-in decides: it might be a super-dooper completely GUI panel, it might be just a summary of chat commands in the chat itself or anything in between.


    If anybody has ideas for improvement, please post them here!


    Open points and known issues


    *) None at the moment, but bugs may well exist! I did my best but foreseeing all the possible use cases and contexts is hard. Post here bug reports, with specific steps to replicate the issues and I'll try to correct them.


    I really need steps or instructions to replicate the problem on my PC or I cannot fix it!

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!