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.
GuildsAPI api =Guilds.getApi();
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.
Using OfflinePlayer
/** * Get the guild of a player * @param player the players you're getting the guild of * @return the guild that the player is in */publicGuildgetGuild(@NotNullOfflinePlayer player) {returnguildHandler.getGuild(player); }
Using Guild UUID
/** * Get a guild by it's uuid * @param uuid uuid of the guild * @return the guild the uuid belong to */publicGuildgetGuild(@NotNullUUID uuid) {returnguildHandler.getGuild(uuid); }
Using Player name
/** * Get a guild by it's name * @param name the name of the guild * @return the guild object */publicGuildgetGuild(@NotNullString name) {returnguildHandler.getGuild(name); }
Getting a Guild Vault
/** * Get a copy of one of a guild's vaults * @param guild the guild to get the vault of * @param vaultNumber which vault to get * @return guild vault */publicInventorygetGuildVault(@NotNullGuild guild,int vaultNumber) {returnguildHandler.getGuildVault(guild, vaultNumber); }
Getting a GuildRole
/** * Get the role of a player * @param player role * @return the role of a player */publicGuildRolegetGuildRole(@NotNullPlayer player) {returngetGuild(player).getMember(player.getUniqueId()).getRole(); }
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.
/** * Get a copy of the guild handler * @return guild handler */publicGuildHandlergetGuildHandler() {return guildHandler; }
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
/** * Base guild event * @param player player in event * @param guild guild in the event */publicGuildEvent(Player player,Guild guild) { super(player);this.guild= guild; }
GuildAddAllyEvent
/** * This event takes place when two guilds ally each other * @param player player who accepted * @param guild guild one * @param ally guild two */publicGuildAddAllyEvent(Player player,Guild guild,Guild ally) { super(player, guild);this.ally= ally; }
GuildCreateEvent
/** * Called when people create a guild * @param player player creating the guild * @param guild the guild being created */publicGuildCreateEvent(Player player,Guild guild) { super(player, guild); }
GuildDepositMoneyEvent
/** * Base guild event * @param player player in event * @param guild guild in the event * @param amount the amount to deposit */publicGuildDepositMoneyEvent(Player player,Guild guild,double amount) { super(player, guild);this.amount= amount; }
GuildInviteEvent
/** * Called when a player gets invited to a guild * @param player the player inviting other to guild * @param guild the guild player will be joining * @param invitedPlayer the player being invited */publicGuildInviteEvent(Player player,Guild guild,Player invitedPlayer) { super(player, guild);this.invitedPlayer= invitedPlayer; }
GuildJoinEvent
/** * Called when a player joins a guild * @param player the player joining a guild * @param guild the guild the player will be joining */publicGuildJoinEvent(Player player,Guild guild) { super(player, guild); }
GuildLeaveEvent
/** * Called a when a player leaves the guild * @param player the player leaving the guild * @param guild the guild the player was leaving * @param cause the reason the event was called */publicGuildLeaveEvent(Player player,Guild guild,Cause cause) { super(player, guild);this.cause= cause; }publicenumCause { PLAYER_LEFT, PLAYER_KICKED, ADMIN_REMOVED }
GuildPrefixEvent
privateString prefix; /** * Base guild event * @param player player in event * @param guild guild in the event * @param prefix */publicGuildPrefixEvent(Player player,Guild guild,String prefix) { super(player, guild);this.prefix= prefix; }publicStringgetPrefix() {return prefix; }
GuildRemoveAllyEvent
/** * Called when a guild removes an ally * @param player the player calling the removal * @param guild the guild calling the removal * @param ally the guild being removed */publicGuildRemoveAllyEvent(Player player,Guild guild,Guild ally) { super(player, guild);this.ally= ally; }
GuildRemoveEvent
privateString name; /** * Called when a guild is removed * @param player the player removing the guild * @param guild the guild getting removed * @param cause the reason for the guild being removed */publicGuildRemoveEvent(Player player,Guild guild,Cause cause) { super(player, guild);this.cause= cause; }publicenumCause { MASTER_LEFT, PLAYER_DELETED, ADMIN_DELETED }
GuildRenameEvent
/** * @param player player in event * @param guild guild in the event */publicGuildRenameEvent(Player player,Guild guild,String newName) { super(player, guild);this.name= newName; }publicStringgetName() {return name; }
GuildTransferEvent
privatePlayer newMaster; /** * Base guild event * @param player player in event * @param guild guild in the event * @param newMaster */publicGuildTransferEvent(Player player,Guild guild,Player newMaster) { super(player, guild);this.newMaster = newMaster; }publicPlayergetNewMaster() {return newMaster; }
GuildWithdrawMoneyEvent
/** * @param player player in event * @param guild guild in the event * @param amount the amount to withdraw */publicGuildWithdrawMoneyEvent(Player player,Guild guild,double amount) { super(player, guild);this.amount= amount; }