EyCoinsAPI
A lightweight, async coins economy API for Minecraft 1.21.1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ Features
- Fully async storage — zero main-thread blocking
- YAML & MySQL — switchable backends with HikariCP connection pool
- Transaction history — every coin change is logged per player
- Coin multipliers — temporary or permanent boost for addCoins
- Bank / Transfer — atomic coin transfers between players
- Top list — getTopPlayers(limit) ready to use
- Bukkit Events — CoinsChangeEvent (cancellable) & CoinsTransactionEvent
- Offline player support — all operations work by UUID
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ Storage Setup
Configure the backend in plugins/EyCoinsAPI/config.yml:
Code (YAML):
storage:
type
: YAML
# YAML or MYSQL
max-transactions
: 50
mysql:
host
: localhost
port
: 3306
database
: eycoinsapi
username
: root
password
: secret
table
: eycoins_players
pool:
max-size
: 10
min-idle
: 2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ Developer Setup
Add EyCoinsAPI as a dependency in your plugin.yml:
Code (YAML):
depend
:
- EyCoinsAPI
Maven pom.xml — replace VERSION with the release, e.g. 1.0.0:
Code (XML):
<dependency>
<groupId>buzz.eyplugins.eynoah
</groupId>
<artifactId>EyCoinsAPI
</artifactId>
<version>VERSION
</version>
<scope>provided
</scope>
</dependency>
Get the API instance:
Code (Java):
CoinsAPI coinsAPI
= EyCoinsAPI.
getInstance
(
).
getCoinsAPI
(
)
;
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ API Reference
All methods return CompletableFuture — use .thenAccept() for callbacks.
» Coins
Code (Java):
// Get
coinsAPI.
getCoins
(player
).
thenAccept
(coins
-> player.
sendMessage
(
"Balance: "
+ coins
)
)
;
// Set
coinsAPI.
setCoins
(player,
500.0,
"Admin reset"
)
;
// Add (multiplier is applied automatically)
coinsAPI.
addCoins
(player,
100.0,
"Quest reward"
)
;
// Remove (returns false if not enough coins)
coinsAPI.
removeCoins
(player,
50.0,
"Shop purchase"
).
thenAccept
(success
->
{
if
(
!success
) player.
sendMessage
(
"Not enough coins!"
)
;
}
)
;
// Check
coinsAPI.
hasCoins
(player,
200.0
).
thenAccept
(has
->
{ ...
}
)
;
» Transfer (Bank)
Code (Java):
coinsAPI.
transferCoins
(fromPlayer, toPlayer,
250.0,
"Trade"
).
thenAccept
(success
->
{
if
(
!success
) fromPlayer.
sendMessage
(
"Transfer failed."
)
;
}
)
;
» Transaction History
Code (Java):
coinsAPI.
getHistory
(player,
10
).
thenAccept
(transactions
->
{
for
(CoinTransaction tx
: transactions
)
{
// tx.getType(), tx.getAmount(), tx.getBalanceBefore(),
// tx.getBalanceAfter(), tx.getReason(), tx.getTimestamp()
}
}
)
;
» Top Players
Code (Java):
coinsAPI.
getTopPlayers
(
10
).
thenAccept
(entries
->
{
int rank
=
1
;
for
(
Map.
Entry
<UUID, Double
> e
: entries
)
{
System.
out.
println
(
"#"
+ rank
++
+
": "
+ e.
getValue
(
)
+
" coins"
)
;
}
}
)
;
» Multipliers
Code (Java):
// 2x multiplier for 1 hour
coinsAPI.
setMultiplier
(player,
2.0,
3600
)
;
// Permanent (duration = 0)
coinsAPI.
setMultiplier
(uuid,
1.5,
0
)
;
// Query
double multi
= coinsAPI.
getEffectiveMultiplier
(uuid
)
;
// 1.0 if none
boolean active
= coinsAPI.
hasMultiplier
(uuid
)
;
Multiplier m
= coinsAPI.
getMultiplier
(uuid
)
;
// null if none/expired
// Remove
coinsAPI.
removeMultiplier
(player
)
;
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ Events
» CoinsChangeEvent
— fired before every change, cancellable
Code (Java):
@EventHandler
public
void onCoinsChange
(CoinsChangeEvent event
)
{
// Modify the final amount
event.
setNewAmount
(event.
getNewAmount
(
)
*
2
)
;
// Or cancel entirely
event.
setCancelled
(
true
)
;
}
» CoinsTransactionEvent
— fired after a successful change
Code (Java):
@EventHandler
public
void onTransaction
(CoinsTransactionEvent event
)
{
CoinTransaction tx
= event.
getTransaction
(
)
;
// log, sync, notify, etc.
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✦ Commands & Permissions
| Command |
Description |
Permission |
| /coins |
Show your own balance |
eycoinsapi.coins |
| /coins <player> |
Show another player's balance |
eycoinsapi.coins |
| /coins top [limit] |
Show top coin holders |
eycoinsapi.coins |
| /coins <player> set <amount> |
Set a player's coins |
eycoinsapi.coins.others |
| /coins <player> add <amount> |
Add coins to a player |
eycoinsapi.coins.others |
| /coins <player> remove <amount> |
Remove coins from a player |
eycoinsapi.coins.others |
| /coins <player> transfer <amount> |
Transfer coins to another player |
eycoinsapi.coins.others |
| /coins <player> history [limit] |
View transaction history |
eycoinsapi.coins.others |
| /coins <player> multiplier [value] [secs] |
Get or set coin multiplier |
eycoinsapi.admin |