public abstract class SQLStorageEngine extends StorageEngine
| Modifier and Type | Field and Description |
|---|---|
protected AccessTable |
accessTable |
protected AccountTable |
accountTable |
protected BalanceTable |
balanceTable |
protected ConfigTable |
configTable |
protected CurrencyTable |
currencyTable |
protected com.zaxxer.hikari.HikariDataSource |
db |
protected ExchangeTable |
exchangeTable |
protected LogTable |
logTable |
protected java.lang.String |
tablePrefix |
protected WorldGroupTable |
worldGroupTable |
| Constructor and Description |
|---|
SQLStorageEngine() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accountExist(java.lang.String name,
boolean bankAccount)
Checks if a account exist
|
void |
cleanLog(java.sql.Timestamp timestamp)
Clear the logs before the timestamp given
|
void |
commit()
Commit the changes.
|
boolean |
deleteAccount(java.lang.String name,
boolean bankAccount)
Delete a account from the backend
|
void |
deleteCurrency(Currency currency)
Delete a currency from the storage
|
void |
disable()
Disable the storage engine.
|
void |
disableAutoCommit()
Disable auto-commit in the storage engine
|
void |
enableAutoCommit()
Enable auto-commit in the storage engine (default)
|
Account |
getAccount(java.lang.String name,
boolean bankAccount,
boolean createDefault)
Retrieve an account from the storage.
|
Account |
getAccount(java.util.UUID uuid)
Retrieve an account from the storage.
|
java.util.List<java.lang.String> |
getAllAccounts(boolean bank)
Retrieve all account names
|
java.util.List<Balance> |
getAllBalance(Account account)
Retrieve all the balance of an account
|
java.util.Map<java.lang.String,Currency> |
getAllCurrencies()
Retrieve all currencies
|
java.util.List<java.lang.String> |
getAllCurrencyNames()
Get the names of all the currencies in the system.
|
java.util.List<Balance> |
getAllWorldBalance(Account account,
java.lang.String worldName)
Retrieve all balance from a world
|
double |
getBalance(Account account,
Currency currency,
java.lang.String world)
Retrieve the balance of an account
|
java.lang.String[] |
getBankAccountList(java.lang.String sender)
Retrieve the list of bank account this player have access to
|
java.lang.String |
getConfigEntry(java.lang.String name)
Retrieve the configuration value
|
Currency |
getCurrency(java.lang.String name)
Retrieve a currency
|
java.util.List<CurrencyRatesCommand.CurrencyRateEntry> |
getCurrencyExchanges()
Get the exchange rates of every currencies
|
double |
getExchangeRate(Currency currency,
Currency otherCurrency)
Retrieve the exchange rate between 2 currencies
|
java.util.List<LogCommand.LogEntry> |
getLog(Account user,
int page)
Get the logs of an account
|
java.util.List<TopCommand.TopEntry> |
getTopEntry(int page,
Currency currency,
java.lang.String world)
Retrieve a list of the top accounts
|
java.util.Map<java.lang.String,WorldGroup> |
getWorldGroups()
Get all the world groups in the system
|
void |
removeWorldGroup(java.lang.String group)
Remove a world group from the system
|
java.util.Map<java.lang.String,AccountACLValue> |
retrieveACL(Account account)
Retrieve the ACL listing for a bank account
|
java.lang.String |
retrieveWorldGroupWorlds(java.lang.String name)
Get the raw value of the world list of a world group.
|
AccountACLValue |
saveACL(Account account,
java.lang.String name,
boolean deposit,
boolean withdraw,
boolean acl,
boolean balance,
boolean owner)
Save the ACL setting of a bank account
|
void |
saveCurrency(java.lang.String oldName,
Currency currency)
Save a currency in the backend
|
void |
saveImporterUsers(java.util.List<Converter.User> userList)
Save the converted accounts into the backend
|
void |
saveLog(LogInfo info,
Cause cause,
java.lang.String causeReason,
Account account,
double amount,
Currency currency,
java.lang.String worldName)
Write a transaction to the Log.
|
void |
saveLog(LogInfo info,
Cause cause,
java.lang.String causeReason,
Account account,
double amount,
Currency currency,
java.lang.String worldName,
java.sql.Timestamp timestamp) |
void |
saveWorldGroup(java.lang.String name,
java.lang.String worldList)
Save a world group
|
double |
setBalance(Account account,
double amount,
Currency currency,
java.lang.String world)
Set the balance of the account
|
void |
setConfigEntry(java.lang.String name,
java.lang.String value)
Set a configuration value in the database
|
void |
setDefaultBankCurrency(Currency currency)
Set the default bank creation currency.
|
void |
setDefaultCurrency(Currency currency)
Set the default currency of the system
|
void |
setExchangeRate(Currency currency,
Currency otherCurrency,
double amount)
Set the exchange between 2 currencies in the backend
|
void |
setIgnoreACL(Account account,
boolean ignoreACL)
Set if the account must ignore the ACL
|
void |
setInfiniteMoney(Account account,
boolean infinite)
Set if the account have infinite money
|
void |
updateUsername(java.lang.String name,
java.util.UUID uuid)
Update the username in the account
|
void |
updateUUID(java.lang.String name,
java.util.UUID uuid)
Set the UUID of the account if it exists
|
getAccountprotected java.lang.String tablePrefix
protected com.zaxxer.hikari.HikariDataSource db
protected AccessTable accessTable
protected AccountTable accountTable
protected BalanceTable balanceTable
protected ConfigTable configTable
protected CurrencyTable currencyTable
protected ExchangeTable exchangeTable
protected LogTable logTable
protected WorldGroupTable worldGroupTable
public void disable()
StorageEnginedisable in class StorageEnginepublic Account getAccount(java.lang.String name, boolean bankAccount, boolean createDefault)
StorageEnginegetAccount in class StorageEnginename - The account namebankAccount - If the account is a bank account or notcreateDefault - If it adds the default balance in or notpublic Account getAccount(java.util.UUID uuid)
StorageEnginegetAccount in class StorageEngineuuid - The UUID of the playerpublic java.util.List<java.lang.String> getAllAccounts(boolean bank)
StorageEnginegetAllAccounts in class StorageEnginebank - If we want to retrieve the bank accounts or notpublic void saveLog(LogInfo info, Cause cause, java.lang.String causeReason, Account account, double amount, Currency currency, java.lang.String worldName)
StorageEnginesaveLog in class StorageEngineinfo - The type of transaction to log.cause - The cause of the transaction.causeReason - The reason of the causeaccount - The account being impacted by the changeamount - The amount of money in this transaction.currency - The currency associated with this transactionworldName - The world name associated with this transactionpublic void saveLog(LogInfo info, Cause cause, java.lang.String causeReason, Account account, double amount, Currency currency, java.lang.String worldName, java.sql.Timestamp timestamp)
saveLog in class StorageEnginepublic java.lang.String getConfigEntry(java.lang.String name)
StorageEnginegetConfigEntry in class StorageEnginename - The name of the valuepublic void setConfigEntry(java.lang.String name,
java.lang.String value)
StorageEnginesetConfigEntry in class StorageEnginename - The name of the valuevalue - The actual valuepublic java.util.List<Balance> getAllBalance(Account account)
StorageEnginegetAllBalance in class StorageEngineaccount - The account to retrieve the balance frompublic java.util.List<Balance> getAllWorldBalance(Account account, java.lang.String worldName)
StorageEnginegetAllWorldBalance in class StorageEngineaccount - The account to retrieve the balance fromworldName - The world group to retrieve the balance frompublic double getBalance(Account account, Currency currency, java.lang.String world)
StorageEnginegetBalance in class StorageEngineaccount - The account to retrieve the balance fromcurrency - The currencyworld - The world grouppublic double setBalance(Account account, double amount, Currency currency, java.lang.String world)
StorageEnginesetBalance in class StorageEngineaccount - The account that the balance is set in.amount - The amount of money being placedcurrency - The Currencyworld - The world grouppublic void setInfiniteMoney(Account account, boolean infinite)
StorageEnginesetInfiniteMoney in class StorageEngineaccount - The account to modifyinfinite - If the account have infinite money or notpublic void setIgnoreACL(Account account, boolean ignoreACL)
StorageEnginesetIgnoreACL in class StorageEngineaccount - The account to modifyignoreACL - If the account must ignore the ACL or notpublic java.util.Map<java.lang.String,AccountACLValue> retrieveACL(Account account)
StorageEngineretrieveACL in class StorageEngineaccount - The bank accountpublic AccountACLValue saveACL(Account account, java.lang.String name, boolean deposit, boolean withdraw, boolean acl, boolean balance, boolean owner)
StorageEnginesaveACL in class StorageEngineaccount - The accountname - The player namedeposit - If the player can depositwithdraw - If the player can withdrawacl - If the player can modify the ACLbalance - If the player can show the balanceowner - If the player is the ownerpublic double getExchangeRate(Currency currency, Currency otherCurrency) throws NoExchangeRate
StorageEnginegetExchangeRate in class StorageEnginecurrency - The currency to convert fromotherCurrency - The currency to convert toNoExchangeRate - If there's no exchange rate, this event is thrown.public void setExchangeRate(Currency currency, Currency otherCurrency, double amount)
StorageEnginesetExchangeRate in class StorageEnginecurrency - The currency to convert fromotherCurrency - The currency to convert toamount - The exchange rate (Example: 1.3 will make 1 Currency transform to 1.3 otherCurrency)public void saveCurrency(java.lang.String oldName,
Currency currency)
StorageEnginesaveCurrency in class StorageEngineoldName - The name of the currency if overriding a existing currencycurrency - The currency to savepublic void deleteCurrency(Currency currency)
StorageEnginedeleteCurrency in class StorageEnginecurrency - The currency to deletepublic void updateUsername(java.lang.String name,
java.util.UUID uuid)
StorageEngineupdateUsername in class StorageEnginename - The name of the playeruuid - The UUID of the playerpublic void updateUUID(java.lang.String name,
java.util.UUID uuid)
StorageEngineupdateUUID in class StorageEnginename - The player nameuuid - the UUID of the playerpublic java.util.Map<java.lang.String,WorldGroup> getWorldGroups()
StorageEnginegetWorldGroups in class StorageEnginepublic void removeWorldGroup(java.lang.String group)
StorageEngineremoveWorldGroup in class StorageEnginegroup - The name of the world grouppublic java.lang.String[] getBankAccountList(java.lang.String sender)
StorageEnginegetBankAccountList in class StorageEnginesender - The player namepublic java.util.List<LogCommand.LogEntry> getLog(Account user, int page)
StorageEnginegetLog in class StorageEngineuser - The account to retrieve the log frompage - The page number of the entry.public java.util.List<TopCommand.TopEntry> getTopEntry(int page, Currency currency, java.lang.String world)
StorageEnginegetTopEntry in class StorageEnginepage - The page numbercurrency - The currencyworld - The world group.public java.util.List<CurrencyRatesCommand.CurrencyRateEntry> getCurrencyExchanges()
StorageEnginegetCurrencyExchanges in class StorageEnginepublic void cleanLog(java.sql.Timestamp timestamp)
StorageEnginecleanLog in class StorageEnginetimestamp - The lowest date a log entry can havepublic boolean deleteAccount(java.lang.String name,
boolean bankAccount)
StorageEnginedeleteAccount in class StorageEnginename - The name of the accountbankAccount - If the account is a bank account or notpublic boolean accountExist(java.lang.String name,
boolean bankAccount)
StorageEngineaccountExist in class StorageEnginename - The name of the accountbankAccount - If the account is a bank account or notpublic void saveWorldGroup(java.lang.String name,
java.lang.String worldList)
StorageEnginesaveWorldGroup in class StorageEnginename - The name of the world group.worldList - The worlds being in this world group seperated by , .public java.util.List<java.lang.String> getAllCurrencyNames()
StorageEnginegetAllCurrencyNames in class StorageEnginepublic void setDefaultCurrency(Currency currency)
StorageEnginesetDefaultCurrency in class StorageEnginecurrency - The currency to set as defaultpublic void setDefaultBankCurrency(Currency currency)
StorageEnginesetDefaultBankCurrency in class StorageEnginecurrency - The currencypublic Currency getCurrency(java.lang.String name)
StorageEnginegetCurrency in class StorageEnginename - The name of the currencypublic java.util.Map<java.lang.String,Currency> getAllCurrencies()
StorageEnginegetAllCurrencies in class StorageEnginepublic java.lang.String retrieveWorldGroupWorlds(java.lang.String name)
StorageEngineretrieveWorldGroupWorlds in class StorageEnginename - The name of the world group.public void saveImporterUsers(java.util.List<Converter.User> userList)
StorageEnginesaveImporterUsers in class StorageEngineuserList - The user list being convertedpublic void disableAutoCommit()
StorageEnginedisableAutoCommit in class StorageEnginepublic void enableAutoCommit()
StorageEngineenableAutoCommit in class StorageEnginepublic void commit()
StorageEnginecommit in class StorageEngine