1.14 support, fixes #105
3 changed files with 180 additions and 175 deletions
|
@ -178,15 +178,14 @@ public class ChatProcessing {
|
||||||
if (score < 0) // Never send messages to score below 0
|
if (score < 0) // Never send messages to score below 0
|
||||||
sender.sendMessage("§cYou don't have permission to send this message or something went wrong");
|
sender.sendMessage("§cYou don't have permission to send this message or something went wrong");
|
||||||
else {
|
else {
|
||||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
ChatUtils.dispatchConsoleCommand(
|
||||||
String.format("tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID,
|
String.format("tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID,
|
||||||
score, jsonstr));
|
score, jsonstr), true);
|
||||||
val tc = ComponentManager.getIfEnabled(TownyComponent.class);
|
val tc = ComponentManager.getIfEnabled(TownyComponent.class);
|
||||||
if (tc != null) tc.handleSpies(channel, json, ChatProcessing::toJson);
|
if (tc != null) tc.handleSpies(channel, json, ChatProcessing::toJson);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
ChatUtils.dispatchConsoleCommand(String.format("tellraw @a %s", jsonstr), true);
|
||||||
String.format("tellraw @a %s", jsonstr));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
TBMCCoreAPI.SendException("An error occured while sending a chat message!", ex);
|
TBMCCoreAPI.SendException("An error occured while sending a chat message!", ex);
|
||||||
sender.sendMessage("§cAn error occured while sending the message.");
|
sender.sendMessage("§cAn error occured while sending the message.");
|
||||||
|
|
20
src/main/java/buttondevteam/chat/ChatUtils.java
Normal file
20
src/main/java/buttondevteam/chat/ChatUtils.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package buttondevteam.chat;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public final class ChatUtils {
|
||||||
|
private ChatUtils() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch a console command.
|
||||||
|
*
|
||||||
|
* @param command The command
|
||||||
|
* @param async Whether the caller is async
|
||||||
|
*/
|
||||||
|
public static void dispatchConsoleCommand(String command, boolean async) {
|
||||||
|
if (async)
|
||||||
|
Bukkit.getScheduler().runTask(PluginMain.Instance, () -> Bukkit.dispatchCommand(PluginMain.Console, command));
|
||||||
|
else
|
||||||
|
Bukkit.dispatchCommand(PluginMain.Console, command);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,6 @@ import java.util.stream.Collectors;
|
||||||
* again.
|
* again.
|
||||||
*
|
*
|
||||||
* @author NorbiPeti
|
* @author NorbiPeti
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@ -64,74 +63,67 @@ public final class ChatFormatter {
|
||||||
* This method assumes that there is always a global formatter
|
* This method assumes that there is always a global formatter
|
||||||
*/
|
*/
|
||||||
header("ChatFormatter.Combine begin");
|
header("ChatFormatter.Combine begin");
|
||||||
ArrayList<FormattedSection> sections = new ArrayList<FormattedSection>();
|
ArrayList<FormattedSection> sections = new ArrayList<>();
|
||||||
|
|
||||||
for (ChatFormatter formatter : formatters) {
|
createSections(formatters, str, sections, true);
|
||||||
if (formatter.type != Type.Excluder)
|
|
||||||
continue;
|
|
||||||
Matcher matcher = formatter.regex.matcher(str);
|
|
||||||
while (matcher.find()) {
|
|
||||||
DebugCommand.SendDebugMessage("Found match from " + matcher.start() + " to " + (matcher.end() - 1));
|
|
||||||
DebugCommand.SendDebugMessage("With excluder formatter:" + formatter);
|
|
||||||
sendMessageWithPointer(str, matcher.start(), matcher.end() - 1);
|
|
||||||
if (formatter.regex != ChatProcessing.ENTIRE_MESSAGE_PATTERN && sections.stream().anyMatch(fs -> fs.type == Type.Excluder && (fs.End >= matcher.start() && fs.Start <= matcher.end() - 1))) {
|
|
||||||
DebugCommand.SendDebugMessage("Ignoring formatter because of an excluder");
|
|
||||||
continue; //Exclude areas matched by excluders - Range sections are correctly handled afterwards
|
|
||||||
}
|
|
||||||
ArrayList<String> groups = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < matcher.groupCount(); i++)
|
|
||||||
groups.add(matcher.group(i + 1));
|
|
||||||
if (groups.size() > 0)
|
|
||||||
DebugCommand.SendDebugMessage("First group: " + groups.get(0));
|
|
||||||
FormattedSection section = new FormattedSection(formatter, matcher.start(), matcher.end() - 1, groups,
|
|
||||||
formatter.type);
|
|
||||||
sections.add(section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
header("Section creation (excluders done)");
|
header("Section creation (excluders done)");
|
||||||
for (ChatFormatter formatter : formatters) {
|
createSections(formatters, str, sections, false);
|
||||||
if (formatter.type == Type.Excluder)
|
sortSections(sections);
|
||||||
continue;
|
|
||||||
Matcher matcher = formatter.regex.matcher(str);
|
|
||||||
while (matcher.find()) {
|
|
||||||
DebugCommand.SendDebugMessage("Found match from " + matcher.start() + " to " + (matcher.end() - 1));
|
|
||||||
DebugCommand.SendDebugMessage("With formatter:" + formatter);
|
|
||||||
sendMessageWithPointer(str, matcher.start(), matcher.end() - 1);
|
|
||||||
if (formatter.regex != ChatProcessing.ENTIRE_MESSAGE_PATTERN && sections.stream().anyMatch(fs -> fs.type == Type.Excluder && (fs.End >= matcher.start() && fs.Start <= matcher.end() - 1))) {
|
|
||||||
DebugCommand.SendDebugMessage("Ignoring formatter because of an excluder");
|
|
||||||
continue; //Exclude areas matched by excluders - Range sections are correctly handled afterwards
|
|
||||||
}
|
|
||||||
ArrayList<String> groups = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < matcher.groupCount(); i++)
|
|
||||||
groups.add(matcher.group(i + 1));
|
|
||||||
if (groups.size() > 0)
|
|
||||||
DebugCommand.SendDebugMessage("First group: " + groups.get(0));
|
|
||||||
FormattedSection section = new FormattedSection(formatter, matcher.start(), matcher.end() - 1, groups,
|
|
||||||
formatter.type);
|
|
||||||
sections.add(section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sections.sort(
|
|
||||||
(s1, s2) -> s1.Start == s2.Start
|
|
||||||
? s1.End == s2.End ? Integer.compare(s2.Formatters.get(0).priority.GetValue(),
|
|
||||||
s1.Formatters.get(0).priority.GetValue()) : Integer.compare(s2.End, s1.End)
|
|
||||||
: Integer.compare(s1.Start, s2.Start));
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 0: Start - 1: End index
|
* 0: Start - 1: End index
|
||||||
*/
|
*/
|
||||||
val remchars = new ArrayList<int[]>();
|
val remchars = new ArrayList<int[]>();
|
||||||
|
|
||||||
header("Range section conversion");
|
header("Range section conversion");
|
||||||
|
sections = convertRangeSections(str, sections, remchars);
|
||||||
|
|
||||||
|
header("Adding remove chars (RC)"); // Important to add after the range section conversion
|
||||||
|
addRemChars(sections, remchars);
|
||||||
|
|
||||||
|
header("Section combining");
|
||||||
|
combineSections(str, sections);
|
||||||
|
|
||||||
|
header("Section applying");
|
||||||
|
applySections(str, tp, sections, remchars);
|
||||||
|
header("ChatFormatter.Combine done");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createSections(List<ChatFormatter> formatters, String str, ArrayList<FormattedSection> sections,
|
||||||
|
boolean excluders) {
|
||||||
|
for (ChatFormatter formatter : formatters) {
|
||||||
|
if (excluders == (formatter.type != Type.Excluder))
|
||||||
|
continue; //If we're looking at excluders and this isn't one, skip - or vica-versa
|
||||||
|
Matcher matcher = formatter.regex.matcher(str);
|
||||||
|
while (matcher.find()) {
|
||||||
|
DebugCommand.SendDebugMessage("Found match from " + matcher.start() + " to " + (matcher.end() - 1));
|
||||||
|
DebugCommand.SendDebugMessage("With " + (excluders ? "excluder " : "") + "formatter: " + formatter);
|
||||||
|
sendMessageWithPointer(str, matcher.start(), matcher.end() - 1);
|
||||||
|
if (formatter.regex != ChatProcessing.ENTIRE_MESSAGE_PATTERN && sections.stream().anyMatch(fs -> fs.type == Type.Excluder && (fs.End >= matcher.start() && fs.Start <= matcher.end() - 1))) {
|
||||||
|
DebugCommand.SendDebugMessage("Ignoring formatter because of an excluder");
|
||||||
|
continue; //Exclude areas matched by excluders - Range sections are correctly handled afterwards
|
||||||
|
}
|
||||||
|
ArrayList<String> groups = new ArrayList<>();
|
||||||
|
for (int i = 0; i < matcher.groupCount(); i++)
|
||||||
|
groups.add(matcher.group(i + 1));
|
||||||
|
if (groups.size() > 0)
|
||||||
|
DebugCommand.SendDebugMessage("First group: " + groups.get(0));
|
||||||
|
FormattedSection section = new FormattedSection(formatter, matcher.start(), matcher.end() - 1, groups,
|
||||||
|
formatter.type);
|
||||||
|
sections.add(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<FormattedSection> convertRangeSections(String str, ArrayList<FormattedSection> sections, ArrayList<int[]> remchars) {
|
||||||
ArrayList<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;
|
||||||
int takenStart = -1, takenEnd = -1;
|
int takenStart = -1, takenEnd = -1;
|
||||||
ChatFormatter takenFormatter = null;
|
ChatFormatter takenFormatter = null;
|
||||||
for (int i = 0; i < sections.size(); i++) {
|
for (final FormattedSection section : sections) {
|
||||||
// Set ending to -1 until closed with another 1 long "section" - only do this if IsRange is true
|
// Set ending to -1 until closed with another 1 long "section" - only do this if IsRange is true
|
||||||
final FormattedSection section = sections.get(i);
|
|
||||||
if (section.type != Type.Range) {
|
if (section.type != Type.Range) {
|
||||||
escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER) && !escaped; // Enable escaping on first \, disable on second
|
escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER) && !escaped; // Enable escaping on first \, disable on second
|
||||||
if (escaped) {// Don't add the escape character
|
if (escaped) {// Don't add the escape character
|
||||||
|
@ -145,12 +137,6 @@ public final class ChatFormatter {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!escaped) {
|
if (!escaped) {
|
||||||
if (combined.stream().anyMatch(s -> section.type != Type.Range && (s.Start == section.Start
|
|
||||||
|| (s.Start < section.Start ? s.End >= section.Start : s.Start <= section.End)))) {
|
|
||||||
DebugCommand.SendDebugMessage("Range " + section + " overlaps with a combined section, ignoring.");
|
|
||||||
sendMessageWithPointer(str, section.Start, section.End);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (section.Start == takenStart || (section.Start > takenStart && section.Start < takenEnd)) {
|
if (section.Start == takenStart || (section.Start > takenStart && section.Start < takenEnd)) {
|
||||||
/*
|
/*
|
||||||
* if (nextSection.containsKey(section.Formatters.get(0)) ? section.RemCharFromStart <= takenEnd - takenStart : section.RemCharFromStart > takenEnd - takenStart) {
|
* if (nextSection.containsKey(section.Formatters.get(0)) ? section.RemCharFromStart <= takenEnd - takenStart : section.RemCharFromStart > takenEnd - takenStart) {
|
||||||
|
@ -193,21 +179,24 @@ public final class ChatFormatter {
|
||||||
}
|
}
|
||||||
//Do not finish unfinished sections, ignore them
|
//Do not finish unfinished sections, ignore them
|
||||||
sections = combined;
|
sections = combined;
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
header("Adding remove chars (RC)"); // Important to add after the range section conversion
|
private static void addRemChars(ArrayList<FormattedSection> sections, ArrayList<int[]> remchars) {
|
||||||
sections.stream()
|
sections.stream()
|
||||||
.flatMap(fs -> fs.Formatters.stream().filter(cf -> cf.removeCharCount > 0)
|
.flatMap(fs -> fs.Formatters.stream().filter(cf -> cf.removeCharCount > 0)
|
||||||
.mapToInt(cf -> cf.removeCharCount).mapToObj(rcc -> new int[]{fs.Start, fs.Start + rcc - 1}))
|
.mapToInt(cf -> cf.removeCharCount).mapToObj(rcc -> new int[]{fs.Start, fs.Start + rcc - 1}))
|
||||||
.forEach(rc -> remchars.add(rc));
|
.forEach(remchars::add);
|
||||||
sections.stream()
|
sections.stream()
|
||||||
.flatMap(fs -> fs.Formatters.stream().filter(cf -> cf.removeCharCount > 0)
|
.flatMap(fs -> fs.Formatters.stream().filter(cf -> cf.removeCharCount > 0)
|
||||||
.mapToInt(cf -> cf.removeCharCount).mapToObj(rcc -> new int[]{fs.End - rcc + 1, fs.End}))
|
.mapToInt(cf -> cf.removeCharCount).mapToObj(rcc -> new int[]{fs.End - rcc + 1, fs.End}))
|
||||||
.forEach(rc -> remchars.add(rc));
|
.forEach(remchars::add);
|
||||||
DebugCommand.SendDebugMessage("Added remchars:");
|
DebugCommand.SendDebugMessage("Added remchars:");
|
||||||
DebugCommand
|
DebugCommand
|
||||||
.SendDebugMessage(remchars.stream().map(rc -> Arrays.toString(rc)).collect(Collectors.joining("; ")));
|
.SendDebugMessage(remchars.stream().map(Arrays::toString).collect(Collectors.joining("; ")));
|
||||||
|
}
|
||||||
|
|
||||||
header("Section combining");
|
private static void combineSections(String str, ArrayList<FormattedSection> sections) {
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int i = 1; cont; ) {
|
for (int i = 1; cont; ) {
|
||||||
|
@ -218,47 +207,40 @@ public final class ChatFormatter {
|
||||||
FormattedSection firstSection = sections.get(i - 1);
|
FormattedSection firstSection = sections.get(i - 1);
|
||||||
DebugCommand.SendDebugMessage("Combining sections " + firstSection);
|
DebugCommand.SendDebugMessage("Combining sections " + firstSection);
|
||||||
sendMessageWithPointer(str, firstSection.Start, firstSection.End);
|
sendMessageWithPointer(str, firstSection.Start, firstSection.End);
|
||||||
DebugCommand.SendDebugMessage(" and " + sections.get(i));
|
final FormattedSection lastSection = sections.get(i);
|
||||||
sendMessageWithPointer(str, sections.get(i).Start, sections.get(i).End);
|
DebugCommand.SendDebugMessage(" and " + lastSection);
|
||||||
if (firstSection.Start == sections.get(i).Start && firstSection.End == sections.get(i).End) {
|
sendMessageWithPointer(str, lastSection.Start, lastSection.End);
|
||||||
firstSection.Formatters.addAll(sections.get(i).Formatters);
|
if (firstSection.Start == lastSection.Start && firstSection.End == lastSection.End) {
|
||||||
firstSection.Matches.addAll(sections.get(i).Matches);
|
firstSection.Formatters.addAll(lastSection.Formatters);
|
||||||
|
firstSection.Matches.addAll(lastSection.Matches);
|
||||||
DebugCommand.SendDebugMessage("To section " + firstSection);
|
DebugCommand.SendDebugMessage("To section " + firstSection);
|
||||||
sendMessageWithPointer(str, firstSection.Start, firstSection.End);
|
sendMessageWithPointer(str, firstSection.Start, firstSection.End);
|
||||||
sections.remove(i);
|
sections.remove(i);
|
||||||
found = true;
|
found = true;
|
||||||
} else if (firstSection.End > sections.get(i).Start && firstSection.Start < sections.get(i).End) {
|
} else if (firstSection.End > lastSection.Start && firstSection.Start < lastSection.End) {
|
||||||
int origend = firstSection.End;
|
int origend2 = firstSection.End;
|
||||||
firstSection.End = sections.get(i).Start - 1;
|
firstSection.End = lastSection.Start - 1;
|
||||||
int origend2 = sections.get(i).End;
|
int origend = lastSection.End;
|
||||||
boolean switchends;
|
FormattedSection section = new FormattedSection(firstSection.Formatters, lastSection.Start, origend,
|
||||||
if (switchends = origend2 < origend) {
|
|
||||||
int tmp = origend;
|
|
||||||
origend = origend2;
|
|
||||||
origend2 = tmp;
|
|
||||||
}
|
|
||||||
FormattedSection section = new FormattedSection(firstSection.Formatters, sections.get(i).Start, origend,
|
|
||||||
firstSection.Matches, Type.Normal);
|
firstSection.Matches, Type.Normal);
|
||||||
section.Formatters.addAll(sections.get(i).Formatters);
|
section.Formatters.addAll(lastSection.Formatters);
|
||||||
section.Matches.addAll(sections.get(i).Matches); // TODO: Clean
|
section.Matches.addAll(lastSection.Matches); // TODO: Clean
|
||||||
sections.add(i, section);
|
sections.add(i, section);
|
||||||
nextindex++;
|
nextindex++;
|
||||||
FormattedSection thirdFormattedSection = sections.get(i + 1);
|
// Use the properties of the first section not the second one
|
||||||
if (switchends) { // Use the properties of the first section not the second one
|
lastSection.Formatters.clear();
|
||||||
thirdFormattedSection.Formatters.clear();
|
lastSection.Formatters.addAll(firstSection.Formatters);
|
||||||
thirdFormattedSection.Formatters.addAll(firstSection.Formatters);
|
lastSection.Matches.clear();
|
||||||
thirdFormattedSection.Matches.clear();
|
lastSection.Matches.addAll(firstSection.Matches);
|
||||||
thirdFormattedSection.Matches.addAll(firstSection.Matches);
|
|
||||||
}
|
lastSection.Start = origend + 1;
|
||||||
thirdFormattedSection.Start = origend + 1;
|
lastSection.End = origend2;
|
||||||
thirdFormattedSection.End = origend2;
|
|
||||||
|
|
||||||
ArrayList<FormattedSection> sts = sections;
|
|
||||||
Predicate<FormattedSection> removeIfNeeded = s -> {
|
Predicate<FormattedSection> removeIfNeeded = s -> {
|
||||||
if (s.Start < 0 || s.End < 0 || s.Start > s.End) {
|
if (s.Start < 0 || s.End < 0 || s.Start > s.End) {
|
||||||
DebugCommand.SendDebugMessage("Removing section: " + s);
|
DebugCommand.SendDebugMessage("Removing section: " + s);
|
||||||
sendMessageWithPointer(str, s.Start, s.End);
|
sendMessageWithPointer(str, s.Start, s.End);
|
||||||
sts.remove(s);
|
sections.remove(s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -273,9 +255,9 @@ public final class ChatFormatter {
|
||||||
DebugCommand.SendDebugMessage(" 2:" + section + "");
|
DebugCommand.SendDebugMessage(" 2:" + section + "");
|
||||||
sendMessageWithPointer(str, section.Start, section.End);
|
sendMessageWithPointer(str, section.Start, section.End);
|
||||||
}
|
}
|
||||||
if (!removeIfNeeded.test(thirdFormattedSection)) {
|
if (!removeIfNeeded.test(lastSection)) {
|
||||||
DebugCommand.SendDebugMessage(" 3:" + thirdFormattedSection);
|
DebugCommand.SendDebugMessage(" 3:" + lastSection);
|
||||||
sendMessageWithPointer(str, thirdFormattedSection.Start, thirdFormattedSection.End);
|
sendMessageWithPointer(str, lastSection.Start, lastSection.End);
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -294,20 +276,16 @@ public final class ChatFormatter {
|
||||||
if (found) {
|
if (found) {
|
||||||
i = 1;
|
i = 1;
|
||||||
found = false;
|
found = false;
|
||||||
sections.sort(
|
sortSections(sections);
|
||||||
(s1, s2) -> s1.Start == s2.Start
|
|
||||||
? s1.End == s2.End
|
|
||||||
? Integer.compare(s2.Formatters.get(0).priority.GetValue(),
|
|
||||||
s1.Formatters.get(0).priority.GetValue())
|
|
||||||
: Integer.compare(s2.End, s1.End)
|
|
||||||
: Integer.compare(s1.Start, s2.Start));
|
|
||||||
} else
|
} else
|
||||||
cont = false;
|
cont = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header("Section applying");
|
private static void applySections(String str, TellrawPart tp, ArrayList<FormattedSection> sections, ArrayList<int[]> remchars) {
|
||||||
TellrawPart lasttp = null; String lastlink = null;
|
TellrawPart lasttp = null;
|
||||||
|
String lastlink = null;
|
||||||
for (FormattedSection section : sections) {
|
for (FormattedSection section : sections) {
|
||||||
DebugCommand.SendDebugMessage("Applying section: " + section);
|
DebugCommand.SendDebugMessage("Applying section: " + section);
|
||||||
String originaltext;
|
String originaltext;
|
||||||
|
@ -343,15 +321,15 @@ public final class ChatFormatter {
|
||||||
if (formatter.color != null)
|
if (formatter.color != null)
|
||||||
newtp.setColor(formatter.color);
|
newtp.setColor(formatter.color);
|
||||||
if (formatter.bold)
|
if (formatter.bold)
|
||||||
newtp.setBold(formatter.bold);
|
newtp.setBold(true);
|
||||||
if (formatter.italic)
|
if (formatter.italic)
|
||||||
newtp.setItalic(formatter.italic);
|
newtp.setItalic(true);
|
||||||
if (formatter.underlined)
|
if (formatter.underlined)
|
||||||
newtp.setUnderlined(formatter.underlined);
|
newtp.setUnderlined(true);
|
||||||
if (formatter.strikethrough)
|
if (formatter.strikethrough)
|
||||||
newtp.setStrikethrough(formatter.strikethrough);
|
newtp.setStrikethrough(true);
|
||||||
if (formatter.obfuscated)
|
if (formatter.obfuscated)
|
||||||
newtp.setObfuscated(formatter.obfuscated);
|
newtp.setObfuscated(true);
|
||||||
if (formatter.openlink != null)
|
if (formatter.openlink != null)
|
||||||
openlink = formatter.openlink;
|
openlink = formatter.openlink;
|
||||||
if (formatter.hoverText != null)
|
if (formatter.hoverText != null)
|
||||||
|
@ -368,6 +346,7 @@ public final class ChatFormatter {
|
||||||
lasttp.setText(lasttp.getText() + originaltext);
|
lasttp.setText(lasttp.getText() + originaltext);
|
||||||
continue; //Combine parts with the same properties
|
continue; //Combine parts with the same properties
|
||||||
}
|
}
|
||||||
|
lastlink = openlink;
|
||||||
newtp.setText(originaltext);
|
newtp.setText(originaltext);
|
||||||
if (openlink != null && openlink.length() > 0) {
|
if (openlink != null && openlink.length() > 0) {
|
||||||
newtp.setClickEvent(TellrawEvent.create(TellrawEvent.ClickAction.OPEN_URL,
|
newtp.setClickEvent(TellrawEvent.create(TellrawEvent.ClickAction.OPEN_URL,
|
||||||
|
@ -378,7 +357,14 @@ public final class ChatFormatter {
|
||||||
tp.addExtra(newtp);
|
tp.addExtra(newtp);
|
||||||
lasttp = newtp;
|
lasttp = newtp;
|
||||||
}
|
}
|
||||||
header("ChatFormatter.Combine done");
|
}
|
||||||
|
|
||||||
|
private static void sortSections(ArrayList<FormattedSection> sections) {
|
||||||
|
sections.sort(
|
||||||
|
(s1, s2) -> s1.Start == s2.Start
|
||||||
|
? s1.End == s2.End ? Integer.compare(s2.Formatters.get(0).priority.GetValue(),
|
||||||
|
s1.Formatters.get(0).priority.GetValue()) : Integer.compare(s2.End, s1.End)
|
||||||
|
: Integer.compare(s1.Start, s2.Start));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendMessageWithPointer(String str, int... pointer) {
|
private static void sendMessageWithPointer(String str, int... pointer) {
|
||||||
|
|
Loading…
Reference in a new issue