Developer API

Plugin API Usage

Maven Integration

There is no maven repository for this plugin, You can add it directly to your project using a filepath like the following:

        <dependency>
            <groupId>me.frxq</groupId>
            <artifactId>gangsx</artifactId>
            <version>LATEST</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/libs/GangsX.jar</systemPath>
        </dependency>


Hooking into GangsX

Firstly check the plugin is enabled using the following:

    public boolean isGangsXEnabled() {
        if(Bukkit.getPluginManager().getPlugin("GangsX") == null) {
           return false;
        }
        return true;
    }

Getting the APIManager instance

Use this code to get all of the features from GangsX API

APIManager apiManager = GangsX.getAPIManager();

This will return the APIManager class which contains the following methods:

public class APIManager {
    private final GangsX plugin;

    public APIManager(GangsX plugin) {
        this.plugin = plugin;
    }
    /**
     * Checks if a gang with the specified name exists.
     *
     * @param name The name of the gang to check
     * @return true if a gang with the given name exists, false otherwise or if parameters are invalid
     */
    public boolean doesGangExist(String name) {
        if(name == null) return false;
        if(name.isEmpty()) return false;
        if(plugin.getDataFactory().getGangDataFactory().getGangs() == null) return false;
        if(plugin.getDataFactory().getGangDataFactory().getGangs().isEmpty()) return false;
        return plugin.getDataFactory().getGangDataFactory().doesGangNameExist(name);
    }

    /**
     * Retrieves a gang by its name.
     *
     * @param name The name of the gang to retrieve
     * @return The Gang object if found, null if the gang doesn't exist or if parameters are invalid
     */
    public Gang getGang(String name) {
        if(name == null) return null;
        if(name.isEmpty()) return null;
        if(plugin.getDataFactory().getGangDataFactory().getGangs() == null) return null;
        if(plugin.getDataFactory().getGangDataFactory().getGangs().isEmpty()) return null;
        if(!plugin.getDataFactory().getGangDataFactory().doesGangNameExist(name)) return null;
        return plugin.getDataFactory().getGangDataFactory().getGangData(plugin.getDataFactory().getGangDataFactory().getGangID(name));
    }

    /**
     * Retrieves a player by their UUID.
     *
     * @param uuid The UUID of the player to retrieve
     * @return The GPlayer object if found, null if the player doesn't exist or if parameters are invalid
     */
    public GPlayer getGPlayer(UUID uuid) {
        if(uuid == null) return null;
        if(plugin.getDataFactory().getGPlayerDataFactory() == null) return null;
        if(plugin.getDataFactory().getGPlayerDataFactory().getPlayers() == null) return null;
        if(plugin.getDataFactory().getGPlayerDataFactory().getPlayers().isEmpty()) return null;
        if(!plugin.getDataFactory().getGPlayerDataFactory().doesGPlayerDataExist(uuid)) return null;
        return plugin.getDataFactory().getGPlayerDataFactory().getGPlayerData(uuid);
    }
    /**
     * Retrieves a module of the specified type from the module manager.
     *
     * @param type The type of module to retrieve
     * @return The requested Module instance
     *
     * NOTE: This method is used to access specific modules within the GangsX plugin.
     * If you want to access none abstract methods of a module, you can cast the Module to the specific module type you need.
     */
    public Module getModule(ModuleType type) {
        return plugin.getModuleManager().getModule(type);
    }

    /**
     * Gets the leaderboard factory instance.
     *
     * @return The LeaderboardFactory instance used for managing leaderboards
     */
    public LeaderboardFactory getLeaderboardFactory() {
        return plugin.getLeaderboardFactory();
    }

    /**
     * Gets the currency manager instance.
     *
     * @return The CurrencyManager instance used for managing currencies
     */
    public CurrencyManager getCurrencyManager() {
        return plugin.getCurrencyManager();
    }

    /**
     * Gets the integration manager instance.
     *
     * @return The IntegrationManager instance used for managing integrations
     */
    public IntegrationManager getIntegrationManager() {
        return plugin.getIntegrationManager();
    }

    /**
     * Gets the permission manager instance.
     *
     * @return The PermissionManager instance used for managing permissions
     */
    public PermissionManager getPermissionManager() {
        return plugin.getPermissionManager();
    }

    /**
     * Gets the upgrade manager instance.
     *
     * @return The UpgradeManager instance used for managing upgrades
     */
    public UpgradeManager getUpgradeManager() {
        return plugin.getUpgradeManager();
    }

    /**
     * Gets the statistic manager instance.
     *
     * @return The StatisticManager instance used for managing statistics
     */
    public StatisticManager getStatisticManager() {
        return plugin.getStatisticManager();
    }

    /**
     * Gets the role manager instance.
     *
     * @return The RoleManager instance used for managing roles
     */
    public RoleManager getRoleManager() {
        return plugin.getRoleManager();
    }

    /**
     * Gets the module manager instance.
     *
     * @return The ModuleManager instance used for managing modules
     */
    public ModuleManager getModuleManager() {
        return plugin.getModuleManager();
    }

    /**
     * Gets the locale manager instance.
     *
     * @return The LocaleManager instance used for managing locales
     */
    public LocaleManager getLocaleManager() {
        return plugin.getLocaleManager();
    }

    /**
     * Gets the command handler instance.
     *
     * @return The CommandHandler instance used for managing commands
     */
    public CommandHandler getCommandHandler() {
        return plugin.getCommandHandler();
    }

    /**
     * Gets the menu utils instance.
     *
     * @return The MenuUtils instance used for managing menus
     */
    public MenuUtils getMenuUtils() {
        return plugin.getMenuUtils();
    }

    /**
     * Gets the validation utils instance.
     *
     * @return The ValidationUtils instance used for validating data
     */
    public ValidationUtils getValidationUtils() {
        return plugin.getValidationUtils();
    }
}

Last updated