Merge pull request #553 from Krakenied/strip-price-colors

Add option to strip price colors
This commit is contained in:
Max Lee 2023-05-20 14:46:08 +01:00 committed by GitHub
commit 6602be68e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -120,6 +120,9 @@ public class Properties {
@ConfigurationComment("Should the plugin try to use a language file that matches the client's locale setting?") @ConfigurationComment("Should the plugin try to use a language file that matches the client's locale setting?")
public static boolean USE_CLIENT_LOCALE = true; 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 @PrecededBySpace
@ConfigurationComment("What containers are allowed to hold a shop? (Only blocks with inventories work!)") @ConfigurationComment("What containers are allowed to hold a shop? (Only blocks with inventories work!)")
@Parser("MaterialSet") @Parser("MaterialSet")

View File

@ -1,5 +1,6 @@
package com.Acrobot.ChestShop.Listeners.Economy.Plugins; 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.AccountCheckEvent;
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent; import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
import com.Acrobot.ChestShop.Events.Economy.CurrencyAmountEvent; 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.Reserve;
import net.tnemc.core.economy.EconomyAPI; import net.tnemc.core.economy.EconomyAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -99,7 +101,8 @@ public class ReserveListener extends EconomyAdapter {
} }
if (provided()) { 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); event.setHandled(true);
} }
} }

View File

@ -5,11 +5,13 @@ import java.util.logging.Level;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Listeners.Economy.EconomyAdapter; import com.Acrobot.ChestShop.Listeners.Economy.EconomyAdapter;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse; import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -172,7 +174,7 @@ public class VaultListener extends EconomyAdapter {
} }
String formatted = provider.format(event.getAmount().doubleValue()); String formatted = provider.format(event.getAmount().doubleValue());
event.setFormattedAmount(formatted); event.setFormattedAmount(Properties.STRIP_PRICE_COLORS ? ChatColor.stripColor(formatted) : formatted);
event.setHandled(true); event.setHandled(true);
} }