Developer API
Build Tool Stuff
<repository>
<id>glares-repo</id>
<url>https://repo.glaremasters.me/repository/public/</url>
</repository>
<dependency>
<groupId>me.glaremasters</groupId>
<artifactId>guilds</artifactId>
<version>VERSION</version>
</dependency>repositories {
maven {
url = 'https://repo.glaremasters.me/repository/public/'
}
}
dependencies {
compileOnly 'me.glaremasters:guilds:VERSION'
}repositories {
maven("https://repo.glaremasters.me/repository/public/")
}
dependencies {
compileOnly("me.glaremasters:guilds:VERSION")
}Hooking Into the API
Obtaining the instance of the API is pretty simple by using the singleton that provides static access to the class. You can obtain the instance of the API through the main Guilds class.
The API object is only created at the very end of the plugin's startup. getApi() returns null for most of that window, so null-check it before you use it if your plugin might load early.
Packages
Everything you need is under me.glaremasters.guilds.api. There are two sub-packages worth knowing about:
me.glaremasters.guilds.api
GuildsAPI, the entry point
me.glaremasters.guilds.api.events
Most events
me.glaremasters.guilds.api.events.base
GuildEvent, which all the others extend
me.glaremasters.guilds.api.events.challenges
The guild war events
Supporting types live outside that package: Guild, GuildMember, GuildRole, GuildTier and GuildHandler are all in me.glaremasters.guilds.guild, and GuildBuff is in me.glaremasters.guilds.conf.objects.
Using the API
The API can be used for obtaining a bunch of information from the plugin. You can browse over the following section to see what all is provided.
Getting a Guild object
We provide a few ways to obtain a Guild object, so feel free to use what is easiest for you.
Getting a GuildMember object
Getting a Guild Vault
Getting a GuildRole
Getting the GuildHandler
The GuildHandler will give you access to anything you might need in the plugin. Please use caution with this method as the content it lets you access to can break the plugin if you use it incorrectly.
Getting the CooldownHandler
The CooldownHandler holds the command cooldowns for every guild. It is exposed on the same API instance.
Custom Events
In the plugin we offer a bunch of custom events that you can listen to and modify as you see fit.
Base GuildEvent
GuildEvent lives in me.glaremasters.guilds.api.events.base and every guild event below extends it. It extends Bukkit's PlayerEvent, so getPlayer() comes for free.
Every GuildEvent implements Cancellable. Calling setCancelled(true) in your listener stops the action the event was fired for.
GuildAddAllyEvent
GuildBuffEvent
The buff on this event is mutable, so a listener can replace it with setBuff(GuildBuff) before the purchase is processed.
GuildCreateEvent
GuildDepositMoneyEvent
GuildInviteEvent
GuildJoinEvent
GuildLeaveEvent
GuildKickEvent
GuildPrefixEvent
GuildRemoveAllyEvent
GuildRemoveEvent
The Cause enum is a nested type, so from Java you reference it as GuildRemoveEvent.Cause.
GuildRenameEvent
GuildSetHomeEvent
GuildTransferEvent
newMaster is an OfflinePlayer, so check isOnline() before assuming you have a Player instance.
GuildWithdrawMoneyEvent
GuildUpgradeEvent
GuildWarAcceptEvent
getGuild() returns the defending guild here, since this event is fired from the accepting side.
GuildWarChallengeEvent
GuildWarDeclineEvent
GuildWarEndEvent
GuildWarStartEvent
GuildWarPlayerJoinEvent
This one fires when a player joins a war, not when the war is set up. It extends Bukkit's Event directly rather than GuildEvent, so it is not cancellable.
Last updated
Was this helpful?