Sueta
DI

Discussions

2.0.0

Build a discussion and gain insightful user input

·Plugin

This is an API - it is not a plugin. This resource is only useful for developers.

Discussions provides a simplistic and extensible way to present the concept of a "Prompt" to a player and receive their input while maintaining a high level of control over the design and internals of your own code.

Why does this look like Bukkit Conversations?
I started this project as a fork on the ideas of Conversations except that it is not specifically tied to Bukkit in that it is platform independent in the Core API.

Very simple demonstration with 2 MemoPrompts and 1 SetPrompt:

You can download this API's artifacts using Maven, like so:

<dependency>
  <groupId>com.algorithmjunkie.discussions</groupId>
  <artifactId>bukkit</artifactId>
  <version>2.0.0</version>
</dependency>

Or with Gradle:

compile 'com.algorithmjunkie.discussions.bukkit:2.0.0'

You'll also need the Bintray repository to resolve the artifact.

https://dl.bintray.com/simpleauthority/discussions

Here's a simple example of your first Discussion:
First, you'll need a DiscussionController.

class MyDiscussions extends JavaPlugin {
  private DiscussionController controller;

  @Override
  public void onEnable() {
    controller = new DiscussionController(this);
  }
}

After that, you simply need to create your discussion. You have the option of extending BukkitDiscussion, or using the DiscussionBuilder via the controller.

Here's how to do it with the DiscussionBuilder (recommended):

class MyDiscussions extends JavaPlugin {
  private DiscussionController controller;

  @Override
  public void onEnable() {
    controller = new DiscussionController(this);
  }

  @Override
  public void onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) return false;

    Discussion discussion = controller.createDiscussion()
      .startingWith(new SomePromptClass())
      .withModality(true)
      .withEcho(false)
      .build();
}

SomePromptClass() is figurative in the above example, in that it will represent your Discussion's first Prompt.

Once you have created your discussion, you simply need to start it for any BukkitDiscussionUser (a simple wrapper of Player that allows Discussions to operate across different platforms.)

class MyDiscussions extends JavaPlugin {
  private DiscussionController controller;

  @Override
  public void onEnable() {
    controller = new DiscussionController(this);
  }

  @Override
  public void onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) return false;
    BukkitDiscussionUser user = new BukkitDiscussionUser((Player) sender);

    Discussion discussion = controller.createDiscussion()
      .startingWith(new SomePromptClass())
      .withModality(true)
      .withEcho(false)
      .build();

    controller.startDiscussion(discussion, user);
}

And that's it. Once startDiscussion is called, you're well on your way to a masterpiece user input collection system.

Check out the Discussions Wiki to learn more about how to implement Discussions into your project.

Similar projects

Plugin →