From 2fb82a252912ead1ff89e74aa6c4008d4be5f7eb Mon Sep 17 00:00:00 2001 From: Krakenied Date: Sat, 20 May 2023 14:56:06 +0200 Subject: [PATCH] Strip price colors --- .../java/com/Acrobot/ChestShop/Configuration/Properties.java | 3 +++ .../ChestShop/Listeners/Economy/Plugins/ReserveListener.java | 5 ++++- .../ChestShop/Listeners/Economy/Plugins/VaultListener.java | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index 392deda..2183c27 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -120,6 +120,9 @@ public class Properties { @ConfigurationComment("Should the plugin try to use a language file that matches the client's locale setting?") public static boolean USE_CLIENT_LOCALE = true; + @ConfigurationComment("Should the plugin strip the colors from formatted price?") + public static boolean STRIP_PRICE_COLORS = false; + @PrecededBySpace @ConfigurationComment("What containers are allowed to hold a shop? (Only blocks with inventories work!)") @Parser("MaterialSet") diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/ReserveListener.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/ReserveListener.java index 58f50c1..c0340aa 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/ReserveListener.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Economy/Plugins/ReserveListener.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Listeners.Economy.Plugins; +import com.Acrobot.ChestShop.Configuration.Properties; import com.Acrobot.ChestShop.Events.Economy.AccountCheckEvent; import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent; import com.Acrobot.ChestShop.Events.Economy.CurrencyAmountEvent; @@ -12,6 +13,7 @@ import com.Acrobot.ChestShop.Listeners.Economy.EconomyAdapter; import net.tnemc.core.Reserve; import net.tnemc.core.economy.EconomyAPI; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import javax.annotation.Nullable; @@ -99,7 +101,8 @@ public class ReserveListener extends EconomyAdapter { } if (provided()) { - event.setFormattedAmount(economyAPI.format(event.getAmount())); + String formatted = economyAPI.format(event.getAmount()); + event.setFormattedAmount(Properties.STRIP_PRICE_COLORS ? ChatColor.stripColor(formatted) : formatted); event.setHandled(true); } } 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 01091e8..573627c 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 @@ -5,11 +5,13 @@ import java.util.logging.Level; import javax.annotation.Nullable; +import com.Acrobot.ChestShop.Configuration.Properties; import com.Acrobot.ChestShop.Listeners.Economy.EconomyAdapter; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -172,7 +174,7 @@ public class VaultListener extends EconomyAdapter { } String formatted = provider.format(event.getAmount().doubleValue()); - event.setFormattedAmount(formatted); + event.setFormattedAmount(Properties.STRIP_PRICE_COLORS ? ChatColor.stripColor(formatted) : formatted); event.setHandled(true); }