1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-11-23 23:31:05 +01:00

fix: don't register balance commands as main currency command

This commit is contained in:
Jozef Steinhübl 2024-02-25 18:00:28 +01:00
parent 9c0968ded2
commit b7c90ae5c8
No known key found for this signature in database
GPG key ID: E944BC293F5FF7E7
2 changed files with 7 additions and 11 deletions

View file

@ -34,7 +34,7 @@ public class BalanceCommand implements Command {
}; };
} }
private void handleBalance(CommandSender originalSender, CommandArguments args, Currency currency) { public void handleBalance(CommandSender originalSender, CommandArguments args, Currency currency) {
BukkitCommandSender sender = new BukkitCommandSender(originalSender, this.manager.audienceFactory); BukkitCommandSender sender = new BukkitCommandSender(originalSender, this.manager.audienceFactory);
OfflinePlayer target = (OfflinePlayer) args.get("target"); OfflinePlayer target = (OfflinePlayer) args.get("target");

View file

@ -57,21 +57,17 @@ public class BukkitCommandManager extends AbstractCommandManager {
private void registerCommands(@NonNull String name, @NonNull Currency currency) { private void registerCommands(@NonNull String name, @NonNull Currency currency) {
String permissionBase = "lighteco.currency." + currency.getIdentifier() + ".command."; String permissionBase = "lighteco.currency." + currency.getIdentifier() + ".command.";
// Balance BalanceCommand balanceCommand = new BalanceCommand(this, "balance", currency, permissionBase);
for (CommandAPICommand cmd : new BalanceCommand(
this,
name,
currency,
permissionBase
).multipleBuild()) {
cmd.register();
}
CommandAPICommand cmd = new CommandAPICommand(name) CommandAPICommand cmd = new CommandAPICommand(name)
.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())
.withSubcommands(new BalanceCommand(this, "balance", currency, permissionBase).multipleBuild()); .withSubcommands(balanceCommand.multipleBuild())
// We want balance to be the default command
.executesPlayer((sender, args) -> {
balanceCommand.handleBalance(sender, args, currency);
});
if (currency.isPayable()) if (currency.isPayable())
cmd = cmd.withSubcommand(new PayCommand(this, currency, permissionBase).build()); cmd = cmd.withSubcommand(new PayCommand(this, currency, permissionBase).build());