Replace Reflection with setter implementation

This commit is contained in:
games647 2018-03-21 11:16:16 +01:00
parent d24fbc9f55
commit c7000846cd
No known key found for this signature in database
GPG key ID: BFC68C8708713A88
2 changed files with 8 additions and 17 deletions

View file

@ -16,8 +16,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@ -1333,20 +1331,8 @@ public class Settings implements net.ess3.api.ISettings {
DecimalFormat currencyFormat = new DecimalFormat(currencyFormatString, decimalFormatSymbols);
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials
// can follow a single format.
try {
Field field = NumberUtil.class.getDeclaredField("PRETTY_FORMAT");
field.setAccessible(true);
field.set(null, currencyFormat);
field.setAccessible(false);
} catch (NoSuchFieldException | IllegalAccessException e) {
ess.getLogger().severe("Failed to apply custom currency format: " + e.getMessage());
if (isDebug()) {
e.printStackTrace();
}
}
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials can follow a single format.
NumberUtil.internalSetPrettyFormat(currencyFormat);
return currencyFormat;
}