Fixed chat formatting - Mostly ¯\_(ツ)_/¯ #59

Merged
NorbiPeti merged 9 commits from chatformat into dev 2016-12-30 21:05:01 +00:00
2 changed files with 17 additions and 11 deletions
Showing only changes of commit 3ab97276f6 - Show all commits

View file

@ -2,7 +2,6 @@ package buttondevteam.chat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
@ -21,11 +20,7 @@ import com.palmergames.bukkit.towny.object.Town;
import buttondevteam.chat.commands.UnlolCommand;
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.chat.formatting.ChatFormatter;
import buttondevteam.chat.formatting.ChatFormatterBuilder;
import buttondevteam.chat.formatting.TellrawEvent;
import buttondevteam.chat.formatting.TellrawPart;
import buttondevteam.chat.formatting.TellrawSerializer;
import buttondevteam.chat.formatting.*;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.TBMCPlayer;
import buttondevteam.lib.chat.Channel;
@ -57,15 +52,15 @@ public class ChatProcessing {
static {
commonFormatters.add(new ChatFormatterBuilder().setRegex(BOLD_PATTERN).setFormat(Format.Bold)
.setRemoveCharCount((short) 2).build());
.setRemoveCharCount((short) 2).setRange(true).build());
commonFormatters.add(new ChatFormatterBuilder().setRegex(ITALIC_PATTERN).setFormat(Format.Italic)
.setRemoveCharCount((short) 1).build());
.setRemoveCharCount((short) 1).setRange(true).build());
commonFormatters.add(new ChatFormatterBuilder().setRegex(UNDERLINED_PATTERN).setFormat(Format.Underlined)
.setRemoveCharCount((short) 1).build());
.setRemoveCharCount((short) 1).setRange(true).build());
commonFormatters.add(ESCAPE_FORMATTER);
// URLs + Rainbow text
commonFormatters.add(new ChatFormatterBuilder().setRegex(URL_PATTERN).setFormat(Format.Underlined)
.setOpenlink("$1").build());
.setOpenlink("$1").setRange(true).build());
commonFormatters.add(new ChatFormatterBuilder().setRegex(NULL_MENTION_PATTERN).setColor(Color.DarkRed).build()); // Properly added a bug as a feature
commonFormatters.add(new ChatFormatterBuilder().setRegex(CONSOLE_PING_PATTERN).setColor(Color.Aqua)
.setOnmatch((String match) -> {

View file

@ -14,9 +14,11 @@ public class ChatFormatterBuilder {
private Priority priority;
private short removecharcount = 0;
private short removecharpos = -1;
private boolean range = false;
public ChatFormatter build() {
return new ChatFormatter(regex, format, color, onmatch, openlink, priority, removecharcount, removecharpos);
return new ChatFormatter(regex, format, color, onmatch, openlink, priority, removecharcount, removecharpos,
range);
}
public Pattern getRegex() {
@ -100,4 +102,13 @@ public class ChatFormatterBuilder {
this.removecharpos = removecharpos;
return this;
}
public boolean isRange() {
return range;
}
public ChatFormatterBuilder setRange(boolean range) {
this.range = range;
return this;
}
}