Fixed chat formatting - Mostly ¯\_(ツ)_/¯ #59
1 changed files with 8 additions and 2 deletions
|
@ -64,7 +64,7 @@ public final class ChatFormatter {
|
||||||
else
|
else
|
||||||
return Integer.compare(s1.Start, s2.Start);
|
return Integer.compare(s1.Start, s2.Start);
|
||||||
});
|
});
|
||||||
List<FormattedSection> combined = new ArrayList<>();
|
ArrayList<FormattedSection> combined = new ArrayList<>();
|
||||||
Map<ChatFormatter, FormattedSection> nextSection = new HashMap<>();
|
Map<ChatFormatter, FormattedSection> nextSection = new HashMap<>();
|
||||||
boolean escaped = false;
|
boolean escaped = false;
|
||||||
for (int i = 0; i < sections.size(); i++) {
|
for (int i = 0; i < sections.size(); i++) {
|
||||||
|
@ -72,14 +72,20 @@ public final class ChatFormatter {
|
||||||
final FormattedSection section = sections.get(i);
|
final FormattedSection section = sections.get(i);
|
||||||
if (!section.IsRange) {
|
if (!section.IsRange) {
|
||||||
escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER);
|
escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER);
|
||||||
|
combined.add(section);
|
||||||
continue; // TODO: Escape \ and check and fix escape logic
|
continue; // TODO: Escape \ and check and fix escape logic
|
||||||
}
|
} // TODO: Actually combine overlapping sections
|
||||||
if (nextSection.containsKey(section.Formatters.get(0)) && !escaped) {
|
if (nextSection.containsKey(section.Formatters.get(0)) && !escaped) {
|
||||||
FormattedSection s = nextSection.remove(section.Formatters.get(0));
|
FormattedSection s = nextSection.remove(section.Formatters.get(0));
|
||||||
|
DebugCommand.SendDebugMessage("Finishing section: " + s);
|
||||||
s.End = section.Start;
|
s.End = section.Start;
|
||||||
combined.add(s);
|
combined.add(s);
|
||||||
|
} else {
|
||||||
|
DebugCommand.SendDebugMessage("Adding next section: " + section);
|
||||||
|
nextSection.put(section.Formatters.get(0), section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sections = combined;
|
||||||
for (int i = 0; i < sections.size(); i++) {
|
for (int i = 0; i < sections.size(); i++) {
|
||||||
FormattedSection section = sections.get(i);
|
FormattedSection section = sections.get(i);
|
||||||
DebugCommand.SendDebugMessage("Applying section: " + section);
|
DebugCommand.SendDebugMessage("Applying section: " + section);
|
||||||
|
|
Loading…
Reference in a new issue