-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Admin commands. Revised history.
Added test classes.
- Loading branch information
1 parent
c4156eb
commit 5ac1d27
Showing
23 changed files
with
1,095 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
src/main/java/world/bentobox/bank/commands/AdminCommand.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/main/java/world/bentobox/bank/commands/admin/AdminBalanceCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package world.bentobox.bank.commands.admin; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
import world.bentobox.bank.Bank; | ||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.localization.TextVariables; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.database.objects.Island; | ||
|
||
/** | ||
* @author tastybento | ||
* | ||
*/ | ||
public class AdminBalanceCommand extends AdminCommand { | ||
|
||
private @Nullable Island island; | ||
|
||
public AdminBalanceCommand(CompositeCommand parent) { | ||
super(parent, "balance"); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("bank.admin.balance"); | ||
this.setDescription("bank.admin.description"); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(User user, String label, List<String> args) { | ||
// Check if there's the right number of arguments | ||
if (args.size() != 1) { | ||
this.showHelp(this, user); | ||
return false; | ||
} | ||
// Get target's island | ||
island = getIslands().getIsland(getWorld(), getAddon().getPlayers().getUser(args.get(0))); | ||
if (island == null) { | ||
user.sendMessage("general.errors.no-island"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
user.sendMessage("bank.balance.island-balance", TextVariables.NUMBER, ((Bank)getAddon()) | ||
.getVault() | ||
.format(((Bank)getAddon()) | ||
.getBankManager() | ||
.getBalance(island))); | ||
return true; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/world/bentobox/bank/commands/admin/AdminCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package world.bentobox.bank.commands.admin; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import world.bentobox.bank.Bank; | ||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.util.Util; | ||
|
||
/** | ||
* @author tastybento | ||
* | ||
*/ | ||
public class AdminCommand extends CompositeCommand { | ||
|
||
public AdminCommand(Bank bank, CompositeCommand adminCmd, String adminCommand) { | ||
super(bank, adminCmd, adminCommand); | ||
} | ||
|
||
public AdminCommand(CompositeCommand parent, String string) { | ||
super(parent, string); | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setDescription("bank.admin.description"); | ||
new AdminStatementCommand(this); | ||
new AdminBalanceCommand(this); | ||
new AdminGiveCommand(this); | ||
new AdminSetCommand(this); | ||
new AdminTakeCommand(this); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) { | ||
return Optional.of(Util.getOnlinePlayerList(user)); | ||
} | ||
} |
Oops, something went wrong.