1. Initialize EZVault
Code (Java):
public
class Plugin
extends JavaPlugin
{
@Override
public
void onEnable
(
)
{
EZVault.
builder
(
this
)
.
providerPriority
(
"essentials",
10
)
// Higher priority for Essentials
.
providerPriority
(
"cmi",
5
)
.
backupIntervalSeconds
(
600
)
// Backup every 10 mins
.
httpPort
(
8080
)
// Enable REST API
.
connect
(
)
;
}
}
2. Check a Player's Balance
Code (Java):
Player player
= Bukkit.
getPlayer
(
"Notch"
)
;
double balance
= EZVault.
balance
(player
)
;
// Synchronous
System.
out.
println
(player.
getName
(
)
+
" has $"
+ balance
)
;
3. Deposit/Withdraw Money (Async with Retry)
Code (Java):
EZVault.
depositAsync
(player,
100.0
)
.
thenAccept
(success
->
{
if
(success
) player.
sendMessage
(
"$100 added!"
)
;
else player.
sendMessage
(
"Transaction failed!"
)
;
}
)
;
EZVault.
withdrawAsync
(player,
50.0
)
.
exceptionally
(e
->
{
e.
printStackTrace
(
)
;
return
false
;
}
)
;
4. Listen to Economy Events (Reactive API)
Code (Java):
EZVault.
events
(
).
subscribe
(event
->
{
if
(event
instanceof EZVault.
VaultBalanceChangedEvent
)
{
VaultBalanceChangedEvent e
=
(VaultBalanceChangedEvent
) event
;
Bukkit.
broadcastMessage
(
e.
player.
getName
(
)
+
"'s balance changed from $"
+ e.
oldBalance
+
" to $"
+ e.
newBalance
)
;
}
}
)
;
5. HTTP REST API Endpoints (8081 - make sure that port is open)
- GET /balance?player=Notch → Returns Balance: 1000.0
ALL EVENTS LIKE VAULTBALANCECHANGEDEVENT ARE ONLY FIRED WHEN BALANCE CHANGES ARE MADE THROUGH THE EZVAULT PLUGIN ITSELF.