From 559fc9d4abe227b49e17b3a779bf7b4cca24c3f6 Mon Sep 17 00:00:00 2001 From: Zrips Date: Fri, 17 Nov 2023 12:55:24 +0200 Subject: [PATCH] Fix for total point calculation being incorrect --- .../java/com/gamingmesh/jobs/Placeholders/Placeholder.java | 7 +++++-- .../java/com/gamingmesh/jobs/container/PlayerPoints.java | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index 2b67b2c8..0c1ed2e3 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -407,6 +407,9 @@ public class Placeholder { return String.valueOf((int) (value * 100) / 100D); } + DecimalFormat dFormat = new DecimalFormat("00.0"); + DecimalFormat fFormat = new DecimalFormat("##.###"); + public String getValue(UUID uuid, JobsPlaceHolders placeHolder, String value) { if (placeHolder == null) return null; @@ -452,7 +455,7 @@ public class Placeholder { case user_totallevels: return Integer.toString(user.getTotalLevels()); case user_points: - return new DecimalFormat("00.0").format(user.getPointsData().getCurrentPoints()); + return dFormat.format(user.getPointsData().getCurrentPoints()); case user_points_fixed: return Integer.toString((int) user.getPointsData().getCurrentPoints()); case user_total_points: @@ -520,7 +523,7 @@ public class Placeholder { case user_jprogress_$1: return j == null ? "" : Jobs.getCommandManager().jobProgressMessage(j.getMaxExperience(), j.getExperience()); case user_jexp_rounded_$1: - return j == null ? "0" : new DecimalFormat("##.###").format(j.getExperience()); + return j == null ? "0" : fFormat.format(j.getExperience()); case user_jmaxexp_$1: return j == null ? "0" : format.format(j.getMaxExperience()); case user_jexpunf_$1: diff --git a/src/main/java/com/gamingmesh/jobs/container/PlayerPoints.java b/src/main/java/com/gamingmesh/jobs/container/PlayerPoints.java index c7c886d9..e98077c5 100644 --- a/src/main/java/com/gamingmesh/jobs/container/PlayerPoints.java +++ b/src/main/java/com/gamingmesh/jobs/container/PlayerPoints.java @@ -21,12 +21,12 @@ public class PlayerPoints { public void setPoints(double points) { current = points; - total = points; + if (current > total) + total = current; } public void takePoints(double points) { current -= points; - total -= points; } public boolean havePoints(double points) {