Developer API

Creating a custom CurrencyManager

1
public void example() {
2
/**
3
* #setCostCurrencyManager changes the currency used to purchase robot upgrades
4
* #setGeneratorCurrencyManager changes the currency used to generate money from the robots.
5
*/
6
Core.c.setCostCurrencyManager(
7
new CurrencyManager() {
8
9
@Override
10
public void load() {
11
// Pre-Load method to setup currency manager
12
}
13
14
@Override
15
public double getCurrentBalance(Player p) {
16
// Get the current balance of a Player.
17
return 0;
18
}
19
20
@Override
21
public boolean chargeAmount(Player p, double amt) {
22
// Charge the player for upgrades
23
return false;
24
}
25
26
@Override
27
public boolean withdraw(Player p, double amt) {
28
// Withdraw _to_ a players account.
29
return false;
30
}
31
}
32
);
33
}
Copied!

Getting Robots from by Location

1
Robot r = Robots.get().getByLocation(e.getRightClicked().getLocation());
2
if (r == null) return;
3
4
if (!r.getOwner().equals(e.getPlayer().getUniqueId().toString())) {
5
Core.c.getMsg().sendMessage(e.getPlayer(), Lang.notYourRobot);
6
return;
7
}
Copied!

Last modified 10mo ago