mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Merge remote-tracking branch 'games647/java9' into 1.13
This commit is contained in:
commit
ba959586e2
@ -17,8 +17,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@ -1352,24 +1350,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
DecimalFormat currencyFormat = new DecimalFormat(currencyFormatString, decimalFormatSymbols);
|
DecimalFormat currencyFormat = new DecimalFormat(currencyFormatString, decimalFormatSymbols);
|
||||||
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
|
currencyFormat.setRoundingMode(RoundingMode.FLOOR);
|
||||||
|
|
||||||
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials
|
// Updates NumberUtil#PRETTY_FORMAT field so that all of Essentials can follow a single format.
|
||||||
// can follow a single format.
|
NumberUtil.internalSetPrettyFormat(currencyFormat);
|
||||||
try {
|
|
||||||
Field field = NumberUtil.class.getDeclaredField("PRETTY_FORMAT");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
|
||||||
modifiersField.setAccessible(true);
|
|
||||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
|
||||||
field.set(null, currencyFormat);
|
|
||||||
modifiersField.setAccessible(false);
|
|
||||||
field.setAccessible(false);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
ess.getLogger().severe("Failed to apply custom currency format: " + e.getMessage());
|
|
||||||
if (isDebug()) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return currencyFormat;
|
return currencyFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
public class NumberUtil {
|
public class NumberUtil {
|
||||||
static DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
|
||||||
static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
private static DecimalFormat twoDPlaces = new DecimalFormat("#,###.##");
|
||||||
|
private static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||||
|
|
||||||
// This field is likely to be modified in com.earth2me.essentials.Settings when loading currency format.
|
// This field is likely to be modified in com.earth2me.essentials.Settings when loading currency format.
|
||||||
// This ensures that we can supply a constant formatting.
|
// This ensures that we can supply a constant formatting.
|
||||||
static final NumberFormat PRETTY_FORMAT = NumberFormat.getInstance(Locale.US);
|
private static NumberFormat PRETTY_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
twoDPlaces.setRoundingMode(RoundingMode.HALF_UP);
|
twoDPlaces.setRoundingMode(RoundingMode.HALF_UP);
|
||||||
@ -30,6 +30,11 @@ public class NumberUtil {
|
|||||||
PRETTY_FORMAT.setMaximumFractionDigits(2);
|
PRETTY_FORMAT.setMaximumFractionDigits(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this method should only be called by Essentials
|
||||||
|
public static void internalSetPrettyFormat(NumberFormat prettyFormat) {
|
||||||
|
PRETTY_FORMAT = prettyFormat;
|
||||||
|
}
|
||||||
|
|
||||||
public static String shortCurrency(final BigDecimal value, final IEssentials ess) {
|
public static String shortCurrency(final BigDecimal value, final IEssentials ess) {
|
||||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||||
}
|
}
|
||||||
|
23
pom.xml
23
pom.xml
@ -84,29 +84,6 @@
|
|||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
|
||||||
<version>1.7</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun</groupId>
|
|
||||||
<artifactId>tools</artifactId>
|
|
||||||
<version>1.5.0</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${java.home}/../lib/tools.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<inherited>false</inherited>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user