Added points in message and fixed price and point calculations
This commit is contained in:
parent
d45c2f9ace
commit
97860c7da5
|
|
@ -49,7 +49,7 @@ public class BuyGUI extends GUIMerchant {
|
|||
private void buy(VillagerType villagerType, Player player, Material material, int amount, Price price) {
|
||||
Economy econ = VillagerUI.getInstance().getEconomy();
|
||||
double balance = econ.getBalance(player);
|
||||
int itemPts = (int) (Math.floor(price.getPrice(amount) / WorthConfig.POINT_MOD) + 1);
|
||||
int itemPts = (int) (Math.floor(price.getPrice(1) / WorthConfig.POINT_MOD) + 1);
|
||||
int transPts = itemPts * amount;
|
||||
EconUser econUser = EconUser.getUser(player.getUniqueId());
|
||||
int oldPoints = Objects.requireNonNullElse(econUser.getPointsMap().get(villagerType.getName()), 0);
|
||||
|
|
@ -69,7 +69,8 @@ public class BuyGUI extends GUIMerchant {
|
|||
Template.template("amount", String.valueOf(amount)),
|
||||
Template.template("item", StringUtils.capitalize(material.name()
|
||||
.toLowerCase().replaceAll("_", " "))),
|
||||
Template.template("price", String.valueOf(cost))));
|
||||
Template.template("price", String.valueOf(cost)),
|
||||
Template.template("points", String.valueOf(transPts))));
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new SpawnShopEvent(player, amount, cost, material,
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@ public class SellGUI extends GUIMerchant {
|
|||
Economy econ = VillagerUI.getInstance().getEconomy();
|
||||
EconUser econUser = EconUser.getUser(player.getUniqueId());
|
||||
int oldPoints = Objects.requireNonNullElse(econUser.getPointsMap().get(villagerType.getName()), 0);
|
||||
int itemPts = (int) (Math.floor(price.getPrice(amount) / WorthConfig.POINT_MOD) + 1);
|
||||
int transPts = itemPts * amount;
|
||||
int itemPts = (int) (Math.floor(price.getPrice(1) / WorthConfig.POINT_MOD) + 1);
|
||||
int transPts = (itemPts * amount) * -1;
|
||||
double cost = price.calculatePriceThing(oldPoints, transPts, false, itemPts);
|
||||
|
||||
econ.depositPlayer(player, cost);
|
||||
econUser.addPoints(villagerType.getName(), -price.getPoints());
|
||||
econUser.addPoints(villagerType.getName(), transPts);
|
||||
|
||||
removeItems(inventory, material, amount);
|
||||
|
||||
|
|
@ -74,7 +74,8 @@ public class SellGUI extends GUIMerchant {
|
|||
Template.template("amount", String.valueOf(amount)),
|
||||
Template.template("item", StringUtils.capitalize(material.name()
|
||||
.toLowerCase().replaceAll("_", " "))),
|
||||
Template.template("price", String.valueOf(cost))));
|
||||
Template.template("price", String.valueOf(cost)),
|
||||
Template.template("points", String.valueOf(transPts))));
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new SpawnShopEvent(player, amount, cost, material,
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public final class Config extends AbstractConfig {
|
|||
|
||||
public static String NOT_ENOUGH_MONEY = "<red>You only have $<money>, you need at least $<price> for this purchase.</red>";
|
||||
public static String NOT_ENOUGH_ITEMS = "<red>You only have don't have enough <type> you need at least <amount>.</red>";
|
||||
public static String PURCHASED_ITEM = "<green>You bought <amount> <item> for <price>!</green>";
|
||||
public static String PURCHASED_ITEM = "<green>You bought <amount> <item> for <price> and got <points> points!</green>";
|
||||
public static String SOLD_ITEM = "<green>You sold <amount> <item> for <price>!</green>";
|
||||
public static String REMOVED_VILLAGER = "<green>Removed villager with uuid <uuid></green>";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user