Added points to buy and sell events

This commit is contained in:
stjn 2021-11-10 20:08:16 +01:00
parent 9236befd7f
commit 6893d7bac7
2 changed files with 9 additions and 6 deletions

View File

@ -47,9 +47,11 @@ public class BuyGUI extends GUIMerchant {
Template.of("price", String.valueOf(price)))); Template.of("price", String.valueOf(price))));
return; return;
} }
EconUser econUser = EconUser.users.get(player.getUniqueId());
int oldPoints = econUser.getPointsMap().get(villagerType.getName());
econ.withdrawPlayer(player, cost); econ.withdrawPlayer(player, cost);
EconUser.users.get(player.getUniqueId()) econUser.addPoints(villagerType.getName(), price.getPoints());
.addPoints(villagerType.getName(), price.getPoints());
player.sendMessage(MiniMessage.get().parse(Config.PURCHASED_ITEM, player.sendMessage(MiniMessage.get().parse(Config.PURCHASED_ITEM,
Template.of("amount", String.valueOf(amount)), Template.of("amount", String.valueOf(amount)),
Template.of("item", material.toString()), Template.of("item", material.toString()),
@ -57,7 +59,7 @@ public class BuyGUI extends GUIMerchant {
Bukkit.getServer().getPluginManager() Bukkit.getServer().getPluginManager()
.callEvent(new SpawnShopEvent(player, amount, cost, material, .callEvent(new SpawnShopEvent(player, amount, cost, material,
0, 0, true)); oldPoints, econUser.getPointsMap().get(villagerType.getName()), true));
} }
private ItemStack getPriceItem(double price) { private ItemStack getPriceItem(double price) {

View File

@ -40,10 +40,11 @@ public class SellGUI extends GUIMerchant {
private void sell(VillagerType villagerType, Player player, Material material, int amount, Price price) { private void sell(VillagerType villagerType, Player player, Material material, int amount, Price price) {
Economy econ = VillagerUI.getEcon(); Economy econ = VillagerUI.getEcon();
double cost = price.getPrice(amount); double cost = price.getPrice(amount);
EconUser econUser = EconUser.users.get(player.getUniqueId());
int oldPoints = econUser.getPointsMap().get(villagerType.getName());
econ.depositPlayer(player, cost); econ.depositPlayer(player, cost);
EconUser.users.get(player.getUniqueId()) econUser.addPoints(villagerType.getName(), -price.getPoints());
.addPoints(villagerType.getName(), -price.getPoints());
player.sendMessage(MiniMessage.get().parse(Config.PURCHASED_ITEM, player.sendMessage(MiniMessage.get().parse(Config.PURCHASED_ITEM,
Template.of("amount", String.valueOf(amount)), Template.of("amount", String.valueOf(amount)),
Template.of("item", material.toString()), Template.of("item", material.toString()),
@ -51,7 +52,7 @@ public class SellGUI extends GUIMerchant {
Bukkit.getServer().getPluginManager() Bukkit.getServer().getPluginManager()
.callEvent(new SpawnShopEvent(player, amount, cost, material, .callEvent(new SpawnShopEvent(player, amount, cost, material,
0, 0, false)); oldPoints, econUser.getPointsMap().get(villagerType.getName()), false));
} }
private ItemStack getPriceItem(double price) { private ItemStack getPriceItem(double price) {