Dieser Commit ist enthalten in:
Ursprung
3552acd473
Commit
bc5f099b3b
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.message;
|
package de.steamwar.message;
|
||||||
|
|
||||||
import de.steamwar.core.BountifulWrapper;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
import de.steamwar.core.WorldOfColorWrapper;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -30,12 +29,15 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
|
private static final int JDK_VERSION = Integer.parseInt(System.getProperty("java.version").split("\\.")[1]);
|
||||||
|
|
||||||
private final String resourceBundleName;
|
private final String resourceBundleName;
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
@ -68,12 +70,19 @@ public class Message {
|
|||||||
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
|
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
|
||||||
String pattern = "";
|
String pattern = "";
|
||||||
if(prefixed)
|
if(prefixed)
|
||||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
pattern = fromRB(resourceBundle, "PREFIX") + " ";
|
||||||
pattern += (String)resourceBundle.getObject(message);
|
pattern += fromRB(resourceBundle, message);
|
||||||
|
|
||||||
return new MessageFormat(pattern, locale).format(params);
|
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){
|
private Locale getLocale(Player player){
|
||||||
return SteamwarUser.get(player).getLocale();
|
return SteamwarUser.get(player).getLocale();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren