Properly added a bug as a feature
Wth did I just do before - Anyways, fixed null nicknames
This commit is contained in:
parent
845f3e1f16
commit
a3b3af859a
2 changed files with 11 additions and 8 deletions
|
@ -122,11 +122,17 @@ public class ChatProcessing {
|
||||||
namesb.append(")");
|
namesb.append(")");
|
||||||
StringBuilder nicksb = new StringBuilder();
|
StringBuilder nicksb = new StringBuilder();
|
||||||
nicksb.append("(?i)(");
|
nicksb.append("(?i)(");
|
||||||
for (Player p : PluginMain.GetPlayers())
|
for (Player p : PluginMain.GetPlayers()) {
|
||||||
nicksb.append(PlayerListener.nicknames.inverse().get(p.getUniqueId())).append("|");
|
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.deleteCharAt(nicksb.length() - 1);
|
||||||
nicksb.append(")");
|
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)
|
formatters.add(new ChatFormatterBuilder().setRegex(Pattern.compile(namesb.toString())).setColor(Color.Aqua)
|
||||||
.setOnmatch((String match) -> {
|
.setOnmatch((String match) -> {
|
||||||
Player p = Bukkit.getPlayer(match);
|
Player p = Bukkit.getPlayer(match);
|
||||||
|
|
|
@ -164,11 +164,8 @@ public final class ChatFormatter {
|
||||||
section.Formatters.sort((cf2, cf1) -> cf1.priority.compareTo(cf2.priority));
|
section.Formatters.sort((cf2, cf1) -> cf1.priority.compareTo(cf2.priority));
|
||||||
for (ChatFormatter formatter : section.Formatters) {
|
for (ChatFormatter formatter : section.Formatters) {
|
||||||
DebugCommand.SendDebugMessage("Applying formatter: " + formatter);
|
DebugCommand.SendDebugMessage("Applying formatter: " + formatter);
|
||||||
if (formatter.onmatch != null) {
|
if (formatter.onmatch != null)
|
||||||
String f = formatter.onmatch.apply(originaltext);
|
originaltext = formatter.onmatch.apply(originaltext);
|
||||||
if (f != null)
|
|
||||||
originaltext = f; //TODO: Find out...
|
|
||||||
}
|
|
||||||
if (formatter.color != null)
|
if (formatter.color != null)
|
||||||
color = formatter.color;
|
color = formatter.color;
|
||||||
if (formatter.format != null)
|
if (formatter.format != null)
|
||||||
|
|
Loading…
Reference in a new issue