Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,55 @@ object Components {
suspend fun formatCreationResult(result: AccountCreationResult) = buildText {
when (result) {
is AccountCreationResult.Success -> {
appendSuccessPrefix()
success("Das Konto ")
append(displayName(result.account as AccountImpl))
success(" wurde erfolgreich erstellt")
}

is AccountCreationResult.Failed -> {
when (result.reason) {
NAME_ALREADY_EXISTS -> error("Ein Konto mit diesem Namen existiert bereits")
NAME_TOO_LONG -> error("Der Name darf maximal ${ApiAccount.MAX_NAME_LENGTH} Zeichen lang sein")
NAME_TOO_SHORT -> error("Der Name muss mindestens ${ApiAccount.MIN_NAME_LENGTH} Zeichen lang sein")
NAME_IS_UUID -> error("Der Name darf keine UUID sein")
NAME_ALREADY_EXISTS -> {
appendErrorPrefix()
error("Ein Konto mit diesem Namen existiert bereits")
}

NAME_TOO_LONG -> {
appendErrorPrefix()
error("Der Name darf maximal ${ApiAccount.MAX_NAME_LENGTH} Zeichen lang sein")
}

NAME_TOO_SHORT -> {
appendErrorPrefix()
error("Der Name muss mindestens ${ApiAccount.MIN_NAME_LENGTH} Zeichen lang sein")
}

NAME_IS_UUID -> {
appendErrorPrefix()
error("Der Name darf keine UUID sein")
}
}
}
}
}

fun formatDeletionResult(result: AccountDeleteResult) = buildText {
when (result) {
AccountDeleteResult.SUCCESS -> success("Das Konto wurde erfolgreich gelöscht")
AccountDeleteResult.DEFAULT_ACCOUNT_CANNOT_BE_DELETED -> error("Das Standardkonto kann nicht gelöscht werden")
AccountDeleteResult.ACCOUNT_NOT_FOUND -> error("Das Konto konnte nicht gefunden werden")
AccountDeleteResult.SUCCESS -> {
appendSuccessPrefix()
success("Das Konto wurde erfolgreich gelöscht")
}

AccountDeleteResult.DEFAULT_ACCOUNT_CANNOT_BE_DELETED -> {
appendErrorPrefix()
error("Das Standardkonto kann nicht gelöscht werden")
}

AccountDeleteResult.ACCOUNT_NOT_FOUND -> {
appendErrorPrefix()

error("Das Konto konnte nicht gefunden werden")
}
}
}

Expand All @@ -70,6 +98,7 @@ object Components {
buildText {
when (result) {
AccountMemberResult.SUCCESS -> {
appendSuccessPrefix()
variableValue(usernameOrUuid(member))
success(" wurde erfolgreich als Mitglied ")
if (added) {
Expand All @@ -80,6 +109,7 @@ object Components {
}

AccountMemberResult.NOTHING_CHANGED -> {
appendErrorPrefix()
if (added) {
variableValue(usernameOrUuid(member))
error(" ist bereits ein Mitglied des Kontos")
Expand All @@ -99,28 +129,33 @@ object Components {
fun formatCreateResult(currency: CurrencyImpl, result: CurrencyCreateResult) = buildText {
when (result) {
CurrencyCreateResult.SUCCESS -> {
appendSuccessPrefix()
success("Die Währung ")
append(currency)
success(" wurde erfolgreich erstellt")
}

CurrencyCreateResult.ALREADY_EXISTS -> {
appendErrorPrefix()
error("Die Währung ")
append(currency)
error(" existiert bereits!")
}

CurrencyCreateResult.DEFAULT_ALREADY_EXISTS -> {
appendErrorPrefix()
error("Es existiert bereits eine Standardwährung!")
}

CurrencyCreateResult.INVALID_NAME -> {
appendErrorPrefix()
error("Der Name '")
variableValue(currency.name)
error("' ist ungültig!")
}

CurrencyCreateResult.INVALID_SYMBOL -> {
appendErrorPrefix()
error("Das Symbol '")
variableValue(currency.symbol)
error("' ist ungültig!")
Expand All @@ -134,11 +169,13 @@ object Components {
) = buildText {
when (result) {
CurrencyDefaultResult.SUCCESS -> {
appendSuccessPrefix()
append(currency)
success(" ist nun die Standardwährung")
}

CurrencyDefaultResult.NOT_FOUND -> {
appendErrorPrefix()
error("Die Währung ")
append(currency)
error(" wurde nicht gefunden")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fun CommandAPICommand.accountCreateCommand() = subcommand("create") {
val result = player.transactionUser().createAccount(name)

player.sendText {
appendPrefix()
append(Components.Account.formatCreationResult(result))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fun CommandAPICommand.accountDeleteCommand() = subcommand("delete") {
val result = player.transactionUser().deleteAccount(account)

player.sendText {
appendPrefix()
append(Components.Account.formatDeletionResult(result))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fun CommandAPICommand.addAccountMemberCommand() = subcommand("add") {
)

sender.sendText {
appendPrefix()
append(Components.Account.Member.formatResult(result, targetUuid, added = true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fun CommandAPICommand.removeAccountMemberCommand() = subcommand("remove") {
val result = account.removeMember(sender.uniqueId, targetUuid)

sender.sendText {
appendPrefix()
append(Components.Account.Member.formatResult(result, targetUuid, added = false))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private suspend fun create(
val result = CurrencyServiceImpl.get().createCurrency(currency)

sender.sendText {
appendPrefix()
append(Components.Currency.formatCreateResult(currency, result))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ private suspend fun makeDefault(sender: CommandSender, currency: Currency) {
val result = CurrencyServiceImpl.get().makeDefaultCurrency(currency as CurrencyImpl)

sender.sendText {
appendPrefix()
append(Components.Currency.formatChangedDefaultResult(currency, result))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private suspend fun pay(
}

sender.sendText {
appendPrefix()
appendInfoPrefix()
info("Überweisung wird ausgeführt...")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private suspend fun add(

private fun handleError(sender: CommandSender, result: TransactionResult, receiverUuid: UUID) {
sender.sendText {
appendPrefix()
appendErrorPrefix()
error("Es ist ein Fehler aufgetreten!")
}

Expand All @@ -87,7 +87,7 @@ private suspend fun handleSuccess(
currency: Currency
) {
sender.sendText {
appendPrefix()
appendSuccessPrefix()

darkSpacer("[")
variableKey("Admin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private suspend fun remove(

private fun handleError(sender: CommandSender, result: TransactionResult, receiverUuid: UUID) {
sender.sendText {
appendPrefix()
appendErrorPrefix()
error("Es ist ein Fehler aufgetreten!")
}

Expand All @@ -88,7 +88,7 @@ private suspend fun handleSuccess(
currency: Currency
) {
sender.sendText {
appendPrefix()
appendSuccessPrefix()

darkSpacer("[")
variableKey("Admin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PaymentEventsHandler {

plugin.launch(plugin.entityDispatcher(receiver)) {
receiver.sendText {
appendPrefix()
appendInfoPrefix()

info("Du hast ")
append(event.currency.format(event.amount))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TransactionEventsHandler {

plugin.launch(plugin.entityDispatcher(receiver)) {
receiver.sendText {
appendPrefix()
appendInfoPrefix()

darkSpacer("[")
variableKey("Admin")
Expand Down