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
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,3 @@
</profile>
</profiles>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public boolean execute(CommandSender sender, String[] args) {
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? "Bank operation failed." : response.errorMessage;
String message = response == null ? null : response.errorMessage;
if (message == null || message.isBlank()) {
message = "Bank operation failed.";
message = com.skyblockexp.ezeconomy.util.MessageUtils.format(plugin, "bank_operation_failed");
}
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, message));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public boolean execute(CommandSender sender, String[] args) {
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? "Bank operation failed." : response.errorMessage;
String message = response == null ? null : response.errorMessage;
if (message == null || message.isBlank()) {
message = "Bank operation failed.";
message = MessageUtils.format(plugin, "bank_operation_failed");
}
sender.sendMessage(MessageUtils.color(plugin, message));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public boolean execute(CommandSender sender, String[] args) {
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? "Bank operation failed." : response.errorMessage;
String message = response == null ? null : response.errorMessage;
if (message == null || message.isBlank()) {
message = "Bank operation failed.";
message = com.skyblockexp.ezeconomy.util.MessageUtils.format(plugin, "bank_operation_failed");
}
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, message));
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
package com.skyblockexp.ezeconomy.command.bank;
package com.skyblockexp.ezeconomy.command.bank;

import com.skyblockexp.ezeconomy.command.Subcommand;
import com.skyblockexp.ezeconomy.core.EzEconomyPlugin;
import com.skyblockexp.ezeconomy.util.NumberUtil;
import com.skyblockexp.ezeconomy.api.storage.StorageProvider;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.command.CommandSender;
/**
* Subcommand for /bank deposit <name> <amount> [currency]
*/
public class DepositSubcommand implements Subcommand {
private final EzEconomyPlugin plugin;
public DepositSubcommand(EzEconomyPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (!sender.hasPermission("ezeconomy.bank.deposit") && !sender.hasPermission("ezeconomy.bank.admin")) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "no_permission");
return true;
}
if (args.length < 1) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "usage_bank_deposit");
return true;
}
// Resolve bank name and amount:
// /bank deposit <amount> — deposits into the sender's own bank
// /bank deposit <name> <amount> — deposits into the named bank
final String bankName;
final String amountStr;
final String currency;

/**
* Subcommand for /bank deposit <name> <amount> [currency]
*/
public class DepositSubcommand implements Subcommand {
private final EzEconomyPlugin plugin;

public DepositSubcommand(EzEconomyPlugin plugin) {
this.plugin = plugin;
}

@Override
public boolean execute(CommandSender sender, String[] args) {
if (!sender.hasPermission("ezeconomy.bank.deposit") && !sender.hasPermission("ezeconomy.bank.admin")) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "no_permission");
return true;
}
if (args.length < 1) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "usage_bank_deposit");
return true;
}

// Resolve bank name and amount:
// /bank deposit <amount> — deposits into the sender's own bank
// /bank deposit <name> <amount> — deposits into the named bank
final String bankName;
final String amountStr;
final String currency;
if (args.length == 1) {
if (!(sender instanceof org.bukkit.entity.Player)) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "only_players");
Expand All @@ -47,12 +47,12 @@ public boolean execute(CommandSender sender, String[] args) {
amountStr = args[1];
currency = args.length >= 3 ? args[2] : plugin.getDefaultCurrency();
}
Double amount = NumberUtil.parseDouble(amountStr);
if (amount == null || amount <= 0) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "invalid_amount");
return true;
}

Double amount = NumberUtil.parseDouble(amountStr);
if (amount == null || amount <= 0) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "invalid_amount");
return true;
}
StorageProvider storage = plugin.getStorageOrWarn();
if (storage == null) return true;

Expand All @@ -73,27 +73,24 @@ public boolean execute(CommandSender sender, String[] args) {
}
return true;
}
String formattedAmount = plugin.getCurrencyFormatter().formatPriceForMessage(amount, currency);
java.util.HashMap<String, String> placeholders = new java.util.HashMap<>();
placeholders.put("name", bankName);
placeholders.put("amount", formattedAmount);
placeholders.put("currency", currency);
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "deposited", placeholders);
return true;
}
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response, String bankName) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? null : response.errorMessage;
if (message != null && message.startsWith("Bank does not exist")) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "bank_not_found",
java.util.Map.of("name", bankName));
} else {
String fallback = (message == null || message.isBlank()) ? "Bank operation failed." : message;
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, fallback));
}
return true;
}
return false;
}
String formattedAmount = plugin.getCurrencyFormatter().formatPriceForMessage(amount, currency);
java.util.HashMap<String, String> placeholders = new java.util.HashMap<>();
placeholders.put("name", bankName);
placeholders.put("amount", formattedAmount);
placeholders.put("currency", currency);
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "deposited", placeholders);
return true;
}
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response, String bankName) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? null : response.errorMessage;
String fallback = (message == null || message.isBlank())
? com.skyblockexp.ezeconomy.util.MessageUtils.format(plugin, "bank_operation_failed")
: message;
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, fallback));
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public boolean execute(CommandSender sender, String[] args) {
private boolean handleEconomyFailure(CommandSender sender, EconomyResponse response) {
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? "Bank operation failed." : response.errorMessage;
String message = response == null ? null : response.errorMessage;
if (message == null || message.isBlank()) {
message = "Bank operation failed.";
message = com.skyblockexp.ezeconomy.util.MessageUtils.format(plugin, "bank_operation_failed");
}
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, message));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean execute(CommandSender sender, String[] args) {
} catch (Exception ex) {
// Roll back the bank withdrawal if wallet credit fails unexpectedly.
storage.depositBank(bankName, currency, amount);
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, "Bank operation failed."));
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "bank_operation_failed");
return true;
}
}
Expand All @@ -84,15 +84,10 @@ private boolean handleEconomyFailure(CommandSender sender, EconomyResponse respo
if (response == null || response.type == EconomyResponse.ResponseType.FAILURE
|| response.type == EconomyResponse.ResponseType.NOT_IMPLEMENTED) {
String message = response == null ? null : response.errorMessage;
if (message != null && message.startsWith("Bank does not exist")) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "bank_not_found",
java.util.Map.of("name", bankName));
} else if (message != null && message.startsWith("Insufficient funds")) {
com.skyblockexp.ezeconomy.util.MessageUtils.send(sender, plugin, "not_enough_money");
} else {
String fallback = (message == null || message.isBlank()) ? "Bank operation failed." : message;
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, fallback));
}
String fallback = (message == null || message.isBlank())
? com.skyblockexp.ezeconomy.util.MessageUtils.format(plugin, "bank_operation_failed")
: message;
sender.sendMessage(com.skyblockexp.ezeconomy.util.MessageUtils.color(plugin, fallback));
return true;
}
return false;
Expand Down
Loading