[BANKING] Small bits for future
Some checks failed
build / build (21) (push) Has been cancelled

This commit is contained in:
Jkibbels 2024-11-10 01:01:44 -05:00
parent a42d196c3c
commit 3abdf9b184
4 changed files with 59 additions and 3 deletions

View File

@ -71,6 +71,26 @@ public final class BankManager {
return bank; return bank;
} }
public void AdminSubtractFunds(String accountId, Integer amount) {
}
public void AdminSetFunds(String accountId, Integer amount) {
}
public void AdminAddFunds(String accountId, Integer amount) {
}
public void InitiateBankFundsTransfer(String fromAccount, String toAccount) {
}
public void InitiateBankAccountClosure(String bankIdentifier, ServerPlayerEntity player, String bankAccountId) {
}
public void InitiateBankAccountCreation(String bankIdentifier, ServerPlayerEntity player, String accountType) { public void InitiateBankAccountCreation(String bankIdentifier, ServerPlayerEntity player, String accountType) {
Boolean success = false; Boolean success = false;
System.out.println("initiating bank creation"); System.out.println("initiating bank creation");

View File

@ -6,6 +6,8 @@ import java.util.List;
// TODO: Add ability to store NBT data of items in the future so we can store not just money but items too // TODO: Add ability to store NBT data of items in the future so we can store not just money but items too
// like a safety deposit box // like a safety deposit box
public class IndividualAccount { public class IndividualAccount {
private String globalAccountNumber;
private String bankLetterIdentifier;
private String accountNumber; private String accountNumber;
private String accountNumberAlias; private String accountNumberAlias;
private Integer routingNumber; // Will always be the bank it's in private Integer routingNumber; // Will always be the bank it's in
@ -21,7 +23,7 @@ public class IndividualAccount {
public IndividualAccount(String accountNumber, Integer routingNumber, List<String> holders, public IndividualAccount(String accountNumber, Integer routingNumber, List<String> holders,
List<String> accountHolderUuids, Boolean allowNegativeBalance, Integer initialBalance, List<String> accountHolderUuids, Boolean allowNegativeBalance, Integer initialBalance,
String alias, Integer accountType) { String alias, Integer accountType, String bankLetterIdentifier) {
System.out.println("Called to create new IndividualAccount with following values: " + accountNumber + " " + routingNumber + " " + holders + " " + System.out.println("Called to create new IndividualAccount with following values: " + accountNumber + " " + routingNumber + " " + holders + " " +
accountHolderUuids + " " + allowNegativeBalance + " " + initialBalance + " " + alias + " " + accountType); accountHolderUuids + " " + allowNegativeBalance + " " + initialBalance + " " + alias + " " + accountType);
@ -33,6 +35,9 @@ public class IndividualAccount {
this.accountBalance = initialBalance; this.accountBalance = initialBalance;
this.accountNumberAlias = alias; this.accountNumberAlias = alias;
this.accountType = accountType; this.accountType = accountType;
this.bankLetterIdentifier = bankLetterIdentifier;
this.globalAccountNumber = bankLetterIdentifier + "-" + routingNumber + "-" + accountType + accountNumber;
} }
// TODO: Make this a map in the future // TODO: Make this a map in the future
@ -126,4 +131,8 @@ public class IndividualAccount {
return routingNumber; return routingNumber;
} }
public String GetGlobalAccountNumber() {
return globalAccountNumber;
}
} }

View File

@ -242,7 +242,7 @@ public class IndividualBank {
if (!accounts.accountsList.containsKey(actualAccountNumber)) { if (!accounts.accountsList.containsKey(actualAccountNumber)) {
IndividualAccount newAccount = new IndividualAccount(actualAccountNumber, this.routingNumber, List.of(holderName), IndividualAccount newAccount = new IndividualAccount(actualAccountNumber, this.routingNumber, List.of(holderName),
List.of(holderUuid), false, 0, List.of(holderUuid), false, 0,
"", ACCOUNT_TYPES.get(accountTypeStr)); "", ACCOUNT_TYPES.get(accountTypeStr), bankFourLetterIdentifier);
System.out.println("Updating accounts list for this bank"); System.out.println("Updating accounts list for this bank");
UpdateBankAccounts(holderName, holderUuid, actualAccountNumber, newAccount); UpdateBankAccounts(holderName, holderUuid, actualAccountNumber, newAccount);
success = true; success = true;

View File

@ -168,6 +168,9 @@ public class BankCommands {
case "accounts": case "accounts":
ManageAccounts(context.getSource().getPlayer(), formattedArgList.subList(1, formattedArgList.size())); ManageAccounts(context.getSource().getPlayer(), formattedArgList.subList(1, formattedArgList.size()));
break; break;
case "admin":
AdminCommand(context.getSource().getPlayer(), formattedArgList.subList(1, formattedArgList.size()));
break;
default: default:
if (context.getSource().isExecutedByPlayer()) { if (context.getSource().isExecutedByPlayer()) {
context.getSource().getPlayer().sendMessage(Text.of("You have entered an improperly formatted message. Please reference the bank manual if you are confused how to form a command!")); context.getSource().getPlayer().sendMessage(Text.of("You have entered an improperly formatted message. Please reference the bank manual if you are confused how to form a command!"));
@ -177,6 +180,30 @@ public class BankCommands {
return 0; return 0;
} }
// Possible code paths ({}=required, []=optionals, ()=explanation):
// REQUIRED (path) = {SetBal|AddMoney|SubMoney} {LONG_ID|BANK_ID} {amount} (Depending on context, changes balance somehow from an account ID or bank)
// REQUIRED (path) = {GetBal} {LONG_ID:BANK_ID} (Gets the balance of a bank account or bank)
// REQUIRED (path) = {accounts} {list} {PLAYER_NAME} (Returns summarized account information on a player)
// REQUIRED (path) = {accounts} {move} {LONG_ID} to {BANK_ID} (Will move account to diff bank. May generate new account ID)
// REQUIRED (path) = {accounts} {force-close} {LOND_ID} (Forces an account to be closed. Money is returned to server bank account)
// REQUIRED (path) = {accounts} {add} to {PLAYER_NAME} [BANK_ID] (Adds an account to a player to server by default. Specify other for other)
// REQUIRED (path) = {accounts} {transactions} from {LONG_ID} (Gets transaction report from an account by ID)
// REQUIRED (path) = {accounts} {lock} {LONG_ID:USER} (Locks a specific bank account OR all bank accounts owned by $USER)
// REQUIRED (path) = {create-bank} {BANK_ID} (Create a new bank. Default is owned by server)
// REQUIRED (path) = {close-bank} {BANK_ID} (Closing a bank forces a close on all accounts. Banks money is returned to server bank)
// REQUIRED (path) = {lock-bank} {BANK_ID} (Freezes all activities through a bank)
// REQUIRED (path) = {unlock} {BANK_ID:ACCOUNT_ID:USER} (will unlock a bank, account, or all of a users accounts)
// REQUIRED (path) = {wire} from {ACCOUNT_ID} to {ACCOUNT_ID} (Forces a wire from one account to another. Overrides overdraft setting since it's administrative)
// REQUIRED (path) = {get-server-allowance} (Returns the rate of which the server adds money to itself magically & how much)
// REQUIRED (path) = {set-server-allowance} {amount} {interval} (Sets the magic allowance rate of server & period in which it does it to add money magically to server bank)
public void AdminCommand(ServerPlayerEntity sourcePlayer, List<String> argList) {
if (sourcePlayer.hasPermissionLevel(4)) {
} else {
sourcePlayer.sendMessage(Text.of("Only admins can use this command!"));
}
}
// Possible code paths: // Possible code paths:
// REQUIRED = {Routing # or Bank name} // REQUIRED = {Routing # or Bank name}
// OPTIONAL = [] // OPTIONAL = []
@ -184,7 +211,6 @@ public class BankCommands {
System.out.println("Manage accounts arg list is { " + argList + " }"); System.out.println("Manage accounts arg list is { " + argList + " }");
if (argList.size() > 0) { if (argList.size() > 0) {
// TODO: For now we assume they reference the bank name and not routing # // TODO: For now we assume they reference the bank name and not routing #
Boolean success = false;
String bankName = argList.get(0).toUpperCase(); String bankName = argList.get(0).toUpperCase();
IndividualBank bank = BankManager.GetInstance().GetBankByName(bankName); IndividualBank bank = BankManager.GetInstance().GetBankByName(bankName);
System.out.println("Test print on memory"); System.out.println("Test print on memory");
@ -196,6 +222,7 @@ public class BankCommands {
sourcePlayer.sendMessage(Text.of("------------[BANK INFO FOR " + bankName.toUpperCase() + "]------------")); sourcePlayer.sendMessage(Text.of("------------[BANK INFO FOR " + bankName.toUpperCase() + "]------------"));
for (int i = 0; i < userAccounts.size(); i++) { for (int i = 0; i < userAccounts.size(); i++) {
sourcePlayer.sendMessage(Text.of("ACCOUNT NUMBER: " + userAccounts.get(i).GetAccountNumber())); sourcePlayer.sendMessage(Text.of("ACCOUNT NUMBER: " + userAccounts.get(i).GetAccountNumber()));
sourcePlayer.sendMessage(Text.of("GLOBAL ACCOUNT NUMBER: " + userAccounts.get(i).GetGlobalAccountNumber()));
sourcePlayer.sendMessage(Text.of("HOLDERS: " + userAccounts.get(i).GetAccountHolders())); sourcePlayer.sendMessage(Text.of("HOLDERS: " + userAccounts.get(i).GetAccountHolders()));
sourcePlayer.sendMessage(Text.of("BALANCE: " + userAccounts.get(i).GetAccountBalance())); sourcePlayer.sendMessage(Text.of("BALANCE: " + userAccounts.get(i).GetAccountBalance()));
sourcePlayer.sendMessage(Text.of("\n")); sourcePlayer.sendMessage(Text.of("\n"));