mirror of https://github.com/MilkBowl/Vault.git
Fix stack overflow by using Essentials as name for EssentialsX; stop Essentials from loading if EssentialsX is present
This commit is contained in:
parent
ace36ee753
commit
ac2667be3f
|
@ -220,10 +220,14 @@ public class Vault extends JavaPlugin {
|
|||
hookEconomy("Gringotts", Economy_Gringotts.class, ServicePriority.Normal, "org.gestern.gringotts.Gringotts");
|
||||
|
||||
// Try to load EssentialsX Economy
|
||||
hookEconomy("EssentialsX Economy", Economy_EssentialsX.class, ServicePriority.Normal, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException", "com.earth2me.essentials.AsyncTeleport");
|
||||
boolean isEssentialsX = hookEconomy("Essentials Economy", Economy_EssentialsX.class, ServicePriority.Low,
|
||||
"com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException",
|
||||
"com.earth2me.essentials.api.UserDoesNotExistException", "com.earth2me.essentials.AsyncTeleport");
|
||||
|
||||
// Try to load Essentials Economy
|
||||
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
|
||||
if (!isEssentialsX) {
|
||||
// Try to load Essentials Economy
|
||||
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
|
||||
}
|
||||
|
||||
// Try to load iConomy 6
|
||||
hookEconomy("iConomy 6", Economy_iConomy6.class, ServicePriority.High, "com.iCo6.iConomy");
|
||||
|
@ -324,16 +328,19 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private void hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) {
|
||||
private boolean hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) {
|
||||
try {
|
||||
if (packagesExists(packages)) {
|
||||
Economy econ = hookClass.getConstructor(Plugin.class).newInstance(this);
|
||||
sm.register(Economy.class, econ, this, priority);
|
||||
log.info(String.format("[Economy] %s found: %s", name, econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("[Economy] There was an error hooking %s - check to make sure you're using a compatible version!", name));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) {
|
||||
|
|
|
@ -154,7 +154,7 @@ public class Economy_Essentials extends AbstractEconomy {
|
|||
type = ResponseType.SUCCESS;
|
||||
} catch (UserDoesNotExistException e) {
|
||||
if (createPlayerAccount(playerName)) {
|
||||
return tryDepositPlayer(playerName, amount, tries--);
|
||||
return tryDepositPlayer(playerName, amount, --tries);
|
||||
} else {
|
||||
amount = 0;
|
||||
balance = 0;
|
||||
|
|
|
@ -15,11 +15,6 @@ public class Economy_EssentialsX extends Economy_Essentials {
|
|||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EssentialsX Economy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(OfflinePlayer player) {
|
||||
return Economy.playerExists(player.getUniqueId());
|
||||
|
@ -115,7 +110,7 @@ public class Economy_EssentialsX extends Economy_Essentials {
|
|||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
} catch (UserDoesNotExistException e) {
|
||||
if (createPlayerAccount(player)) {
|
||||
return tryDepositPlayer(player, amount, tries--);
|
||||
return tryDepositPlayer(player, amount, --tries);
|
||||
} else {
|
||||
amount = 0;
|
||||
balance = BigDecimal.ZERO;
|
||||
|
@ -168,4 +163,9 @@ public class Economy_EssentialsX extends Economy_Essentials {
|
|||
public boolean createPlayerAccount(OfflinePlayer player, String worldName) {
|
||||
return createPlayerAccount(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(OfflinePlayer player) {
|
||||
return createPlayerAccount(player.getName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue