-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
The first thing you need to do to use EagleFactionsAPI is to depend on it. The easiest way to achieve it is to use Jitpack.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Aquerr</groupId>
<artifactId>EagleFactionsAPI</artifactId>
<version>v1.0.1</version>
</dependency>
</dependencies>
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compileOnly "com.github.Aquerr:EagleFactionsAPI:v1.0.1"
}
Now you are ready to use EagleFactionsAPI in your own project.
Firstly, add the EagleFactions dependency to your plugin instance by specifying it in the @Plugin annotation. It is not required but it is a good practice to do it so that Sponge knows what is needed by your plugin. Add eaglefactions dependency in sponge configuration block in your build.gradle file:
# ...
dependency("eaglefactions") {
loadOrder(PluginDependency.LoadOrder.AFTER) # Load our add-on after eaglefactions
optional(false) # Make the dependency required
version("1.0.1") # Used version of EagleFactions.
}
# ...
After that, you are ready to write some code 😄. So, lets grab EagleFactions instance.
@Listener
public void onConstructPlugin(final ConstructPluginEvent event)
{
this.logger.info("Constructing EagleFactions-Economy...");
// Lets get eaglefactions from Sponge's Plugin Manager
// This should return eaglefactions container because we set up loading order in our Gradle build script.
PluginContainer efPluginContainer = event.game().pluginManager().plugin("eaglefactions").orElse(null);
if (efPluginContainer == null)
{
this.logger.error("EagleFactions not detected");
disablePlugin();
return;
}
// Now lets retrieve Eagle Factions instance from PluginContainer
this.eagleFactions = (EagleFactions) efPluginContainer.instance();
// Now you can do something with EF like getting all factions and so on
Map<String, Faction> factions = this.eaglefactions.getFactionLogic().getFactions();
// You can also ask Sponge for EagleFactions services instead of getting an instance of EagleFactions.
this.factionLogic = Sponge.game().serviceProvider().provide(FactionLogic.class).orElse(null);
this.powerManager = Sponge.game().serviceProvider().provide(PowerManager.class).orElse(null);
}
Now when you have EagleFactions
instance in your code, you can play with it as you want. Javadocs should be self-explanatory. 😄
Want to see an example plugin that is using EagleFactionsAPI? Take a look at EagleFactions-Economy.
- Open an issue here on Github if you want to report a bug or suggest an enhancement
- Write to me on Spongepowered Forum
- Join my Discord server and contact me there