Skip to content
This repository was archived by the owner on Mar 6, 2021. It is now read-only.

Tutorial: Getting Started!

Aurium_ @ElytraForce edited this page Feb 8, 2021 · 2 revisions

How to set up AUtils for Newbies

First, before you get started, AUtils depends on GUICE. Go add it as a dependency in maven or gradle.

Making the plugin

You'll need to set up your plugin as either a SpigotPlugin (For spigot API like servers, e.g. paper) or a BungeePlugin (For bungee API like servers, e.g. Waterfall or Bungeecord.) Sponge and Velocity implementations of the core are coming soon!

Write your plugin class like you would a normal class, except instead of extending JavaPlugin, extend SpigotPlugin or BungeePlugin. For the sake of this tutorial, we'll assume you're using spigot.

public class PluginTest extends SpigotPlugin {

}

Everything else is identical to JavaPlugin as SpigotPlugin merely extends it. Set up your onEnable methods, but do note that we will be coming back to these!

Making the binder

Next, you need to make a binder, as AUtils depends on one of these to correctly use it's own methods relative to your plugin class.

Implement the methods, allow the constructor to accept your main plugin class. You will need to store this class as a field as well. Finally, in the method configureSpecific(), bind the cached instance of your plugin to the Class, alongside any other GUICE bindings you wish to invoke.

public class BinderTest extends ABinder {
    private PluginTest pluginTest;

    public BinderTest(PluginTest plugin) {
        super(plugin);

        this.pluginTest = plugin;
    }

    @Override
    public void configureSpecific() {
        this.bind(PluginTest.class).toInstance(pluginTest);
    }
}

Activating the binder

Now that your plugin and binder are finished, it is time to invoke the binder.

Do not inject a binder, as GUICE is only active after you invoke the binder.

In your onEnable method, instantiate the binder, create an injector, and then inject members.

@Override
    public void onEnable() {
            new BinderTest(this).createInjector().injectMembers(this);
    }

You are now ready to use AUtils! For more information, read the rest of the tutorials, or take a look at the javadocs and documentation inside each class.

Sidebar

Clone this wiki locally