Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Fixed price calculation for items with discounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidius20 committed Aug 11, 2018
1 parent 9086e94 commit 3b2f714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/main/java/ua/leonidius/trading/buy/Buy.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ public static double getPrice (Item item) {
int id = item.getId();
int meta = item.getDamage();
String key = "b-"+id+"-"+meta;

double priceWithoutDiscount = Main.buycfg.getDouble(key);
double priceWithDiscount = priceWithoutDiscount;

String discountKey = "d-"+id+"-"+meta;

if (Main.discountCfg.exists(discountKey)) {
double discountModifier = Main.discountCfg.getDouble(discountKey)/100;
priceWithDiscount = priceWithoutDiscount*discountModifier;
double discountPercent = Main.discountCfg.getDouble(discountKey);
double discount = (priceWithoutDiscount * discountPercent) / 100;
return priceWithoutDiscount - discount;
}
return priceWithDiscount;

return priceWithoutDiscount;
}

private static int getMaxByMoney(Player player, Item item){
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Trading Commands
main: ua.leonidius.trading.Main
version: 1.0.2
version: 1.0.3
author: Leonidius20
api: ["1.0.0"]
description: Shop and auction system, based on commands.
Expand Down

0 comments on commit 3b2f714

Please sign in to comment.