[INACTIVE][DEV] IPC - Inter Plugin Communication

Discussion in 'Inactive/Unsupported Plugins' started by deltahat, Jan 22, 2011.

  1. Offline

    deltahat

    https://github.com/rmichela/IPC

    IPC is a framework for allowing plugins to communicate with each other in a standardized way that does not introduce binary dependencies between plugins. At the moment, IPC supports the following three use cases:

    Publish/Subscribe - A player interacts with an iConomy shop sign wishing to buy some wood. When the user clicks the sign, iConomy dispatches an "iConomyPreSale" event, attaching a context object containing the details of the transaction and the player's Player object. The Towny plugin has registered itself to listen to "iConomyPreSale" events and thus receives the dispatched event. Using the data attached to the event, Towny determines that the player is attempting to buy from a shop sign in a town which she is not a resident. Towny uses the attached Player object to send the player a message regarding a lack of residency and sets the cancelled status of the event to True. After dispatching the event, iConomy looks at the cancelled status of the event object it created and aborts the transaction.

    Remote Procedure Call - DeathShout wants to send a tweet out to the server's twitter feed using TwitterEvents. DeathShout calls into IPC asking for TwitterEvents's implementation of the "Tweet" method and receives an IpcMethod object in return. Using the IpcMethod object, DeathShout remotely invokes the TwitterEvent's tweet method using the IpcMethod's invoke(Object...args) method and passing in the message to be tweeted as a parameter. Unfortunately, the tweet fails inside TwitterEvents and an exception is raised. TwitterEvents returns the exception which is raised by the invoke method called by DeathShout.

    Plugin Extensibility - Every minute, MCStats writes it's statistics data to a number of files and endpoints. Rather than hardcoding each endpoint into the plugin, MCStats asks IPC for an array of IpcMethod objects containing all implementations of the "MCStatsWrite" method exposed by any registered plugin. Three results are returned: a reference to MCStats's own file writer method, a reference to a custom plugin that generates signature images with play stats for adding to forums, and a reference to the Achievements plugin which takes the stats and checks to see if an achievement has been reached. MCStats then iterates over the returned IpcMethod array, invoking each plugin in turn. At no time was MCStats ever configured to access the other plugins directly, nor does it know directly about their existence.

    Right now, IPC is practically undocumented. For the moment, I've created two gist files with code demonstrating the use of IPC. I will continue to update IPC's documentation in the future. Please give me feedback.

    https://gist.github.com/789430
    https://gist.github.com/789432

    -DeltaHat
     
  2. Offline

    barghest

    This looks really interesting. I'd love to hear what someone who can code (since I can't) would say about this - I thought Bukkit kinda had some kind of interplugin thing already?
     
  3. Offline

    Afforess

    For a real live example of Custom Events used in a plugin, grab a copy of Minecart Mania. Minecart Mania Core has 6 custom events that launch -

    Minecart Stopped Moving Event
    Minecart Started Moving Event
    Minecart Time Change Event
    Minecart Intersection Event
    Minecart Action Event
    Chest Powered Event.

    All of the addons for Minecart Mania Core rely on the custom events launched by Minecart Mania core, but theoretically, any plugin developer could write a plugin to send a receive these events.
     
  4. Offline

    EvilSeph

Share This Page