mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	removed call to Locale#setDefault within LocaleLoader#initialize; added static locale-parameter to all instances of a Formatter (#5141)
This commit is contained in:
		| @@ -25,6 +25,7 @@ import org.bukkit.entity.Player; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.text.DecimalFormat; | ||||
| import java.text.DecimalFormatSymbols; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| @@ -34,8 +35,8 @@ public abstract class SkillCommand implements TabExecutor { | ||||
|     public static final String ABILITY_GENERIC_TEMPLATE = "Ability.Generic.Template"; | ||||
|     protected PrimarySkillType skill; | ||||
|  | ||||
|     protected DecimalFormat percent = new DecimalFormat("##0.00%"); | ||||
|     protected DecimalFormat decimal = new DecimalFormat("##0.00"); | ||||
|     protected DecimalFormat percent = new DecimalFormat("##0.00%", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|     protected DecimalFormat decimal = new DecimalFormat("##0.00", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|     protected McMMOPlayer mmoPlayer; | ||||
|  | ||||
|     private final CommandExecutor skillGuideCommand; | ||||
|   | ||||
| @@ -18,13 +18,14 @@ import org.bukkit.entity.Player; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.text.DecimalFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.LinkedHashMap; | ||||
| import java.util.List; | ||||
| import java.util.UUID; | ||||
| import java.text.DecimalFormatSymbols; | ||||
| import java.util.*; | ||||
| import java.util.function.Predicate; | ||||
|  | ||||
| public class Party { | ||||
|  | ||||
|     private static final DecimalFormat percent = new DecimalFormat("##0.00%", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|  | ||||
|     private final @NotNull Predicate<CommandSender> samePartyPredicate; | ||||
|     private final LinkedHashMap<UUID, String> members = new LinkedHashMap<>(); | ||||
|     private final List<Player> onlineMembers = new ArrayList<>(); | ||||
| @@ -204,7 +205,6 @@ public class Party { | ||||
|     } | ||||
|  | ||||
|     public String getXpToLevelPercentage() { | ||||
|         DecimalFormat percent = new DecimalFormat("##0.00%"); | ||||
|         return percent.format(this.getXp() / getXpToLevel()); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -109,7 +109,7 @@ public final class LocaleLoader { | ||||
|  | ||||
|     public static String formatString(String string, Object... messageArguments) { | ||||
|         if (messageArguments != null) { | ||||
|             MessageFormat formatter = new MessageFormat(""); | ||||
|             MessageFormat formatter = new MessageFormat("", Locale.US); | ||||
|             formatter.applyPattern(string.replace("'", "''")); | ||||
|             string = formatter.format(messageArguments); | ||||
|         } | ||||
| @@ -121,7 +121,7 @@ public final class LocaleLoader { | ||||
|  | ||||
|     public static @NotNull TextComponent formatComponent(@NotNull String string, Object... messageArguments) { | ||||
|         if (messageArguments != null) { | ||||
|             MessageFormat formatter = new MessageFormat(""); | ||||
|             MessageFormat formatter = new MessageFormat("", Locale.US); | ||||
|             formatter.applyPattern(string.replace("'", "''")); | ||||
|             string = formatter.format(messageArguments); | ||||
|         } | ||||
| @@ -138,7 +138,6 @@ public final class LocaleLoader { | ||||
|  | ||||
|     private static void initialize() { | ||||
|         if (bundle == null) { | ||||
|             Locale.setDefault(new Locale("en", "US")); | ||||
|             Locale locale = null; | ||||
|  | ||||
|             String[] myLocale = mcMMO.p.getGeneralConfig().getLocale().split("[-_ ]"); | ||||
|   | ||||
| @@ -107,7 +107,7 @@ public class CleanBackupsTask extends CancellableRunnable { | ||||
|     } | ||||
|  | ||||
|     private Date getDate(String fileName) { | ||||
|         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); | ||||
|         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss", Locale.US); | ||||
|         Date date; | ||||
|  | ||||
|         try { | ||||
|   | ||||
| @@ -8,6 +8,8 @@ import org.bukkit.entity.Player; | ||||
| import org.bukkit.plugin.PluginDescriptionFile; | ||||
|  | ||||
| import java.text.DecimalFormat; | ||||
| import java.text.DecimalFormatSymbols; | ||||
| import java.util.Locale; | ||||
|  | ||||
| public final class Motd { | ||||
|     public static final String PERK_PREFIX = LocaleLoader.getString("MOTD.PerksPrefix") + " "; | ||||
| @@ -101,7 +103,7 @@ public final class Motd { | ||||
|         double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0); | ||||
|  | ||||
|         if (cooldownReduction > 0.0) { | ||||
|             DecimalFormat percent = new DecimalFormat("##0.00%"); | ||||
|             DecimalFormat percent = new DecimalFormat("##0.00%", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|             player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Cooldowns.Name"), LocaleLoader.getString("Perks.Cooldowns.Desc", percent.format(cooldownReduction)))); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -14,11 +14,13 @@ import org.jetbrains.annotations.Nullable; | ||||
| import org.jetbrains.annotations.VisibleForTesting; | ||||
|  | ||||
| import java.text.DecimalFormat; | ||||
| import java.text.DecimalFormatSymbols; | ||||
| import java.util.Locale; | ||||
|  | ||||
| import static java.util.Objects.requireNonNull; | ||||
|  | ||||
| public class ProbabilityUtil { | ||||
|     public static final @NotNull DecimalFormat percent = new DecimalFormat("##0.00%"); | ||||
|     public static final @NotNull DecimalFormat percent = new DecimalFormat("##0.00%", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|     public static final double LUCKY_MODIFIER = 1.333D; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import org.bukkit.entity.EntityType; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.text.DecimalFormat; | ||||
| import java.text.DecimalFormatSymbols; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| @@ -18,8 +19,8 @@ import static java.util.Objects.requireNonNull; | ||||
|  */ | ||||
| public class StringUtils { | ||||
|  | ||||
|     protected static final DecimalFormat percent = new DecimalFormat("##0.00%"); | ||||
|     protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0"); | ||||
|     protected static final DecimalFormat percent = new DecimalFormat("##0.00%", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|     protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0", DecimalFormatSymbols.getInstance(Locale.US)); | ||||
|  | ||||
|     // Using concurrent hash maps to avoid concurrency issues (Folia) | ||||
|     private static final Map<EntityType, String> formattedEntityStrings = new ConcurrentHashMap<>(); | ||||
|   | ||||
| @@ -11,6 +11,7 @@ import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.zip.Deflater; | ||||
| import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipOutputStream; | ||||
| @@ -43,7 +44,7 @@ public class ZipLibrary { | ||||
|  | ||||
|         // Generate the proper date for the backup filename | ||||
|         Date date = new Date(); | ||||
|         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); | ||||
|         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss", Locale.US); | ||||
|         File fileZip = new File(BACKUP_DIRECTORY + File.separator + dateFormat.format(date) + ".zip"); | ||||
|  | ||||
|         // Create the Source List, and add directories/etc to the file. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Philip Hell
					Philip Hell