Properly added a bug as a feature

Wth did I just do before - Anyways, fixed null nicknames
This commit is contained in:
Norbi Peti 2016-12-16 21:25:13 +01:00
parent 845f3e1f16
commit a3b3af859a
2 changed files with 11 additions and 8 deletions

View file

@ -122,11 +122,17 @@ public class ChatProcessing {
namesb.append(")");
StringBuilder nicksb = new StringBuilder();
nicksb.append("(?i)(");
for (Player p : PluginMain.GetPlayers())
nicksb.append(PlayerListener.nicknames.inverse().get(p.getUniqueId())).append("|");
for (Player p : PluginMain.GetPlayers()) {
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
if (nick != null) // Not everyone has a nickname
nicksb.append(nick).append("|");
}
nicksb.deleteCharAt(nicksb.length() - 1);
nicksb.append(")");
formatters
.add(new ChatFormatterBuilder().setRegex(Pattern.compile("null")).setColor(Color.DarkRed).build()); // Properly added a bug as a feature
formatters.add(new ChatFormatterBuilder().setRegex(Pattern.compile(namesb.toString())).setColor(Color.Aqua)
.setOnmatch((String match) -> {
Player p = Bukkit.getPlayer(match);

View file

@ -164,15 +164,12 @@ public final class ChatFormatter {
section.Formatters.sort((cf2, cf1) -> cf1.priority.compareTo(cf2.priority));
for (ChatFormatter formatter : section.Formatters) {
DebugCommand.SendDebugMessage("Applying formatter: " + formatter);
if (formatter.onmatch != null) {
String f = formatter.onmatch.apply(originaltext);
if (f != null)
originaltext = f; //TODO: Find out...
}
if (formatter.onmatch != null)
originaltext = formatter.onmatch.apply(originaltext);
if (formatter.color != null)
color = formatter.color;
if (formatter.format != null)
format = formatter.format.getFlag(); // TODO: Fix
format = formatter.format.getFlag(); //TODO: Fix
if (formatter.openlink != null)
openlink = formatter.openlink;
}