From 0d08880ed212d4bfbe0be4dc3f42e0dde1a65d5b Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Sun, 3 May 2020 02:37:06 +0100 Subject: [PATCH] Some cleanup of code and deprecated stuff Also deprecate amount and account setters on the CurrencyCheckEvent, these values will be final in a future version. Changing them here does not make sense in the internal structure. --- .../ChestShop/Events/Economy/CurrencyCheckEvent.java | 10 ++++++++-- .../Listeners/Economy/Plugins/VaultListener.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyCheckEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyCheckEvent.java index 4e47c8a..aaef505 100644 --- a/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyCheckEvent.java +++ b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyCheckEvent.java @@ -16,7 +16,7 @@ import java.util.UUID; public class CurrencyCheckEvent extends Event { private static final HandlerList handlers = new HandlerList(); - boolean outcome = false; + private boolean outcome = false; private BigDecimal amount; private UUID account; @@ -59,6 +59,7 @@ public class CurrencyCheckEvent extends Event { * @return Amount of currency, as a double * @deprecated Use {@link #getAmount()} if possible */ + @Deprecated public double getDoubleAmount() { return amount.doubleValue(); } @@ -67,7 +68,9 @@ public class CurrencyCheckEvent extends Event { * Sets the amount of currency transferred * * @param amount Amount to transfer + * @deprecated The amount should not be changed! */ + @Deprecated public void setAmount(BigDecimal amount) { this.amount = amount; } @@ -76,8 +79,9 @@ public class CurrencyCheckEvent extends Event { * Sets the amount of currency transferred * * @param amount Amount to transfer - * @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible + * @deprecated The amount should not be changed! Use {@link #setAmount(java.math.BigDecimal)} if possible */ + @Deprecated public void setAmount(double amount) { this.amount = BigDecimal.valueOf(amount); } @@ -100,7 +104,9 @@ public class CurrencyCheckEvent extends Event { * Sets the account name * * @param account Account name + * @deprecated The account should not be changed! */ + @Deprecated public void setAccount(UUID account) { this.account = account; } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/VaultListener.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/VaultListener.java index b3b022d..98bd9b1 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/VaultListener.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/VaultListener.java @@ -137,7 +137,7 @@ public class VaultListener extends EconomyAdapter { try { event.hasEnough(lastSeen != null && provider.has(lastSeen, world.getName(), event.getAmount().doubleValue())); } catch (Exception e) { - ChestShop.getBukkitLogger().log(Level.WARNING, "Could not check if account of " + lastSeen.getUniqueId() + "/" + lastSeen.getName() + " has " + event.getDoubleAmount() + "." + + ChestShop.getBukkitLogger().log(Level.WARNING, "Could not check if account of " + lastSeen.getUniqueId() + "/" + lastSeen.getName() + " has " + event.getAmount() + "." + "This is probably due to https://github.com/MilkBowl/Vault/issues/746 and has to be fixed in either Vault directly or your economy plugin." + "If you are sure it's not this issue then please report the following error.", e); } @@ -168,7 +168,7 @@ public class VaultListener extends EconomyAdapter { return; } - String formatted = provider.format(event.getDoubleAmount()); + String formatted = provider.format(event.getAmount().doubleValue()); event.setFormattedAmount(formatted); }