Admin and Party chat prefixes are now customizable

Closes #578
This commit is contained in:
TfT_02
2013-08-17 12:18:29 +02:00
parent 560c3860b4
commit 1f712063bf
20 changed files with 17 additions and 32 deletions

View File

@ -7,7 +7,7 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), "Commands.AdminChat.Prefix");
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
}
@Override

View File

@ -28,7 +28,7 @@ public abstract class ChatManager {
}
displayName = useDisplayNames ? event.getDisplayName() : event.getSender();
message = LocaleLoader.getString(chatPrefix, displayName) + event.getMessage();
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
sendMessage();
}

View File

@ -11,7 +11,7 @@ public class PartyChatManager extends ChatManager {
private Party party;
protected PartyChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getPartyDisplayNames(), "Commands.Party.Chat.Prefix");
super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
}
public void setParty(Party party) {

View File

@ -225,7 +225,9 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public String getPartyChatPrefix() { return config.getString("Commands.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
/* Mob Healthbar */

View File

@ -46,17 +46,19 @@ public final class LocaleLoader {
}
private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException {
String output = bundle.getString(key);
return formatString(bundle.getString(key), messageArguments);
}
public static String formatString(String string, Object... messageArguments) {
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
formatter.applyPattern(string);
string = formatter.format(messageArguments);
}
output = addColors(output);
string = addColors(string);
return output;
return string;
}
public static Locale getCurrentLocale() {