-
Notifications
You must be signed in to change notification settings - Fork 19
API Reference
PhilipB edited this page Aug 17, 2026
·
2 revisions
All public v1 types are in:
com.reazip.economycraft.api.v1Implementation and provider classes are internal. Other mods should only import the types listed here.
public interface EconomyCraftApi {
static EconomyCraftApi get(MinecraftServer server);
BalanceApi balances();
PriceApi prices();
LeaderboardApi leaderboard();
BalanceEvents balanceEvents();
String formatMoney(long amount);
}public interface BalanceApi {
long getBalance(UUID playerId);
long getMaximumBalance();
BalanceMutationResult addMoney(UUID playerId, long amount);
BalanceMutationResult addMoney(UUID playerId, long amount, MutationSource source);
BalanceMutationResult removeMoney(UUID playerId, long amount);
BalanceMutationResult removeMoney(UUID playerId, long amount, MutationSource source);
BalanceMutationResult setMoney(UUID playerId, long balance);
BalanceMutationResult setMoney(UUID playerId, long balance, MutationSource source);
PaymentResult pay(UUID senderId, UUID receiverId, long amount);
PaymentResult pay(UUID senderId, UUID receiverId, long amount, MutationSource source);
}public record BalanceMutationResult(
BalanceMutationStatus status,
BalanceMutationType type,
UUID playerId,
long requestedAmount,
long previousBalance,
long newBalance,
Optional<MutationSource> source
) {
boolean successful();
long difference();
}public record PaymentResult(
BalanceMutationStatus status,
UUID senderId,
UUID receiverId,
long amount,
long senderPreviousBalance,
long senderNewBalance,
long receiverPreviousBalance,
long receiverNewBalance,
Optional<MutationSource> source
) {
boolean successful();
long senderDifference();
long receiverDifference();
}public enum BalanceMutationStatus {
SUCCESS,
NO_CHANGE,
INVALID_AMOUNT,
INSUFFICIENT_FUNDS,
SAME_PLAYER,
MAX_BALANCE_EXCEEDED
}public enum BalanceMutationType {
ADD,
REMOVE,
SET,
PAYMENT_SENT,
PAYMENT_RECEIVED
}public record MutationSource(String namespace, String reason) {
static MutationSource of(String namespacedReason);
String asString();
}public interface PriceApi {
Optional<ItemPrice> resolve(ItemStack stack);
List<String> categories();
List<ItemPrice> entries(String category);
}public final class ItemPrice {
public ItemPrice(
String key,
String itemId,
String category,
int bulkAmount,
OptionalLong unitBuyPrice,
OptionalLong unitSellPrice,
boolean customItem,
ItemStack prototype
);
public String key();
public String itemId();
public String category();
public int bulkAmount();
public OptionalLong unitBuyPrice();
public OptionalLong unitSellPrice();
public boolean hasBuyPrice();
public boolean hasSellPrice();
public boolean customItem();
public ItemStack prototype();
}The constructor copies prototype. The prototype() accessor returns another copy.
public interface LeaderboardApi {
List<LeaderboardEntry> getLeaderboardEntries(int limit);
Optional<LeaderboardEntry> getLeaderboardEntry(int rank);
}public record LeaderboardEntry(UUID playerId, long balance) {}public interface BalanceEvents {
ListenerRegistration register(BalanceChangeListener listener);
}@FunctionalInterface
public interface BalanceChangeListener {
void onBalanceChanged(BalanceChangeEvent event);
}public record BalanceChangeEvent(
UUID playerId,
long previousBalance,
long newBalance,
BalanceMutationType type,
Optional<UUID> counterpartyId,
Optional<MutationSource> source
) {
long difference();
}public interface ListenerRegistration extends AutoCloseable {
void unregister();
void close();
}- All calls are server-thread-only.
- UUID arguments support offline players.
- Calling mods handle their own permissions.
- Normal absent values use
Optional,OptionalLongor an empty immutable list instead ofnull. - Failed mutations do not change or implicitly save balances.
- Returned price and leaderboard data is immutable.
- Balance events are successful after-events and are not cancellable.
EconomyCraft API v1