VZone Plugins/VGraves/API/Examples

Access through ServicesManager

RegisteredServiceProvider<VGravesApi> provider =
        Bukkit.getServicesManager().getRegistration(VGravesApi.class);

if (provider == null) {
    getLogger().warning("VGraves API is not available.");
    return;
}

VGravesApi api = provider.getProvider();

Lookup Examples

List<Grave> graves = api.getGraves(player.getUniqueId());
Optional<Grave> graveOptional = api.getGrave(player.getUniqueId(), "a1b2c3d4");

int tickets = api.getTickets(player.getUniqueId());
int buyUsage = api.getBuyUsage(player.getUniqueId());

Action Examples

api.addTickets(player.getUniqueId(), 5);

GraveManager.PaidClaimResult result =
        api.precheckCurrencyClaim(player.getUniqueId(), graveId, player);

boolean success = api.forceClaim(ownerUuid, graveId, targetPlayer, true);

Event Listener Example

@EventHandler
public void onGraveClaim(GraveClaimedEvent event) {
    getLogger().info(
            "Grave " + event.getGrave().getId()
            + " was claimed by " + event.getReceiver().getName()
            + " cause=" + event.getCause()
            + " consumed=" + event.isConsumed()
    );
}