Overview | EssentialsC | KitApi
net.godlycow.org.essc.api

Interface KitApi

public interface KitApi

API interface for interacting with EssentialsC's kit system. All methods are synchronous and safe to call on the main thread. Kit data is loaded from kits.yml at startup and kept in memory.

Retrieve an instance via EssentialsCAPI.getKitApi().

KitApi kits = APIProvider.getAPI().getKitApi();

Kit starter = kits.getKit("starter");
if (starter != null && kits.canClaim(player, starter)) {
    kits.giveKit(player, starter);
}

The Kit data class lives in the net.godlycow.org.essc.api.kit sub-package.

Method Summary

Kit getKit(String name)
Looks up a kit by its internal name. Returns null if not found.
Collection<Kit> getKits()
Returns all currently loaded kits.
boolean hasPermission(Player player, Kit kit)
Returns whether the player has permission to access the given kit.
boolean canClaim(Player player, Kit kit)
Returns whether the player is currently eligible to claim the given kit.
boolean hasClaimed(Player player, Kit kit)
Returns whether the player has claimed the given kit at least once.
int getClaimCount(Player player, Kit kit)
Returns the number of times the player has claimed the given kit.
long getCooldownRemaining(Player player, Kit kit)
Returns the seconds remaining on the player's cooldown for the given kit.
void giveKit(Player player, Kit kit)
Gives the given kit to the player, bypassing all permission and cooldown checks.
Method Detail
public Kit getKit(String name)

Looks up a kit by its internal name. Name matching is case-insensitive.

Parameters:
namethe name of the kit to look up; must not be null
Returns:
Kitthe Kit, or null if no kit with that name exists
public Collection<Kit> getKits()

Returns all currently loaded kits. The returned collection reflects the live kit map and will change if kits are reloaded. Do not assume a stable order.

Returns:
Collection<Kit>all loaded kits; never null, may be empty
public boolean hasPermission(Player player, Kit kit)

Returns whether the given player has the permission to access the given kit. Returns true if the player holds the kit's specific permission node or the essentialsc.kits.admin bypass permission.

Parameters:
playerthe player to check; must not be null
kitthe kit to check against; must not be null
Returns:
booleantrue if the player has permission to claim this kit
public boolean canClaim(Player player, Kit kit)

Returns whether the given player is currently eligible to claim the given kit. This checks, in order:

  • Whether the player has the required permission (see hasPermission).
  • Whether the kit is one-time and has already been claimed.
  • Whether the kit's max-claims limit has been reached.
  • Whether the player is still on cooldown (bypassed by essentialsc.kits.admin).
Parameters:
playerthe player to check; must not be null
kitthe kit to check; must not be null
Returns:
booleantrue if the player may claim the kit right now
public boolean hasClaimed(Player player, Kit kit)

Returns whether the given player has claimed the given kit at least once.

Parameters:
playerthe player to check; must not be null
kitthe kit to check; must not be null
Returns:
booleantrue if the player has at least one claim recorded
public int getClaimCount(Player player, Kit kit)

Returns the number of times the given player has claimed the given kit.

Parameters:
playerthe player to check; must not be null
kitthe kit to check; must not be null
Returns:
intthe claim count; 0 if the player has never claimed this kit
public long getCooldownRemaining(Player player, Kit kit)

Returns the number of seconds remaining on the given player's cooldown for the given kit.

Parameters:
playerthe player to check; must not be null
kitthe kit to check; must not be null
Returns:
longseconds until the player may claim again; 0 if not on cooldown
public void giveKit(Player player, Kit kit)

Gives the given kit to the given player, bypassing all permission and cooldown checks.

Items that do not fit in the player's inventory are dropped naturally at their location. The claim is recorded in the database and the in-memory cache is updated. A success message is sent to the player and a DiscordSRV embed is dispatched if the integration is active.

This method must be called on the main thread.

Parameters:
playerthe player to give the kit to; must not be null and must be online
kitthe kit to give; must not be null