Skip to content
Mark Hughes edited this page Oct 9, 2017 · 16 revisions

The LegacyFactions API is always undergoing improvements. Hopefully this documentation will help you understand how it works!

These docs are still "under construction" but is done on a best effort basis. If you need help feel free to open an issue ticket asking for help.

Build Tools (Gradle, or Maven?)

Use Gradle or Maven? Read this article.

Detecting LegacyFactions

Unlike other forks, the plugin name and package has been changed. So you can detect LegacyFactions like so:

if (Bukkit.getPluginManager().isPluginEnabled("LegacyFactions")) {
    // Woo! The plugin class is also net.redstoneore.legacyfactions.Factions
    // There is a singleton you can grab with Factions.get()
}

Make sure you depend or softdepend on LegacyFactions.

Entity Classes

Events (docs coming soon)

  • EventFactionsChange
  • EventFactionsCreate
  • EventFactionsDisband
  • EventFactionsLandChange
  • EventFactionsNameChange
  • EventFactionsPowerLoss
  • EventFactionsRelation
  • EventFactionsRelationChange
  • EventFactionsWarpCreate
  • EventFactionsWarpDelete

Good practices

When developing there are a few things you should try to do to avoid breaking LegacyFactions or interrupting other plugins.

Read the docs!

The docs are here so we don't have to answer the same questions repeatedly.

Ensure LegacyFactions is enabled before you hook into it!

Using the previous example, you should ensure LegacyFactions is enabled before you hook into it:

if (Bukkit.getPluginManager().isPluginEnabled("LegacyFactions")) {
    this.legacyFactionsEnabled = true;
    LegacyFactionsFeatures.get().enable();
}

Don't store collections! Always use the methods available.

You really shouldn't be storing or modify the results of FactionColl.all() - if you need to fetch a Faction later use FactionColl.get(faction name/id)

Any Collections/Lists/Sets should be considered a snapshot of the current state. Meaning the moment you fetch it, they are technically outdated. You shouldn't modify them as most of the time they won't make changes to the model.

Don't use deprecated methods!

Deprecated methods will be removed from LegacyFactions at some point (and we are keen to remove them as soon as we can!) so please use new methods. The information is in the JavaDoc.

Store faction IDs not names

Faction names can change. Faction IDs can not! So if you need to remember a faction for later, use the faction id.