Developer API - ahmtvc/AquaCoreAPI GitHub Wiki

AquaCore has its own public API for all the developers out there. Here you have an explanation on how to use the API and easily get AquaCore info into your plugin. Most of the methods in API are read-only.

Usage guide

Design

Adding Dependency

To add AquaCoreAPI dependency simply download the jar here and than add it your IDEA project dependencies. When the plugin is enabled, an instance of AquaCoreAPI can be obtained statically from the AquaCoreAPI class. (ex: AquaCoreAPI.INSTANCE)

Grants Usage

All player's ranks are handled by the grant system. The player can have one or more grants, all permissions from the grants will be synchronized and the grant with the highest rank weight will be displayed and used as a player's main grant/rank. Grant system will contain all granted/removed/expired rank's data

To get Grantas a object you need to access PlayerData object first, read here.

Once you get to the Grant object you will have access to different methods shown bellow.

    public boolean hasExpired() 
    public boolean isActiveSomewhere() 
    public boolean isPermanent()
    /*If server is "Global", grant is global*/
    public String getServer()
    public String getNiceDuration()
    public String getNiceExpire()
    public RankData getRank() 

PlayerData Usage

PlayerData object is related to an online player and requires UUID to be accessed. To get access to specific player's data use the following code

PlayerData playerData = AquaCoreAPI.INSTANCE.getPlayerData(UUID);

Now you have access to different methods shown bellow.

    public boolean hasPermission(String permission)
    public boolean hasDefaultGrant() 
    public void loadAttachments(Player player)
    public List<Grant> getActiveGrants()
    public boolean hasRank(RankData rankData) 
    public RankData getHighestRank() 
    public String getLastSeenAgo() 
    public ChatColor getNameColor() 
    public Tag getTag()
    public int getCoins() 
    public void setCoins(int amount)
    public void addCoins(int amount)
    public void removeCoins(int amount)
    public String getTagColor() 
    public ChatColor getChatColor() 
    public boolean isNameTag()
    public void setNameTag(boolean value) 
    public boolean isVanished() 
    public boolean isInStaffMode()

GlobalPlayer Usage

AquaCore provides player's data which can be accessed from any server if player is connected to any synced server via Redis. This data is stored into GlobalPlayer object.

To get someone's global data use one of the next methods:

This method requires UUID or String(player's name) as argument.

GlobalPlayer globalPlayer = AquaCoreAPI.INSTANCE.getGlobalPlayer(UUID||String);

Now you have access to different methods shown bellow.

    public String getName()
    public String getAddress()
    public List<String> getPermissions()
    public int getRankWeight()
    public int getPunishPriority() 
    public int getVanishPriority()
    public boolean isStaffChatAlerts() 
    public boolean isOp() 
    public boolean hasPermission(String value) 
    public boolean isAdminChatAlerts()
    public boolean isHelpopAlerts()
    public boolean isReportAlerts() 
    public boolean isNameMCVerified()
    public String getRankName()
    public String getLastServer() 
    public String getDisplayName()
    public void sendMessage(String message) 
    public void playSound(String sound) 

Punish data Usage

To get access to specific player's punishments data use the following code

PlayerData playerData = AquaCoreAPI.INSTANCE.getPlayerData(UUID);

Once you get PlayerData you will have access to punishments related methods shown bellow.

    public Set<Punishment> getPunishments()
    public boolean isBanned()
    public boolean isIPBanned()
    public boolean isBlacklisted()
    public boolean isWarned() 
    public boolean isMuted() 
    public Punishment getActiveBan()
    public Punishment getActiveMute()
    public Punishment getActiveBlacklist() 
    public List<Punishment> getPunishments(PunishmentType type)

Rank Data Usage

RankData is a cached object which can be obtained from an instance of AquaCoreAPI class.

Getting any server's rank info RankData rankData = AquaCoreAPI.INSTANCE.getRankByName(String);

Getting player's highest rank RankData rankData = AquaCoreAPI.INSTANCE.getPlayerRank(UUID);

Now you have access to different methods shown bellow.

    public ChatColor getColor() 
    public String getPrefix() 
    public String getSuffix()
    public String getName() 
    public boolean hasPermission(String value) 
    public boolean hasInheritance(String value)
    public String getDisplayName() 
    public ChatColor getChatColor()
    public boolean isGlobal()
    public boolean isBungee()
    public boolean isDefaultRank()
    public boolean isPurchasable()
    public List<String> getServers() 
    public List<String> getBungeePermissions() 
    private List<String> getAllPermissions()
    private List<String> getAvailablePermissions()

Offline PunishData Usage

If the player is not cached AquaCore provides an object which can be initialized to get punish data of offline players. Please note that this object uses database connection and all methods need to be called async.

To get such object you need the following code [String parsed as argument is player's name]:

Loading all punishments

OfflinePunishData data = new OfflinePunishData(String).load();

Loading active punishments only

OfflinePunishData data = new OfflinePunishData(String).load(true);

Loading alts as well

OfflinePunishData data = new OfflinePunishData(String).load().loadAlts();
OfflinePunishData data = new OfflinePunishData(String).load(false).loadAlts();

Once you have initialized this object you will have access to different methods shown bellow.

    public List<Punishment> getPunishments() 
    public List<Alt> getAlts()
    public int getPunishPriority() 
    public Alt getAlt(UUID uuid) 
    public boolean isBanned()
    public boolean isIPBanned() 
    public boolean isBlacklisted() 
    public boolean isWarned() 
    public boolean isMuted()
    public Punishment getActiveBan()
    public Punishment getActiveMute()
    public Punishment getActiveBlacklist() 

Events

AquaCore contains custom events which are called when the plugin performs some actions. Here is the list of all events.

PlayerGrantEvent

/**
 * Event called whenever player or console grants a rank
 */
public class PlayerGrantEvent extends AquaEvent {

    public Grant getGrant() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public PlayerData getTargetData() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public CommandSender getExecutor() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isCancelled() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean setCancelled(boolean value) {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerOpChangeEvent

/**
 * Event called whenever player gets access to operator ot gets access of operator removed
 */
public class PlayerOpChangeEvent extends AquaEvent {

    public Player getPlayer() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isOped() {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerPunishEvent

/**
 * Event called whenever player or console tries to punish someone
 */
public class PlayerPunishEvent extends AquaEvent {

    public OfflinePunishData getData() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public Punishment getPunishment() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isCancelled() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean setCancelled(boolean value) {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerUnPunishEvent

/**
 * Event called whenever player or console tries to un-punish someone
 */
public class PlayerUnPunishEvent extends AquaEvent {

    public OfflinePunishData getData() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public Punishment getPunishment() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isCancelled() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean setCancelled(boolean value) {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerReportEvent

/**
 * Event called whenever player tries to report global player [defined as getHacker()]
 */
public class PlayerReportEvent extends AquaEvent {

    public Player getPlayer() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public GlobalPlayer getHacker() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getReason() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isCancelled() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean setCancelled(boolean value) {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

VanishUpdateEvent

/**
 * Event called whenever a staff player execute vanish command
 */
public class VanishUpdateEvent extends AquaEvent {

    public Player getPlayer() {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

NameMCVerificationChangeEvent

/**
 * Event called whenever player likes your server on NameMC (NameMC is updating every 5 minutes per user)
 */
public class NameMCVerificationChangeEvent extends AquaEvent {

    private PlayerData playerData;
    private boolean finalLiked;

    public PlayerData getPlayerData() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public boolean isFinalLiked() {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerDisguiseEvent

#getDisguisedRank() is nullable.

public class PlayerDisguiseEvent extends AquaEvent {

    public Player getPlayer() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getPreviousName() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getCurrentName() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getDisguisedRank() {
        throw new IllegalPluginAccessException("API is not registered");
    }
}

PlayerUnDisguiseEvent

#getPlayer() and #getDisguisedRank() are nullable.

public class PlayerUnDisguiseEvent extends AquaEvent {

    public Player getPlayer() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getPreviousName() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getCurrentName() {
        throw new IllegalPluginAccessException("API is not registered");
    }

    public String getDisguisedRank() {
        throw new IllegalPluginAccessException("API is not registered");
    }
}
⚠️ **GitHub.com Fallback** ⚠️