Null check for bad economy plugins

This commit is contained in:
fullwall 2024-09-05 23:40:10 +08:00
parent 8a53ac68f8
commit 7cabe94b14

View File

@ -55,12 +55,14 @@ public class MoneyAction extends NPCShopAction {
return Transaction.create(() -> true, () -> {
EconomyResponse response = economy.depositPlayer(player, amount);
if (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED) {
if (response != null
&& (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED)) {
Messaging.severe("Failed to deposit", amount, "to", player, "in NPC shop:", response.errorMessage);
}
}, () -> {
EconomyResponse response = economy.withdrawPlayer(player, amount);
if (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED) {
if (response != null
&& (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED)) {
Messaging.severe("Failed to withdraw", amount, "from", player, "in NPC shop:", response.errorMessage);
}
});
@ -77,12 +79,14 @@ public class MoneyAction extends NPCShopAction {
return Transaction.create(() -> economy.has(player, amount), () -> {
EconomyResponse response = economy.withdrawPlayer(player, amount);
if (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED) {
if (response != null
&& (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED)) {
Messaging.severe("Failed to withdraw", amount, "from", player, "in NPC shop:", response.errorMessage);
}
}, () -> {
EconomyResponse response = economy.depositPlayer(player, amount);
if (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED) {
if (response != null
&& (response.type == ResponseType.FAILURE || response.type == ResponseType.NOT_IMPLEMENTED)) {
Messaging.severe("Failed to deposit", amount, "to", player, "in NPC shop:", response.errorMessage);
}
});