Creating an Addon

Setting up your project

  1. 1.
    create a new project in your IDE
  2. 2.
    import the spigot.jar and the UltimateFactions.jar as libaries

Main Class

It is important that your main class extends the FactionAddon class. After extending the FactionAddon class you can auto-import the onEnable methods.
1
import de.miinoo.factions.addon.AddonRegistry;
2
import de.miinoo.factions.addon.FactionsAddon;
3
​
4
public class ExampleAddon extends FactionsAddon {
5
​
6
public ExampleAddon () {
7
super("MyFirstAddon"); // Name of the Addon
8
}
9
​
10
@Override
11
public void onEnable(AddonRegistry registry) {
12
// load while the main plugin is being loaded
13
}
14
​
15
@Override
16
public void onPostEnable(AddonRegistry registry) {
17
// load after the main plugin is loaded completely
18
// register commands and listener
19
}
20
​
21
}
Copied!

Listener

Now you can start coding like a normal plugin. Here you can find a list of the events of UltimateFactions.
1
public class ExampleListener implements Listener {
2
​
3
@EventHandler
4
public void onEnter(FactionTerritoryEnterEvent event) {
5
Player player = event.getPlayer();
6
Faction faction = event.getFaction();
7
player.sendMessage("Β§aEntered territory of: Β§e" + faction.getName());
8
}
9
}
Copied!
After creating the listener don't forget to add it to your onPostEnable(); method in your main class.
1
@Override
2
public void onPostEnable(AddonRegistry registry) {
3
// load after the main plugin is loaded completely
4
// register commands and listener
5
registry.registerEvents(new ExampleListener());
6
}
Copied!
Last modified 9mo ago