Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/net/coreprotect/language/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.concurrent.ConcurrentHashMap;

import org.bukkit.ChatColor;

public class Language {

private static ConcurrentHashMap<Phrase, String> phrases = new ConcurrentHashMap<>();
Expand All @@ -21,10 +23,16 @@ protected static String getTranslatedPhrase(Phrase phrase) {
}

protected static void setUserPhrase(Phrase phrase, String value) {
if (value != null) {
value = ChatColor.translateAlternateColorCodes('&', value);
}
userPhrases.put(phrase, value);
}

protected static void setTranslatedPhrase(Phrase phrase, String value) {
if (value != null) {
value = ChatColor.translateAlternateColorCodes('&', value);
}
translatedPhrases.put(phrase, value);
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/coreprotect/utility/Chat.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ private Chat() {
throw new IllegalStateException("Utility class");
}

public static String translateColorCodes(String text) {
if (text == null) {
return null;
}
return ChatColor.translateAlternateColorCodes('&', text);
}

public static void sendComponent(CommandSender sender, String string, String bypass) {
string = translateColorCodes(string);
SpigotAdapter.ADAPTER.sendComponent(sender, string, bypass);
}

Expand All @@ -32,6 +40,7 @@ public static void sendComponent(CommandSender sender, String string) {
}

public static void sendMessage(CommandSender sender, String message) {
message = translateColorCodes(message);
if (sender instanceof ConsoleCommandSender) {
message = message.replace(Color.DARK_AQUA, ChatColor.DARK_AQUA.toString());
}
Expand All @@ -40,10 +49,12 @@ public static void sendMessage(CommandSender sender, String message) {
}

public static void sendConsoleMessage(String string) {
string = translateColorCodes(string);
Bukkit.getServer().getConsoleSender().sendMessage(string);
}

public static void console(String string) {
string = translateColorCodes(string);
if (string.startsWith("-") || string.startsWith("[")) {
Bukkit.getLogger().log(Level.INFO, string);
}
Expand All @@ -53,6 +64,7 @@ public static void console(String string) {
}

public static void sendGlobalMessage(CommandSender user, String string) {
string = translateColorCodes(string);
if (user instanceof ConsoleCommandSender) {
sendMessage(user, Color.DARK_AQUA + "[CoreProtect] " + Color.WHITE + string);
return;
Expand Down