Skip to content

Commit

Permalink
all: auto code fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Feb 3, 2025
1 parent 2373d21 commit 5decc59
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ abstract class Currency(

abstract suspend fun setPresentationFormat(new: String)

abstract suspend fun registerLocale(locale: Locale, dispNameSingular: String, dispNamePlural: String, decimal: String)
abstract suspend fun registerLocale(
locale: Locale,
dispNameSingular: String,
dispNamePlural: String,
decimal: String,
)

abstract suspend fun unregisterLocale(locale: Locale)

Expand Down
6 changes: 4 additions & 2 deletions docs/brainstorming/SQL_Planner_1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Every time a player joins, it updates their username here.
CREATE TABLE IF NOT EXISTS ArcEco_PlayerCache
(
/* PlayerUUID, PlayerUsername, Timestamp */
player_uuid VARCHAR
player_uuid
VARCHAR
(
32
) PRIMARY KEY,
Expand Down Expand Up @@ -216,7 +217,8 @@ CREATE TABLE IF NOT EXISTS ArcEco_NonPlayerAccountTransactions
CREATE TABLE IF NOT EXISTS ArcEco_CurrentIds
(
/* TableNamesEnum, Value */
table_name VARCHAR
table_name
VARCHAR
(
64
) PRIMARY KEY,
Expand Down
3 changes: 2 additions & 1 deletion docs/brainstorming/SQL_Planner_2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*/
CREATE TABLE IF NOT EXISTS arceco_player_usernames
(
uuid CHAR
uuid
CHAR
(
36
) NOT NULL PRIMARY KEY,
Expand Down
3 changes: 2 additions & 1 deletion plugin-bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@
</relocation>
<relocation>
<pattern>dev.jorel.commandapi</pattern>
<shadedPattern>io.github.arcaneplugins.polyconomy.plugin.bukkit.lib.commandapi</shadedPattern>
<shadedPattern>io.github.arcaneplugins.polyconomy.plugin.bukkit.lib.commandapi
</shadedPattern>
</relocation>
<relocation>
<pattern>de.themoep.minedown</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ object BalanceCommand : InternalCmd {
throw plugin.translations.commandApiFailure()
}

val currency: Currency = args.getOptional("currency").orElseGet { runBlocking {
plugin.storageManager.handler.getPrimaryCurrency()
} } as Currency
val currency: Currency = args.getOptional("currency").orElseGet {
runBlocking {
plugin.storageManager.handler.getPrimaryCurrency()
}
} as Currency

val balance = runBlocking {
plugin.storageManager.handler.getOrCreatePlayerAccount(
Expand All @@ -53,11 +55,13 @@ object BalanceCommand : InternalCmd {
currency.format(balance, plugin.settingsCfg.defaultLocale())
}

plugin.translations.commandBalanceView.sendTo(sender, placeholders = mapOf(
"target-name" to Supplier { targetPlayer.name ?: targetPlayer.uniqueId.toString() },
"balance" to Supplier { balanceFmt },
"currency" to Supplier { currency.name },
))
plugin.translations.commandBalanceView.sendTo(
sender, placeholders = mapOf(
"target-name" to Supplier { targetPlayer.name ?: targetPlayer.uniqueId.toString() },
"balance" to Supplier { balanceFmt },
"currency" to Supplier { currency.name },
)
)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ object BalancetopCommand : InternalCmd {
val page = args.getOptional("page").orElse(1) as Int

if (page < 1) {
plugin.translations.commandBalancetopErrorPageTooLow.sendTo(sender, placeholders = mapOf(
"%page%" to Supplier { page.toString()}
plugin.translations.commandBalancetopErrorPageTooLow.sendTo(
sender, placeholders = mapOf(
"%page%" to Supplier { page.toString() }
))
throw plugin.translations.commandApiFailure()
}
Expand Down Expand Up @@ -64,7 +65,8 @@ object BalancetopCommand : InternalCmd {
currency.getDisplayName(true, locale)
}

plugin.translations.commandBalancetopHeader.sendTo(sender, placeholders = mapOf(
plugin.translations.commandBalancetopHeader.sendTo(
sender, placeholders = mapOf(
"page" to Supplier { page.toString() },
"currency" to Supplier { currencyName }
))
Expand All @@ -73,7 +75,8 @@ object BalancetopCommand : InternalCmd {
plugin.translations.commandBalancetopNoEntriesOnPage.sendTo(sender)
} else {
baltop.onEachIndexed { index, (username, balance) ->
plugin.translations.commandBalancetopEntry.sendTo(sender, placeholders = mapOf(
plugin.translations.commandBalancetopEntry.sendTo(
sender, placeholders = mapOf(
"rank" to Supplier { (((page - 1) * PAGE_SIZE) + index + 1).toString() },
"target-name" to Supplier { username },
"balance" to Supplier { runBlocking { currency.format(balance, locale) } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ object PayCommand : InternalCmd {
val amountBd = amount.toBigDecimal()

if (amount <= 0) {
plugin.translations.commandGenericAmountZeroOrLess.sendTo(sender, placeholders = mapOf(
plugin.translations.commandGenericAmountZeroOrLess.sendTo(
sender, placeholders = mapOf(
"amount" to Supplier { amount.toString() }
))
throw plugin.translations.commandApiFailure()
Expand All @@ -68,7 +69,8 @@ object PayCommand : InternalCmd {
}

if (!canAfford) {
plugin.translations.commandPayErrorCantAfford.sendTo(sender, placeholders = mapOf(
plugin.translations.commandPayErrorCantAfford.sendTo(
sender, placeholders = mapOf(
"amount" to Supplier { amount.toString() },
"balance" to Supplier { runBlocking { senderAccount.getBalance(currency).toString() } },
"currency" to Supplier { currency.name }
Expand Down Expand Up @@ -111,13 +113,15 @@ object PayCommand : InternalCmd {
currency.format(senderAccount.getBalance(currency), plugin.settingsCfg.defaultLocale())
}

plugin.translations.commandPaySuccess.sendTo(sender, placeholders = mapOf(
"amount" to Supplier { amountFmt },
"balance" to Supplier { newBalance },
"currency" to Supplier { currency.name },
"target-name" to Supplier { targetPlayer.name ?: targetPlayer.uniqueId.toString() },
"target-balance" to Supplier { runBlocking { targetAccount.getBalance(currency).toString() } },
))
plugin.translations.commandPaySuccess.sendTo(
sender, placeholders = mapOf(
"amount" to Supplier { amountFmt },
"balance" to Supplier { newBalance },
"currency" to Supplier { currency.name },
"target-name" to Supplier { targetPlayer.name ?: targetPlayer.uniqueId.toString() },
"target-balance" to Supplier { runBlocking { targetAccount.getBalance(currency).toString() } },
)
)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ object CurrencySubcommand : InternalCmd {
.withPermission(PolyconomyPerm.COMMAND_POLYCONOMY_CURRENCY_SET.toString())
.withArguments(
CustomArguments.currencyArgument(plugin, "currency"),
CustomArguments.identityStringArgument(plugin, "new"))
CustomArguments.identityStringArgument(plugin, "new")
)
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency
val new = args.get("new") as String
Expand All @@ -55,7 +56,8 @@ object CurrencySubcommand : InternalCmd {
.withPermission(PolyconomyPerm.COMMAND_POLYCONOMY_CURRENCY_SET.toString())
.withArguments(
CustomArguments.currencyArgument(plugin, "currency"),
DoubleArgument("newValue"))
DoubleArgument("newValue")
)
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency
val newValue = args.get("newValue") as Double
Expand All @@ -75,7 +77,8 @@ object CurrencySubcommand : InternalCmd {
.withPermission(PolyconomyPerm.COMMAND_POLYCONOMY_CURRENCY_SET.toString())
.withArguments(
CustomArguments.currencyArgument(plugin, "currency"),
TextArgument("newValue"))
TextArgument("newValue")
)
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency
val newValue = args.get("newValue") as String
Expand All @@ -92,8 +95,10 @@ object CurrencySubcommand : InternalCmd {
}),
CommandAPICommand("amountFormat")
.withPermission(PolyconomyPerm.COMMAND_POLYCONOMY_CURRENCY_SET.toString())
.withArguments(CustomArguments.currencyArgument(plugin, "currency"),
TextArgument("newValue"))
.withArguments(
CustomArguments.currencyArgument(plugin, "currency"),
TextArgument("newValue")
)
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency
val newValue = args.get("newValue") as String
Expand Down Expand Up @@ -127,8 +132,10 @@ object CurrencySubcommand : InternalCmd {
}),
CommandAPICommand("conversionRate")
.withPermission(PolyconomyPerm.COMMAND_POLYCONOMY_CURRENCY_SET.toString())
.withArguments(CustomArguments.currencyArgument(plugin, "currency"),
DoubleArgument("newValue"))
.withArguments(
CustomArguments.currencyArgument(plugin, "currency"),
DoubleArgument("newValue")
)
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency
val newValue = args.get("newValue") as Double
Expand Down Expand Up @@ -269,7 +276,7 @@ object CurrencySubcommand : InternalCmd {
sender.sendMessage("${ChatColor.YELLOW}${operation}: Processing...")

// if they are trying to unregister the last locale left, stop
if (runBlocking { currency.getLocaleDecimalMap().size < 2}) {
if (runBlocking { currency.getLocaleDecimalMap().size < 2 }) {
// todo translatable message
sender.sendMessage("${RED}${operation} Error: There must be 2 or more locales in this currency so the currency has another locale to fallback one. Try creating the new locale first with `register`, or adjust the values of this existing one with `set`.")
throw plugin.translations.commandApiFailure()
Expand Down Expand Up @@ -311,23 +318,28 @@ object CurrencySubcommand : InternalCmd {
val dispNameSingular = args.get("dispNameSingular") as String
val dispNamePlural = args.get("dispNamePlural") as String
val dispDecimal = args.get("dispDecimal") as String
val presentationFormat: String = args.getOptional("presentationFormat").orElse(Currency.DEFAULT_PRESENTATION_FORMAT) as String
val amountFormat: String = args.getOptional("amountFormat").orElse(Currency.DEFAULT_AMOUNT_FORMAT) as String
val presentationFormat: String =
args.getOptional("presentationFormat").orElse(Currency.DEFAULT_PRESENTATION_FORMAT) as String
val amountFormat: String =
args.getOptional("amountFormat").orElse(Currency.DEFAULT_AMOUNT_FORMAT) as String

val currencyAlreadyExists = runBlocking {
plugin.storageManager.handler.hasCurrency(name)
}

if (currencyAlreadyExists) {
plugin.translations.commandPolyconomyCurrencyRegisterErrorAlreadyExists.sendTo(sender, mapOf(
plugin.translations.commandPolyconomyCurrencyRegisterErrorAlreadyExists.sendTo(
sender, mapOf(
"currency" to Supplier { name }
))
throw plugin.translations.commandApiFailure()
}

plugin.translations.commandPolyconomyCurrencyRegisterStarted.sendTo(sender, placeholders = mapOf(
"currency" to Supplier { name },
))
plugin.translations.commandPolyconomyCurrencyRegisterStarted.sendTo(
sender, placeholders = mapOf(
"currency" to Supplier { name },
)
)

Bukkit.getServer().scheduler.runTaskAsynchronously(plugin) { ->
runBlocking {
Expand All @@ -344,7 +356,8 @@ object CurrencySubcommand : InternalCmd {
)
}

plugin.translations.commandPolyconomyCurrencyRegisterSuccess.sendTo(sender, placeholders = mapOf(
plugin.translations.commandPolyconomyCurrencyRegisterSuccess.sendTo(
sender, placeholders = mapOf(
"currency" to Supplier { name }
))
}
Expand All @@ -360,13 +373,15 @@ object CurrencySubcommand : InternalCmd {
.executes(CommandExecutor { sender, args ->
val currency = args.get("currency") as Currency

plugin.translations.commandPolyconomyCurrencyUnregisterStarted.sendTo(sender, mapOf(
plugin.translations.commandPolyconomyCurrencyUnregisterStarted.sendTo(
sender, mapOf(
"currency" to Supplier { currency.name }
))

runBlocking {
if (currency.isPrimary()) {
plugin.translations.commandPolyconomyCurrencyUnregisterErrorIsPrimary.sendTo(sender, mapOf(
plugin.translations.commandPolyconomyCurrencyUnregisterErrorIsPrimary.sendTo(
sender, mapOf(
"currency" to Supplier { currency.name }
))
throw plugin.translations.commandApiFailure()
Expand All @@ -377,7 +392,8 @@ object CurrencySubcommand : InternalCmd {
runBlocking {
plugin.storageManager.handler.unregisterCurrency(currency)

plugin.translations.commandPolyconomyCurrencyUnregisterCompleted.sendTo(sender, mapOf(
plugin.translations.commandPolyconomyCurrencyUnregisterCompleted.sendTo(
sender, mapOf(
"currency" to Supplier { currency.name }
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ object DepositSubcommand : InternalCmd {
}

if (amount <= 0) {
plugin.translations.commandGenericAmountZeroOrLess.sendTo(sender, placeholders = mapOf(
plugin.translations.commandGenericAmountZeroOrLess.sendTo(
sender, placeholders = mapOf(
"amount" to Supplier { amount.toString() }
))
throw plugin.translations.commandApiFailure()
Expand Down Expand Up @@ -71,11 +72,13 @@ object DepositSubcommand : InternalCmd {
}
val targetName = targetPlayer.name ?: targetPlayer.uniqueId.toString()

plugin.translations.commandPolyconomyDepositCompleted.sendTo(sender, placeholders = mapOf(
"amount" to Supplier { amountFormatted },
"target-name" to Supplier { targetName },
"currency" to Supplier { currency.name },
))
plugin.translations.commandPolyconomyDepositCompleted.sendTo(
sender, placeholders = mapOf(
"amount" to Supplier { amountFormatted },
"target-name" to Supplier { targetName },
"currency" to Supplier { currency.name },
)
)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ object ReloadSubcommand : InternalCmd {
plugin.softReload()
plugin.translations.commandPolyconomyReloadCompleted.sendTo(sender)
} catch (ex: Throwable) {
plugin.translations.commandPolyconomyReloadErrorGeneric.sendTo(sender, placeholders = mapOf(
"message" to Supplier { ex.message ?: ex::class.java.canonicalName },
))
plugin.translations.commandPolyconomyReloadErrorGeneric.sendTo(
sender, placeholders = mapOf(
"message" to Supplier { ex.message ?: ex::class.java.canonicalName },
)
)
if (ex !is DescribedThrowable) {
plugin.nativeLogger.severe("An error occurred whilst reloading Polyconomy via the `reload` subcommand. Stack trace:")
ex.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ object ResetSubcommand : InternalCmd {

val targetName = targetPlayer.name ?: targetPlayer.uniqueId.toString()

plugin.translations.commandPolyconomyResetCompleted.sendTo(sender, placeholders = mapOf(
plugin.translations.commandPolyconomyResetCompleted.sendTo(
sender, placeholders = mapOf(
"target-name" to Supplier { targetName },
"currency" to Supplier { currency.name },
"target-balance" to Supplier { runBlocking {
currency.format(targetAccount.getBalance(currency), plugin.settingsCfg.defaultLocale())
} }
"target-balance" to Supplier {
runBlocking {
currency.format(targetAccount.getBalance(currency), plugin.settingsCfg.defaultLocale())
}
}
))
})
}
Expand Down
Loading

0 comments on commit 5decc59

Please sign in to comment.