mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-21 22:41:06 +01:00
fix: respect if currency is payable
This commit is contained in:
parent
5c0867c348
commit
341bc3eb44
3 changed files with 15 additions and 5 deletions
|
@ -32,13 +32,16 @@ public class BukkitCommandManager extends AbstractCommandManager {
|
|||
cmd.register();
|
||||
}
|
||||
|
||||
new CommandAPICommand(currency.getIdentifier())
|
||||
CommandAPICommand cmd = new CommandAPICommand(currency.getIdentifier())
|
||||
.withSubcommand(new SetCommand(this, currency, permissionBase).build())
|
||||
.withSubcommand(new GiveCommand(this, currency, permissionBase).build())
|
||||
.withSubcommand(new TakeCommand(this, currency, permissionBase).build())
|
||||
.withSubcommand(new PayCommand(this, currency, permissionBase).build())
|
||||
.withSubcommands(new BalanceCommand(this, "balance", currency, permissionBase).multipleBuild())
|
||||
.register();
|
||||
.withSubcommands(new BalanceCommand(this, "balance", currency, permissionBase).multipleBuild());
|
||||
|
||||
if (currency.isPayable())
|
||||
cmd = cmd.withSubcommand(new PayCommand(this, currency, permissionBase).build());
|
||||
|
||||
cmd.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +57,8 @@ public class BukkitCommandManager extends AbstractCommandManager {
|
|||
registerCurrencyCommand(currency);
|
||||
|
||||
// Expose pay as main command
|
||||
new PayCommand(this, currency, permissionBase).build().register();
|
||||
if (currency.isPayable())
|
||||
new PayCommand(this, currency, permissionBase).build().register();
|
||||
|
||||
// Expose balance as main command
|
||||
for (CommandAPICommand cmd : new BalanceCommand(
|
||||
|
|
|
@ -36,6 +36,10 @@ public class Currency {
|
|||
return proxy.isPayable();
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return proxy.fractionalDigits();
|
||||
}
|
||||
|
||||
public List<User> getTopUsers(int length) {
|
||||
List<User> users = new ArrayList<>();
|
||||
users.add(new User(plugin, new UUID(0, 0)));
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.Setter;
|
|||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -43,6 +44,7 @@ public class User {
|
|||
throw new IllegalArgumentException("Balance cannot be negative");
|
||||
}
|
||||
|
||||
balance = balance.setScale(currency.fractionalDigits(), RoundingMode.DOWN);
|
||||
balances.put(currency, balance);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue