9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-27 02:49:13 +00:00

Fixed insufficient exp withdrawing money while failing

This commit is contained in:
Auxilor
2021-10-26 15:41:49 +01:00
parent 8c6240219d
commit 7a211da7fd

View File

@@ -56,14 +56,15 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
return;
}
double cost = 0;
if (EconomyHandler.isEnabled()) {
double cost = this.getPlugin().getConfigYml().getDouble("reforge.cost");
cost = this.getPlugin().getConfigYml().getDouble("reforge.cost");
int reforges = ReforgeUtils.getReforges(toReforge);
cost *= Math.pow(this.getPlugin().getConfigYml().getDouble("reforge.cost-exponent"), reforges);
if (reforge.getRequiresStone() && reforge.getStonePrice() != -1) {
cost = reforge.getStonePrice();
}
if (!EconomyHandler.getInstance().has(player, cost)) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("insufficient-money"));
@@ -76,9 +77,6 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
return;
}
EconomyHandler.getInstance().withdrawPlayer(player, cost);
}
int xpCost = this.getPlugin().getConfigYml().getInt("reforge.xp-cost");
@@ -97,6 +95,10 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
return;
}
if (EconomyHandler.isEnabled()) {
EconomyHandler.getInstance().withdrawPlayer(player, cost);
}
player.setLevel(player.getLevel() - xpCost);
player.sendMessage(this.getPlugin().getLangYml().getMessage("applied-reforge").replace("%reforge%", reforge.getName()));