mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-22 06:51:05 +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();
|
cmd.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
new CommandAPICommand(currency.getIdentifier())
|
CommandAPICommand cmd = new CommandAPICommand(currency.getIdentifier())
|
||||||
.withSubcommand(new SetCommand(this, currency, permissionBase).build())
|
.withSubcommand(new SetCommand(this, currency, permissionBase).build())
|
||||||
.withSubcommand(new GiveCommand(this, currency, permissionBase).build())
|
.withSubcommand(new GiveCommand(this, currency, permissionBase).build())
|
||||||
.withSubcommand(new TakeCommand(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());
|
||||||
.withSubcommands(new BalanceCommand(this, "balance", currency, permissionBase).multipleBuild())
|
|
||||||
.register();
|
if (currency.isPayable())
|
||||||
|
cmd = cmd.withSubcommand(new PayCommand(this, currency, permissionBase).build());
|
||||||
|
|
||||||
|
cmd.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +57,8 @@ public class BukkitCommandManager extends AbstractCommandManager {
|
||||||
registerCurrencyCommand(currency);
|
registerCurrencyCommand(currency);
|
||||||
|
|
||||||
// Expose pay as main command
|
// 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
|
// Expose balance as main command
|
||||||
for (CommandAPICommand cmd : new BalanceCommand(
|
for (CommandAPICommand cmd : new BalanceCommand(
|
||||||
|
|
|
@ -36,6 +36,10 @@ public class Currency {
|
||||||
return proxy.isPayable();
|
return proxy.isPayable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int fractionalDigits() {
|
||||||
|
return proxy.fractionalDigits();
|
||||||
|
}
|
||||||
|
|
||||||
public List<User> getTopUsers(int length) {
|
public List<User> getTopUsers(int length) {
|
||||||
List<User> users = new ArrayList<>();
|
List<User> users = new ArrayList<>();
|
||||||
users.add(new User(plugin, new UUID(0, 0)));
|
users.add(new User(plugin, new UUID(0, 0)));
|
||||||
|
|
|
@ -8,6 +8,7 @@ import lombok.Setter;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ public class User {
|
||||||
throw new IllegalArgumentException("Balance cannot be negative");
|
throw new IllegalArgumentException("Balance cannot be negative");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
balance = balance.setScale(currency.fractionalDigits(), RoundingMode.DOWN);
|
||||||
balances.put(currency, balance);
|
balances.put(currency, balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue