From ca5086621b17112a11f1e78b2ef00ad98dae8e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl=20=28xHyroM=29?= Date: Sat, 7 Oct 2023 13:34:03 +0200 Subject: [PATCH] fix(bukkit): remove max value from commands --- .../lighteco/bukkit/commands/GiveCommand.java | 5 ++--- .../lighteco/bukkit/commands/PayCommand.java | 5 ++--- .../lighteco/bukkit/commands/SetCommand.java | 5 ++--- .../lighteco/bukkit/commands/TakeCommand.java | 5 ++--- .../dev/xhyrom/lighteco/bukkit/util/Util.java | 19 ------------------- 5 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/util/Util.java diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/GiveCommand.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/GiveCommand.java index dbc6ab6..e138c0d 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/GiveCommand.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/GiveCommand.java @@ -7,7 +7,6 @@ import dev.jorel.commandapi.arguments.OfflinePlayerArgument; import dev.jorel.commandapi.executors.CommandArguments; import dev.xhyrom.lighteco.bukkit.chat.BukkitCommandSender; import dev.xhyrom.lighteco.bukkit.manager.BukkitCommandManager; -import dev.xhyrom.lighteco.bukkit.util.Util; import dev.xhyrom.lighteco.common.model.currency.Currency; import lombok.RequiredArgsConstructor; import org.bukkit.OfflinePlayer; @@ -28,8 +27,8 @@ public class GiveCommand implements Command { .withArguments( new OfflinePlayerArgument("target"), currency.getProxy().fractionalDigits() > 0 - ? new DoubleArgument("amount", 1, Util.bigDecimalToDouble(this.manager.plugin.getConfig().maximumBalance)) - : new IntegerArgument("amount", 1, this.manager.plugin.getConfig().maximumBalance.intValue()) + ? new DoubleArgument("amount", 1) + : new IntegerArgument("amount", 1) ) .executes((sender, args) -> { this.handleGive(sender, args, currency); diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/PayCommand.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/PayCommand.java index 4a1f584..4e07a94 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/PayCommand.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/PayCommand.java @@ -7,7 +7,6 @@ import dev.jorel.commandapi.arguments.OfflinePlayerArgument; import dev.jorel.commandapi.executors.CommandArguments; import dev.xhyrom.lighteco.bukkit.chat.BukkitCommandSender; import dev.xhyrom.lighteco.bukkit.manager.BukkitCommandManager; -import dev.xhyrom.lighteco.bukkit.util.Util; import dev.xhyrom.lighteco.common.model.currency.Currency; import lombok.RequiredArgsConstructor; import org.bukkit.OfflinePlayer; @@ -28,8 +27,8 @@ public class PayCommand implements Command { .withArguments( new OfflinePlayerArgument("target"), currency.getProxy().fractionalDigits() > 0 - ? new DoubleArgument("amount", 1, Util.bigDecimalToDouble(this.manager.plugin.getConfig().maximumBalance)) - : new IntegerArgument("amount", 1, this.manager.plugin.getConfig().maximumBalance.intValue()) + ? new DoubleArgument("amount", 1) + : new IntegerArgument("amount", 1) ) .executesPlayer((sender, args) -> { this.handlePay(sender, args, currency); diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/SetCommand.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/SetCommand.java index ac410f0..c45f9ff 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/SetCommand.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/SetCommand.java @@ -7,7 +7,6 @@ import dev.jorel.commandapi.arguments.OfflinePlayerArgument; import dev.jorel.commandapi.executors.CommandArguments; import dev.xhyrom.lighteco.bukkit.chat.BukkitCommandSender; import dev.xhyrom.lighteco.bukkit.manager.BukkitCommandManager; -import dev.xhyrom.lighteco.bukkit.util.Util; import dev.xhyrom.lighteco.common.model.currency.Currency; import lombok.RequiredArgsConstructor; import org.bukkit.OfflinePlayer; @@ -28,8 +27,8 @@ public class SetCommand implements Command { .withArguments( new OfflinePlayerArgument("target"), currency.getProxy().fractionalDigits() > 0 - ? new DoubleArgument("amount", 0, Util.bigDecimalToDouble(this.manager.plugin.getConfig().maximumBalance)) - : new IntegerArgument("amount", 0, this.manager.plugin.getConfig().maximumBalance.intValue()) + ? new DoubleArgument("amount", 0) + : new IntegerArgument("amount", 0) ) .executes((sender, args) -> { this.handleSet(sender, args, currency); diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/TakeCommand.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/TakeCommand.java index 015f6f9..3f25263 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/TakeCommand.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/commands/TakeCommand.java @@ -7,7 +7,6 @@ import dev.jorel.commandapi.arguments.OfflinePlayerArgument; import dev.jorel.commandapi.executors.CommandArguments; import dev.xhyrom.lighteco.bukkit.chat.BukkitCommandSender; import dev.xhyrom.lighteco.bukkit.manager.BukkitCommandManager; -import dev.xhyrom.lighteco.bukkit.util.Util; import dev.xhyrom.lighteco.common.model.currency.Currency; import lombok.RequiredArgsConstructor; import org.bukkit.OfflinePlayer; @@ -28,8 +27,8 @@ public class TakeCommand implements Command { .withArguments( new OfflinePlayerArgument("target"), currency.getProxy().fractionalDigits() > 0 - ? new DoubleArgument("amount", 1, Util.bigDecimalToDouble(this.manager.plugin.getConfig().maximumBalance)) - : new IntegerArgument("amount", 1, this.manager.plugin.getConfig().maximumBalance.intValue()) + ? new DoubleArgument("amount", 1) + : new IntegerArgument("amount", 1) ) .executes((sender, args) -> { this.handleTake(sender, args, currency); diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/util/Util.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/util/Util.java deleted file mode 100644 index d4da7cc..0000000 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/util/Util.java +++ /dev/null @@ -1,19 +0,0 @@ -package dev.xhyrom.lighteco.bukkit.util; - -import lombok.experimental.UtilityClass; - -import java.math.BigDecimal; - -@UtilityClass -public class Util { - public double bigDecimalToDouble(final BigDecimal value) { - double amount = value.doubleValue(); - - // Don't return bigger balance than user actually has - if (BigDecimal.valueOf(amount).compareTo(value) > 0) { - amount = Math.nextAfter(amount, Double.NEGATIVE_INFINITY); - } - - return amount; - } -}