Steal an Egg logoSteal an Egg

Developer API

Read player state and listen for gameplay events from another Bukkit plugin.

Developer API

This page is for plugin developers. cc.arrowtan.stealAnEgg.StealAnEgg exposes the static getAPI() accessor. Call API methods on the server's main thread.

Access

import cc.arrowtan.stealAnEgg.StealAnEgg;
import cc.arrowtan.stealAnEgg.api.EggAPI;

EggAPI eggAPI = StealAnEgg.getAPI();
if (eggAPI != null) {
    double balance = eggAPI.getBalance(player.getUniqueId());
    eggAPI.giveMoney(player.getUniqueId(), 250.0);
}

Declare StealAnEgg as a plugin dependency if your plugin cannot operate without it. No separate API Maven coordinates are specified in this repository.

EggAPI methods

MethodResult
getSpeed(UUID player)Saved speed points.
addSpeed(UUID player, long amount)Add speed points.
getBalance(UUID player)Current game balance, or Vault balance in Vault mode.
giveMoney(UUID player, double amount)Pay money and count it as earnings.
takeMoney(UUID player, double amount)Withdraw money, returning false if the balance is too low.
getIncomePerSecond(UUID player)Current total pet income per second.
getPen(UUID player)Read-only map of nest index to PenEntry.
givePet(UUID player, int zone, EggSize size, Mutation mutation, boolean op)Add a ready pet to the first free nest. Returns the nest index or -1 if full.
getCarried(UUID player)The player's carried LooseEgg, or null.
isStormActive()Whether any arena storm is active.
getIndexCount(UUID player)Number of discovered zone and size combinations.

The getPen map is unmodifiable. Its PenEntry values and LooseEgg objects expose plugin state, so avoid changing them outside their intended API operations.

Events

Events are in cc.arrowtan.stealAnEgg.api.events. All extend Bukkit Event. The listed cancellable events implement Cancellable.

EventData and timingCancellable
AchievementUnlockEventgetPlayer(), getAchievementId()No
BaseClaimedEventgetPlayer(), getBase()No
BaseUnclaimedEventgetBase(), getPreviousOwner()No
BaseProtectionActivateEventgetBase(), getDurationSeconds()No
EggPickupEventgetPlayer(), getEgg(), before pickup from a nest, ground or penYes
EggStolenEventgetThief(), getVictim() UUID, getEgg(), isFromPen()No
EggPlacedEventgetPlayer(), getRoll(), getNest(), before placementYes
EggHatchEventgetOwner() UUID, getRoll(), getNest()No
PetSoldEventgetPlayer(), getRoll(), isPet(), getPrice()No
GuardianCatchEventgetPlayer(), getEgg(), before the catch is appliedYes
EggStruckEventgetArena(), getEgg() after a storm makes it OPNo
StormStartEventgetArena(), getSeconds()No
StormEndEventgetArena()No
SpectatorPromotedEventgetPlayer() when offered a freed plotNo
RoundStartEventgetArena() when a round starts or resumesNo
RoundEndEventgetArena(), getRanking() player UUIDs, first place firstNo
PlayerRebirthEventgetPlayer(), getNewLevel()No
TeamJoinEventgetPlayer(), getTeamNumber()No
TrapTriggerEventgetVictim(), getTrapType(), getBase()No

For example, cancel an egg pickup with a normal Bukkit listener:

@EventHandler
public void onEggPickup(EggPickupEvent event) {
    if (shouldBlock(event.getPlayer(), event.getEgg())) {
        event.setCancelled(true);
    }
}

Version and availability

Compile against the API available in the plugin jar. This API is not a standalone dependency artifact. StealAnEgg.getAPI() is set during plugin enable, so check that the plugin has loaded before using it. Avoid database calls or Bukkit entity changes from asynchronous tasks.

On this page