Add {TEAMPREFIX} {TEAMSUFFIX} and {TEAMNAME} to chat formatting.

This commit is contained in:
KHobbits 2013-06-28 17:12:01 +01:00
parent db234b9837
commit 0e43233e46
2 changed files with 10 additions and 0 deletions

View File

@ -418,6 +418,9 @@ public class Settings implements ISettings
mFormat = mFormat.replace("{GROUP}", "{0}"); mFormat = mFormat.replace("{GROUP}", "{0}");
mFormat = mFormat.replace("{WORLDNAME}", "{1}"); mFormat = mFormat.replace("{WORLDNAME}", "{1}");
mFormat = mFormat.replace("{SHORTWORLDNAME}", "{2}"); mFormat = mFormat.replace("{SHORTWORLDNAME}", "{2}");
mFormat = mFormat.replace("{TEAMPREFIX}", "{3}");
mFormat = mFormat.replace("{TEAMSUFFIX}", "{4}");
mFormat = mFormat.replace("{TEAMNAME}", "{5}");
mFormat = "§r".concat(mFormat); mFormat = "§r".concat(mFormat);
chatFormats.put(group, mFormat); chatFormats.put(group, mFormat);
} }

View File

@ -11,6 +11,8 @@ import org.bukkit.Server;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
@ -48,10 +50,15 @@ 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();
Team team = user.getScoreboard().getPlayerTeam(user);
String format = ess.getSettings().getChatFormat(group); String format = ess.getSettings().getChatFormat(group);
format = format.replace("{0}", group); format = format.replace("{0}", group);
format = format.replace("{1}", world); format = format.replace("{1}", world);
format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH)); format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH));
format = format.replace("{3}", team == null ? "" : team.getPrefix());
format = format.replace("{4}", team == null ? "" : team.getSuffix());
format = format.replace("{5}", team == null ? "" : team.getDisplayName());
synchronized (format) synchronized (format)
{ {
event.setFormat(format); event.setFormat(format);