Fix possible StackOverflowExceptions

This commit is contained in:
Acrobot 2013-08-09 23:00:23 +02:00
parent d7473d68bd
commit aa87b01b68

View File

@ -10,6 +10,8 @@ import org.bukkit.event.Listener;
import java.math.BigDecimal;
import static com.Acrobot.ChestShop.Configuration.Properties.SERVER_ECONOMY_ACCOUNT;
/**
* @author Acrobot
*/
@ -19,15 +21,15 @@ public class ServerAccountCorrector implements Listener {
public static void onCurrencyAdd(CurrencyAddEvent event) {
String target = event.getTarget();
if (!ChestShopSign.isAdminShop(target)) {
if (!ChestShopSign.isAdminShop(target) || event.getTarget().equals(SERVER_ECONOMY_ACCOUNT)) {
return;
}
if (Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
event.setAdded(true);
return;
} else {
target = Properties.SERVER_ECONOMY_ACCOUNT;
target = SERVER_ECONOMY_ACCOUNT;
}
event.setAdded(true);
@ -40,15 +42,15 @@ public class ServerAccountCorrector implements Listener {
public static void onCurrencySubtract(CurrencySubtractEvent event) {
String target = event.getTarget();
if (!ChestShopSign.isAdminShop(target)) {
if (!ChestShopSign.isAdminShop(target) || event.getTarget().equals(SERVER_ECONOMY_ACCOUNT)) {
return;
}
if (Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
event.setSubtracted(true);
return;
} else {
target = Properties.SERVER_ECONOMY_ACCOUNT;
target = SERVER_ECONOMY_ACCOUNT;
}
event.setSubtracted(true);
@ -61,15 +63,15 @@ public class ServerAccountCorrector implements Listener {
public static void onCurrencyCheck(CurrencyCheckEvent event) {
String target = event.getAccount();
if (!ChestShopSign.isAdminShop(target)) {
if (!ChestShopSign.isAdminShop(target) || event.getAccount().equals(SERVER_ECONOMY_ACCOUNT)) {
return;
}
if (Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
event.hasEnough(true);
return;
} else {
target = Properties.SERVER_ECONOMY_ACCOUNT;
target = SERVER_ECONOMY_ACCOUNT;
}
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(event.getAmount(), target, event.getWorld());
@ -82,7 +84,7 @@ public class ServerAccountCorrector implements Listener {
public static void onCurrencyHoldCheck(CurrencyHoldEvent event) {
String target = event.getAccount();
if (!ChestShopSign.isAdminShop(target)) {
if (!ChestShopSign.isAdminShop(target) || event.getAccount().equals(SERVER_ECONOMY_ACCOUNT)) {
return;
}
@ -94,15 +96,15 @@ public class ServerAccountCorrector implements Listener {
public static void onBalanceCheck(CurrencyAmountEvent event) {
String target = event.getAccount();
if (!ChestShopSign.isAdminShop(target)) {
if (!ChestShopSign.isAdminShop(target) || event.getAccount().equals(SERVER_ECONOMY_ACCOUNT)) {
return;
}
if (Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
if (SERVER_ECONOMY_ACCOUNT.isEmpty()) {
event.setAmount(BigDecimal.valueOf(Double.MAX_VALUE));
return;
} else {
target = Properties.SERVER_ECONOMY_ACCOUNT;
target = SERVER_ECONOMY_ACCOUNT;
}
CurrencyAmountEvent currencyAmountEvent = new CurrencyAmountEvent(target, event.getWorld());