Learn how to create custom options with OneConfig.
Creating an option
First you have to create an option, to do this create a class that extends the BasicOption class and implement all methods.
public class MyOption extends BasicOption {
public MyOption(Field field, Object parent, String name, String category, String subcategory, int size) {
super(field, parent, name, category, subcategory, size);
}
@Override
public void draw(long vg, int x, int y) {
// draw everything here
}
@Override
public int getHeight() {
return 32; // return the height of the option so other options can be placed accordingly
}
}
Basic usage
The easiest way to use a custom option is to annotate the field CustomOption annotation and specify an id.
@CustomOption(id = "myOption")
public static boolean yes = true;
Then too add your option to the config system you have to overwrite the getCustomOption method in the config, add the option to the page using ConfigUtils and then return the option. Here is an example implementation: