SteamWar/SpigotCore
Archiviert
13
0

Fix Java 8 Properties
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-06-13 20:53:27 +02:00
Ursprung 3552acd473
Commit bc5f099b3b

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.message;
import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.WorldOfColorWrapper;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ClickEvent;
@ -30,12 +29,15 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
public class Message {
private static final int JDK_VERSION = Integer.parseInt(System.getProperty("java.version").split("\\.")[1]);
private final String resourceBundleName;
private final ClassLoader classLoader;
@ -68,12 +70,19 @@ public class Message {
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
String pattern = "";
if(prefixed)
pattern = resourceBundle.getObject("PREFIX") + " ";
pattern += (String)resourceBundle.getObject(message);
pattern = fromRB(resourceBundle, "PREFIX") + " ";
pattern += fromRB(resourceBundle, message);
return new MessageFormat(pattern, locale).format(params);
}
private String fromRB(ResourceBundle bundle, String key) {
String result = bundle.getString(key);
if(JDK_VERSION < 9)
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
return result;
}
private Locale getLocale(Player player){
return SteamwarUser.get(player).getLocale();
}