Compare commits

...

2 Commits

Author SHA1 Message Date
Len 4737ad1cfa Round shop balance and price per item. 2024-08-13 15:42:14 +02:00
Len f714cbef24 Add auto update stage to Jenkinsfile 2024-08-13 15:41:53 +02:00
3 changed files with 21 additions and 2 deletions

9
Jenkinsfile vendored
View File

@ -16,5 +16,14 @@ pipeline {
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
}
}
stage('Copy to /mnt/updates/plugins') {
when {
branch 'main'
branch 'master'
}
steps {
sh 'cp build/libs/*.jar /mnt/updates/plugins/'
}
}
}
}

View File

@ -65,7 +65,7 @@ public class PlayerShop {
playerShop.server = server;
playerShop.price = price;
playerShop.amount = amount;
playerShop.balance = balance;
playerShop.balance = EconomyUtils.round(balance);
playerShop.itemStack = item;
playerShop.lastTransaction = lastTransaction;
@ -193,7 +193,7 @@ public class PlayerShop {
}
public double getPricePerItem() {
return this.getPrice() / this.getAmount();
return EconomyUtils.round(this.getPrice() / this.getAmount());
}
public boolean removeBalance(double amount) {

View File

@ -5,6 +5,9 @@ import com.alttd.playershops.shop.PlayerShop;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.entity.Player;
import java.math.BigDecimal;
import java.math.RoundingMode;
// TODO document
public class EconomyUtils {
@ -55,4 +58,11 @@ public class EconomyUtils {
// if we ever need to limit the maximum balance a shop can have this is the place
return true;
}
public static double round(double value) {
BigDecimal bd = BigDecimal.valueOf(value);
bd = bd.setScale(2, RoundingMode.HALF_UP);
return bd.doubleValue();
}
}