Fixed Economy wasn't working in Enchanter.

This commit is contained in:
TeamHR 2024-03-24 02:30:26 +05:30
parent b1858599fc
commit 7f536ce4d9
4 changed files with 22 additions and 8 deletions

View File

@ -91,6 +91,7 @@ public class EpicEnchants extends SongodaPlugin {
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
System.out.println(EconomyManager.getManager().getCurrentHook().toString());
preload();

View File

@ -273,13 +273,18 @@ public class AlchemistMenu extends FastInv {
return;
}
if(EconomyManager.isEnabled()){
EconomyManager.withdrawBalance(event.getPlayer(), ecoCost);
changeExp(event.getPlayer(), -expCost);
this.instance.getLocale().getMessage("alchemist.success")
this.instance.getLocale().getMessage("alchemist.successeco")
.processPlaceholder("eco_cost", ecoCost)
.sendPrefixedMessage(event.getPlayer());
}
else {
changeExp(event.getPlayer(), -expCost);
this.instance.getLocale().getMessage("alchemist.successexp")
.processPlaceholder("exp_cost", expCost)
.sendPrefixedMessage(event.getPlayer());
}
event.getPlayer().getInventory().addItem(getInventory().getItem(this.PREVIEW_SLOT));
clear(this.RIGHT_SLOT);
clear(this.LEFT_SLOT);

View File

@ -55,22 +55,28 @@ public class EnchanterMenu extends FastInv {
return;
}
if (EconomyManager.isEnabled() && !EconomyManager.hasBalance((player), ecoCost) || getExp(player) < expCost) {
if (EconomyManager.isEnabled() && EconomyManager.getBalance(player) < ecoCost && getExp(player) < expCost) {
instance.getLocale().getMessage("enchanter.cannotafford").sendPrefixedMessage(player);
return;
}
if (EconomyManager.isEnabled()) {
EconomyManager.withdrawBalance(player, ecoCost);
event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.success")
event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.successeco")
.processPlaceholder("group_name", group.getName())
.processPlaceholder("group_color", group.getColor())
.processPlaceholder("eco_cost", ecoCost)
.getPrefixedMessage());
}
else{
changeExp(player, -expCost);
event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.successexp")
.processPlaceholder("group_name", group.getName())
.processPlaceholder("group_color", group.getColor())
.processPlaceholder("exp_cost", expCost)
.getPrefixedMessage());
}
changeExp(player, -expCost);
player.getInventory().addItem(instance.getSpecialItems().getMysteryBook(group));
this.delay.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 120);
});

View File

@ -39,7 +39,8 @@ whitescroll:
applied: '&7This item is now protected!'
enchanter:
cannotafford: '&cYou cannot afford this purchase.'
success: '&7Purchased &6{group_color}{group_name} &7book for &6{exp_cost} experience&7.'
successexp: '&7Purchased &6{group_color}{group_name} &7book for &6{exp_cost} experience&7.'
successeco: '&7Purchased &6{group_color}{group_name} &7book for &6${eco_cost}&7.'
tinkerer:
open: '&7Trading with the tinkerer.'
cancelled: '&cCancelled.'
@ -56,7 +57,8 @@ alchemist:
differentlevels: '&cThe alchemist can only combine books of the same level...'
differentgroups: '&cThe alchemist can only combine dust of the same group...'
cannotafford: '&cYou cannot afford this exchange...'
success: '&7Exchanged for &6{exp_cost} &7experience.'
successeco: '&7Exchanged for &6${eco_cost}.'
successexp: '&7Exchanged for &6{exp_cost} &7experience.'
enchants:
invalidmaterial: '&cYou can not apply &4{enchant}&r &cto that item...'
failure: '&4{enchant}&r &cfailed to apply...'