Skip to content

Creating Components

Tonodus edited this page Aug 23, 2014 · 1 revision

Create your own Components

Extend BaseComponent

To create our own fancy Component, we extend BaseComponent. That's easier than implementing the Component interface. So lets create a new class: public class MyComponent extends BaseComponent { @Override public void updateSync() {

    }

    @Override
    public void drawAsync(Graphics2D g) {

    }
}

As you might have seen, the two methods are called on different threads. The updateSync() method is called on the bukkit server thread, so it blocks the whole server, but you can access the full bukkit API.
The drawAsync(...) method is called asynchronous on a differnt thread, so you MUST NOT acces the BukkitAPI. Calling something like Location#getBlock() isn't allowed here. Do this in updateSync()-method!

To be filled

Extending ComponentsContainerComponent

A ComponentsContainerComponent is a Component that display other components. It's generic, so you can easily specify what components may added, removed, etc. See the RadioGroup for an example.

Clone this wiki locally