mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-27 14:13:05 +02:00
Fix NPE when server economy account info can't be found (DevBukkit-1216)
Also add a warning to the startup if that happens
This commit is contained in:
parent
4120455974
commit
b3b9e690dd
@ -33,6 +33,9 @@ public class ServerAccountCorrector implements Listener {
|
||||
}
|
||||
|
||||
event.setAdded(true);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(event.getAmount(), target, event.getWorld());
|
||||
ChestShop.callEvent(currencyAddEvent);
|
||||
@ -54,6 +57,9 @@ public class ServerAccountCorrector implements Listener {
|
||||
}
|
||||
|
||||
event.setSubtracted(true);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(event.getAmount(), target, event.getWorld());
|
||||
ChestShop.callEvent(currencySubtractEvent);
|
||||
@ -72,6 +78,10 @@ public class ServerAccountCorrector implements Listener {
|
||||
return;
|
||||
} else {
|
||||
target = NameManager.getUUID(SERVER_ECONOMY_ACCOUNT);
|
||||
if (target == null) {
|
||||
event.hasEnough(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(event.getAmount(), target, event.getWorld());
|
||||
@ -105,6 +115,9 @@ public class ServerAccountCorrector implements Listener {
|
||||
return;
|
||||
} else {
|
||||
target = NameManager.getUUID(SERVER_ECONOMY_ACCOUNT);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CurrencyAmountEvent currencyAmountEvent = new CurrencyAmountEvent(target, event.getWorld());
|
||||
|
@ -270,6 +270,13 @@ public class NameManager {
|
||||
|
||||
Account adminAccount = new Account(Properties.ADMIN_SHOP_NAME, Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
|
||||
accounts.createOrUpdate(adminAccount);
|
||||
|
||||
if (!Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {
|
||||
Account serverEconomyAccount = getAccount(Properties.SERVER_ECONOMY_ACCOUNT);
|
||||
if (serverEconomyAccount == null || serverEconomyAccount.getUuid() == null) {
|
||||
ChestShop.getBukkitLogger().log(Level.WARNING, "Server economy account setting '" + Properties.SERVER_ECONOMY_ACCOUNT + "' doesn't seem to be the name of a known player! Please log in at least once in order for the server economy account to work.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user