PlumDeliveryPlumDelivery
Home
Guide
  • Overview
  • Database
  • Deliveries
  • Menus
  • Categories
  • Rewards
  • Messages
Commands
Placeholders
  • Overview
  • Methods
  • Events
Database Guide
FAQ
GitHub
Home
Guide
  • Overview
  • Database
  • Deliveries
  • Menus
  • Categories
  • Rewards
  • Messages
Commands
Placeholders
  • Overview
  • Methods
  • Events
Database Guide
FAQ
GitHub
  • Developer API

    • Developer API
    • Method Reference
    • Events

Method Reference

This page documents every public method in the PlumDelivery API. All classes are in the net.plumstudio.plumdelivery.api package.

PlumDeliveryAPI

The main entry point for all API interactions. Access it via PlumDeliveryAPI.getInstance().

getInstance

public static PlumDeliveryAPI getInstance()

Returns the singleton API instance. Available after PlumDelivery has been enabled.

Returns: PlumDeliveryAPI — the API instance


User Data

getUser

public ApiUser getUser(UUID uuid)

Retrieves an ApiUser wrapper for the specified player.

ParameterTypeDescription
uuidUUIDThe player's unique ID

Returns: ApiUser — a wrapper with the player's delivery data

Example:

ApiUser user = api.getUser(player.getUniqueId());
int dailyMining = user.getPoints(DeliveryType.DAILY, "mining");

getAllUsers

public Collection<ApiUser> getAllUsers()

Returns all users currently loaded in the system.

Returns: Collection<ApiUser> — all tracked users

Example:

Collection<ApiUser> users = api.getAllUsers();
for (ApiUser user : users) {
    getLogger().info("User: " + user.getUuid());
}

Point Operations

Tips

These methods directly modify the database. They do not send messages to players or check goal completion. If you need goal-aware point changes, modify points through an ApiUser and call save().

addPoints

public void addPoints(UUID playerUuid, DeliveryType type, String category, int amount)

Adds points to a player for a specific delivery type and category. Changes are persisted to the database immediately.

ParameterTypeDescription
playerUuidUUIDThe player's unique ID
typeDeliveryTypeThe delivery period (DAILY, WEEKLY, MONTHLY)
categoryStringThe category key (e.g. "mining", "fishing")
amountintThe number of points to add

Example:

// Award 10 daily mining points
api.addPoints(player.getUniqueId(), DeliveryType.DAILY, "mining", 10);

removePoints

public void removePoints(UUID playerUuid, DeliveryType type, String category, int amount)

Removes points from a player. Changes are persisted to the database immediately.

ParameterTypeDescription
playerUuidUUIDThe player's unique ID
typeDeliveryTypeThe delivery period
categoryStringThe category key
amountintThe number of points to remove

Example:

// Remove 5 weekly fishing points as a penalty
api.removePoints(player.getUniqueId(), DeliveryType.WEEKLY, "fishing", 5);

getPoints

public int getPoints(UUID playerUuid, DeliveryType type, String category)

Returns a player's current point count for a specific delivery type and category.

ParameterTypeDescription
playerUuidUUIDThe player's unique ID
typeDeliveryTypeThe delivery period
categoryStringThe category key

Returns: int — the current point count

Example:

int points = api.getPoints(player.getUniqueId(), DeliveryType.MONTHLY, "combat");
player.sendMessage("Monthly combat points: " + points);

getAllCategories

public Collection<String> getAllCategories()

Returns all category keys defined in the plugin configuration.

Returns: Collection<String> — all category keys

Example:

Collection<String> categories = api.getAllCategories();
categories.forEach(cat -> getLogger().info("Category: " + cat));

Delivery Status

isDeliveryRunning

public boolean isDeliveryRunning(DeliveryType type)

Checks whether a specific delivery type is currently active (timer is running).

ParameterTypeDescription
typeDeliveryTypeThe delivery period to check

Returns: boolean — true if the delivery is currently running

Example:

if (api.isDeliveryRunning(DeliveryType.DAILY)) {
    player.sendMessage("The daily delivery is active!");
}

isDeliveryEnabled

public boolean isDeliveryEnabled(DeliveryType type)

Checks whether a delivery type is enabled in the plugin configuration.

ParameterTypeDescription
typeDeliveryTypeThe delivery period to check

Returns: boolean — true if the delivery type is enabled in config

Example:

if (api.isDeliveryEnabled(DeliveryType.WEEKLY)) {
    // Weekly deliveries are configured
}

Timer

getRemainingTime

public long getRemainingTime(DeliveryType type)

Returns the remaining time (in seconds) for the specified delivery type's current cycle.

ParameterTypeDescription
typeDeliveryTypeThe delivery period

Returns: long — remaining time in seconds

getFormattedRemainingTime

public String getFormattedRemainingTime(DeliveryType type)

Returns the remaining time as a human-readable formatted string (e.g. "2h 30m 15s").

ParameterTypeDescription
typeDeliveryTypeThe delivery period

Returns: String — formatted remaining time

Example:

String timeLeft = api.getFormattedRemainingTime(DeliveryType.DAILY);
player.sendMessage("Time remaining: " + timeLeft);

Category Info

getCategories

public Set<String> getCategories()

Returns an unmodifiable set of all category keys from the configuration.

Returns: Set<String> — all category keys, or an empty set if none are configured

getCategory

public ApiCategory getCategory(String name)

Retrieves detailed information about a specific category.

ParameterTypeDescription
nameStringThe category key

Returns: ApiCategory — category details, or null if not found

Example:

ApiCategory category = api.getCategory("mining");
if (category != null) {
    player.sendMessage("Category: " + category.getDisplayName());
}

ApiUser

A wrapper around a player's delivery data. Obtained via PlumDeliveryAPI.getUser(UUID).

Warning

ApiUser is a snapshot wrapper around the internal user object. Changes made through addPoints() or removePoints() on an ApiUser modify the in-memory data but are not automatically saved to the database. Call save() to persist changes.

getUuid

public UUID getUuid()

Returns the player's UUID.

Returns: UUID — the player's unique ID

getPoints

public int getPoints(DeliveryType type, String category)

Returns this user's point count for a delivery type and category.

ParameterTypeDescription
typeDeliveryTypeThe delivery period
categoryStringThe category key

Returns: int — current points

addPoints

public void addPoints(DeliveryType type, String category, int amount)

Adds points to this user's in-memory data.

ParameterTypeDescription
typeDeliveryTypeThe delivery period
categoryStringThe category key
amountintPoints to add

Tips

Remember to call save() after modifying points through ApiUser.

removePoints

public void removePoints(DeliveryType type, String category, int amount)

Removes points from this user's in-memory data.

ParameterTypeDescription
typeDeliveryTypeThe delivery period
categoryStringThe category key
amountintPoints to remove

getCurrentGoal

public int getCurrentGoal(DeliveryType type, String category)

Returns the current goal value for a delivery type and category.

ParameterTypeDescription
typeDeliveryTypeThe delivery period
categoryStringThe category key

Returns: int — the goal target value

getAllPoints

public Map<String, Integer> getAllPoints()

Returns an unmodifiable map of all point entries for this user. Map keys are composite identifiers (e.g., "daily_mining").

Returns: Map<String, Integer> — all points (read-only)

getAllGoals

public Map<String, Integer> getAllGoals()

Returns an unmodifiable map of all goal entries for this user.

Returns: Map<String, Integer> — all goals (read-only)

save

public void save()

Persists this user's current data to the database.

Example:

ApiUser user = api.getUser(player.getUniqueId());
user.addPoints(DeliveryType.DAILY, "mining", 10);
user.save(); // Don't forget this!

ApiCategory

Provides information about a configured delivery category. Obtained via PlumDeliveryAPI.getCategory(String).

getKey

public String getKey()

Returns the internal key of this category (as defined in the config).

Returns: String — the category key

getDisplayName

public String getDisplayName()

Returns the display name of this category.

Returns: String — the human-readable name

getRequiredObjects

public Map<String, String> getRequiredObjects()

Returns the required objects for this category as a map of object type to action.

Returns: Map<String, String> — required objects (type → action), or an empty map if none are defined

Example:

ApiCategory category = api.getCategory("mining");
if (category != null) {
    Map<String, String> objects = category.getRequiredObjects();
    for (Map.Entry<String, String> entry : objects.entrySet()) {
        getLogger().info("Type: " + entry.getKey() + " → Action: " + entry.getValue());
    }
}

DeliveryType

An enum representing the three delivery periods. Located in net.plumstudio.plumdelivery.model.DeliveryType.

Values

ConstantKeyDefault Duration
DAILY"daily"86,400 seconds (24 hours)
WEEKLY"weekly"604,800 seconds (7 days)
MONTHLY"monthly"2,592,000 seconds (30 days)

Methods

getKey

public String getKey()

Returns the string key of this delivery type (e.g. "daily").

Returns: String — the key

getDisplayName

public String getDisplayName()

Returns a human-readable display name for this delivery type.

Returns: String — the display name

fromString

public static DeliveryType fromString(String key)

Parses a string key into a DeliveryType enum value.

ParameterTypeDescription
keyStringThe delivery type key (e.g. "daily", "weekly", "monthly")

Returns: DeliveryType — the matching enum value

Example:

DeliveryType type = DeliveryType.fromString("weekly");
// type == DeliveryType.WEEKLY

Complete Example

Here is a full example plugin that integrates with the PlumDelivery API:

import net.plumstudio.plumdelivery.api.PlumDeliveryAPI;
import net.plumstudio.plumdelivery.api.ApiUser;
import net.plumstudio.plumdelivery.api.ApiCategory;
import net.plumstudio.plumdelivery.model.DeliveryType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public class DeliveryStatsPlugin extends JavaPlugin {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) return false;
        if (!command.getName().equalsIgnoreCase("deliverystats")) return false;

        PlumDeliveryAPI api = PlumDeliveryAPI.getInstance();
        if (api == null) {
            player.sendMessage("§cPlumDelivery is not loaded!");
            return true;
        }

        ApiUser user = api.getUser(player.getUniqueId());

        player.sendMessage("§6§l━━━ Your Delivery Stats ━━━");

        for (String categoryKey : api.getCategories()) {
            ApiCategory category = api.getCategory(categoryKey);
            String name = category != null ? category.getDisplayName() : categoryKey;

            for (DeliveryType type : DeliveryType.values()) {
                int points = user.getPoints(type, categoryKey);
                int goal = user.getCurrentGoal(type, categoryKey);
                String status = points >= goal ? "§a✔" : "§c✘";

                player.sendMessage(String.format(
                    "  §e%s §7[%s§7] §f%d§7/§f%d %s",
                    name, type.getDisplayName(), points, goal, status
                ));
            }
        }

        // Show active delivery timers
        player.sendMessage("§6§l━━━ Active Deliveries ━━━");
        for (DeliveryType type : DeliveryType.values()) {
            if (api.isDeliveryRunning(type)) {
                String time = api.getFormattedRemainingTime(type);
                player.sendMessage(String.format("  §a%s §7- §f%s remaining", type.getDisplayName(), time));
            } else {
                player.sendMessage(String.format("  §c%s §7- Not active", type.getDisplayName()));
            }
        }

        return true;
    }
}
Prev
Developer API
Next
Events