Sueta

⭐The Assistant⭐ Easy To Use Dependency Injection API

4.0.2

Okaeri based library which provides developer tools.

·Plugin

Libraries aimed to developers with multiple functions that will make you things easier.

API

/**
 * The Assistant API
 */
public interface TheAssistantAPI {
    /**
     * Retrieves Command Provider
     *
     * @return CommandProvider of {@link AssistantCommand}
     */
    public CommandProvider<AssistantCommand> getCommandProvider();

    /**
     * Retrieves Dependency Resolver
     * @return {@link DependencyResolver}
     */
    public DependencyResolver getDependencyResolver();

    /**
     * Retrieves Addon Service
     *
     * @return {@link AddonsService}
     */
    public AddonsService getAddons();

    /**
     * Retrieves NMS Multi Version handler
     *
     * @return {@link NMS}
     */
    public NMS getNms();


    /**
     * Retrieves Plugin instance
     *
     * @return {@link Plugin} instance
     */
    public Plugin getPlugin();
}

Addons Service
Probably the most powerful feature in this assistant, the posibility to easily manage hooks.

► Economy Addon (Support Vault, PlayerPoints & TokenManager)

/**
 * Economy Addon
 */
public interface EconomyAddon extends DependencyPlugin {
    /**
     * Retrieves player money
     *
     * @param player {@link OfflinePlayer}
     * @return money amount
     */
    public double getMoney(final OfflinePlayer player);

    /**
     * Deposit money to player balance
     *
     * @param player {@link OfflinePlayer}
     * @param amount money to add
     */
    public void depositMoney(final OfflinePlayer player, final double amount);

    /**
     * Withdraw money from player balance
     *
     * @param player {@link OfflinePlayer}
     * @param amount money to remove
     */
    public void withdrawMoney(final OfflinePlayer player, final double amount);
}


► Regions Addon (Support WorldGuard, Residence & UltraRegions)

/**
 * Region Addon
 */
public interface RegionAddon extends DependencyPlugin {
    /**
     * Retrieves if a location is inside any of given regions
     *
     * @param location {@link Location}
     * @param regions  List of regions
     * @return true if location is in any region
     */
    public default boolean isInAnyRegion(final Location location, final List<String> regions) {
        if (regions.isEmpty()) {
            return false;
        }

        return getRegions(location)
                .stream()
                .anyMatch(regions::contains);
    }

    /**
     * Retrieves if a location is inside given region
     *
     * @param location {@link Location}
     * @param region   region
     * @return true if location is in region
     */
    public default boolean isInRegion(final Location location, final String region) {
        if (region == null) {
            return false;
        }

        return getRegions(location)
                .stream()
                .anyMatch(region::equals);
    }

    /**
     * Retrieves location's regions
     *
     * @param location {@link Location}
     * @return Set of regions
     */
    public Set<String> getRegions(final Location location);
}

► Paster Addon (Support WorldEdit)

/**
 * Paster Addon interface
 */
public interface PasterAddon extends DependencyPlugin {
    /**
     * Paste World edit schematic in specific location
     *
     * @param location  {@link Location}
     * @param schematic {@link Schematic}
     * @return CompletableFuture of {@link PasterSession}
     */
    public CompletableFuture<PasterSession> pasteSchematic(final Location location, final Schematic schematic);
}

► NPC's Addon (Support Citizens)

/**
 * NPC Addon
 */
public interface NPCAddon extends DependencyPlugin {
    /**
     * Retrieves if an entity is an npc
     *
     * @param entity {@link Entity}
     * @return true if it's npc
     */
    public boolean isNPC(final Entity entity);
}

► Placeholders Addon (Support PlaceholderAPI & MVdW PlaceholderAPI)

/**
 * Placeholder Addon
 */
public interface PlaceholdersAddon extends DependencyPlugin {
    /**
     * Register a placeholder with custom placeholder replacer
     *
     * @param identifier placeholder key
     * @param replacer   {@link PlaceholderReplacer}
     */
    public void registerPlaceholders(final String identifier, final PlaceholderReplacer replacer);
}

CommandProvider
Register commands in real time, they need to be in plugin.yml.

1- Register the label provider

LabelProvider.builder()
                .id("theAssistantCommand")
                .label("assistant")
                .plugin(box.plugin())
                .useHelpMessage("&cUse Help")
                .unknownCommandMessage("&cUnknown Command")
                .onlyForPlayersMessage("&cThis command can be executed only for players!")
                .noPermissionMessage("&cYou don't have permission to use that command!")
                .build()
                .register();

2-Register command with handler

/**
 * Command provider implementation for the assistant
 */
public final class TheAssistantCommandProvider implements CommandProvider<AssistantCommand> {
    /**
     * Register a command with specific handler
     *
     * @param command Command to be registered
     * @param handler Command handler
     */
    public void registerCommand(final AssistantCommand command, final CommandHandler<AssistantCommand> handler);
}

Similar projects

Plugin →