mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Drop messageFormat for simple string replace, remove duped ' marks.
This commit is contained in:
parent
3e519f95d5
commit
0292cb59cd
@ -27,7 +27,7 @@ public interface ISettings extends IConf
|
|||||||
|
|
||||||
long getBackupInterval();
|
long getBackupInterval();
|
||||||
|
|
||||||
MessageFormat getChatFormat(String group);
|
String getChatFormat(String group);
|
||||||
|
|
||||||
int getChatRadius();
|
int getChatRadius();
|
||||||
|
|
||||||
|
@ -402,26 +402,23 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
return config.getString("backup.command", null);
|
return config.getString("backup.command", null);
|
||||||
}
|
}
|
||||||
private Map<String, MessageFormat> chatFormats = Collections.synchronizedMap(new HashMap<String, MessageFormat>());
|
private Map<String, String> chatFormats = Collections.synchronizedMap(new HashMap<String, String>());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessageFormat getChatFormat(String group)
|
public String getChatFormat(String group)
|
||||||
{
|
{
|
||||||
MessageFormat mFormat = chatFormats.get(group);
|
String mFormat = chatFormats.get(group);
|
||||||
if (mFormat == null)
|
if (mFormat == null)
|
||||||
{
|
{
|
||||||
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
mFormat = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||||
config.getString("chat.format", "&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}"));
|
config.getString("chat.format", "&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}"));
|
||||||
format = FormatUtil.replaceFormat(format);
|
mFormat = FormatUtil.replaceFormat(mFormat);
|
||||||
format = format.replace("'", "''");
|
mFormat = mFormat.replace("{DISPLAYNAME}", "%1$s");
|
||||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
mFormat = mFormat.replace("{MESSAGE}", "%2$s");
|
||||||
format = format.replace("{GROUP}", "{0}");
|
mFormat = mFormat.replace("{GROUP}", "{0}");
|
||||||
format = format.replace("{MESSAGE}", "%2$s");
|
mFormat = mFormat.replace("{WORLDNAME}", "{1}");
|
||||||
format = format.replace("{WORLDNAME}", "{1}");
|
mFormat = mFormat.replace("{SHORTWORLDNAME}", "{2}");
|
||||||
format = format.replace("{SHORTWORLDNAME}", "{2}");
|
mFormat = "§r".concat(mFormat);
|
||||||
format = format.replaceAll("\\{(\\D*?)\\}", "'\\{$1\\}'");
|
|
||||||
format = "§r".concat(format);
|
|
||||||
mFormat = new MessageFormat(format);
|
|
||||||
chatFormats.put(group, mFormat);
|
chatFormats.put(group, mFormat);
|
||||||
}
|
}
|
||||||
return mFormat;
|
return mFormat;
|
||||||
|
@ -48,13 +48,13 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
|||||||
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
|
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
|
||||||
String group = user.getGroup();
|
String group = user.getGroup();
|
||||||
String world = user.getWorld().getName();
|
String world = user.getWorld().getName();
|
||||||
MessageFormat format = ess.getSettings().getChatFormat(group);
|
String format = ess.getSettings().getChatFormat(group);
|
||||||
|
format = format.replace("{0}", group);
|
||||||
|
format = format.replace("{1}", world);
|
||||||
|
format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH));
|
||||||
synchronized (format)
|
synchronized (format)
|
||||||
{
|
{
|
||||||
event.setFormat(format.format(new Object[]
|
event.setFormat(format);
|
||||||
{
|
|
||||||
group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user