parsedContent = new ArrayList<>();
+ contentParsers.forEach(parser -> parser.parse(sender, parsedContent));
+ sendHandler.send(sender, parsedContent);
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/display/ContentFilter.java b/src/main/java/com/onarandombox/MultiverseCore/display/ContentFilter.java
deleted file mode 100644
index cd0bed8cc..000000000
--- a/src/main/java/com/onarandombox/MultiverseCore/display/ContentFilter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.onarandombox.MultiverseCore.display;
-
-import com.dumptruckman.minecraft.util.Logging;
-import org.bukkit.ChatColor;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * Filter content and text based on regex matching.
- *
- * Compile regex pattern based on {@link ContentFilter#filterString}. When prefixed with 'r=',
- * use {@link ContentFilter#filterString} as the full regex pattern. Else, set to any match that
- * contains the {@link ContentFilter#filterString}.
- */
-public class ContentFilter {
-
- public static final ContentFilter DEFAULT = new ContentFilter();
- private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
-
- private String filterString;
- private Pattern filterPattern;
- private boolean exactMatch;
-
- private ContentFilter() {
- }
-
- /**
- * @param filterString The text to do matching, either plaintext or regex.
- */
- public ContentFilter(@NotNull String filterString) {
- this(filterString, false);
- }
-
- /**
- * @param filterString The text to do matching, else plaintext or regex.
- * @param exactMatch Should check for exact match when doing regex matching.
- */
- public ContentFilter(@NotNull String filterString,
- boolean exactMatch) {
-
- this.filterString = filterString;
- this.exactMatch = exactMatch;
- parseFilter();
- }
-
- private void parseFilter() {
- if (filterString == null) {
- return;
- }
- if (filterString.startsWith("r=")) {
- convertToMatcher(filterString.substring(2));
- return;
- }
- String cleanedFilter = REGEX_SPECIAL_CHARS.matcher(filterString.toLowerCase()).replaceAll("\\\\$0");
- convertToMatcher("(?i).*" + cleanedFilter + ".*");
- }
-
- /**
- * Compile and store the regex into a {@link Pattern}.
- *
- * @param regex The regex text.
- */
- private void convertToMatcher(@NotNull String regex) {
- try {
- this.filterPattern = Pattern.compile(regex);
- Logging.finest("Parsed regex pattern: %s", this.filterPattern.toString());
- }
- catch (PatternSyntaxException ignored) {
- Logging.warning("Error parsing regex: %s", filterString);
- }
- }
-
- /**
- * Do regex matching.
- *
- * @param text String to check regex on.
- * @return True of matches regex pattern, false otherwise.
- */
- public boolean checkMatch(@Nullable Object text) {
- if (!hasFilter()) {
- return true;
- }
- if (text == null || !hasValidPattern()) {
- return false;
- }
- text = ChatColor.stripColor(String.valueOf(text));
- return (exactMatch)
- ? filterPattern.matcher((CharSequence) text).matches()
- : filterPattern.matcher((CharSequence) text).find();
- }
-
- /**
- * Checks if a filter string is present.
- *
- * @return True if there is a filter string, else false.
- */
- public boolean hasFilter() {
- return filterString != null;
- }
-
- /**
- * Checks if regex pattern syntax is valid.
- *
- * @return True if valid, else false.
- */
- public boolean hasValidPattern() {
- return filterPattern != null;
- }
-
- /**
- * @return The filter string.
- */
- @Nullable
- public String getString() {
- return filterString;
- }
-
- /**
- * @return The regex pattern.
- */
- @Nullable
- public Pattern getPattern() {
- return filterPattern;
- }
-
- /**
- * @return True if filter is set to do exact matching, else false.
- */
- public boolean isExactMatch() {
- return exactMatch;
- }
-
- /**
- * Nicely format the filter string to be used for showing the sender.
- *
- * @return The formatted filter string.
- */
- public @NotNull String getFormattedString() {
- return String.format("%sFilter: '%s'", ChatColor.ITALIC, filterString);
- }
-
- @Override
- public String toString() {
- return "ContentFilter{" +
- "filterString='" + filterString + '\'' +
- ", filterPattern=" + filterPattern +
- ", exactMatch=" + exactMatch +
- '}';
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayFormatException.java b/src/main/java/com/onarandombox/MultiverseCore/display/DisplayFormatException.java
deleted file mode 100644
index 604d6acdc..000000000
--- a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayFormatException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.onarandombox.MultiverseCore.display;
-
-/**
- * Thrown when an issue occur while formatting content.
- */
-public class DisplayFormatException extends Exception {
- public DisplayFormatException() {
- }
-
- public DisplayFormatException(String message) {
- super(message);
- }
-
- public DisplayFormatException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DisplayFormatException(Throwable cause) {
- super(cause);
- }
-
- public DisplayFormatException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandler.java b/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandler.java
deleted file mode 100644
index 7971a11f5..000000000
--- a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.onarandombox.MultiverseCore.display;
-
-import com.google.common.base.Strings;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collection;
-
-/**
- * Handles the formatting and sending of all content by the {@link ContentDisplay}.
- *
- * @param Type of content to display.
- */
-@FunctionalInterface
-public interface DisplayHandler {
-
- /**
- * Formats the raw content into a {@link Collection} for displaying to the given sender.
- *
- * @param sender The {@link CommandSender} who will the content will be displayed to.
- * @param display The responsible {@link ContentDisplay}.
- * @return The formatted content.
- * @throws DisplayFormatException Issue occurred while formatting content. E.g. invalid page.
- */
- Collection format(@NotNull CommandSender sender, @NotNull ContentDisplay display)
- throws DisplayFormatException;
-
- /**
- * Sends the header.
- *
- * @param sender The {@link CommandSender} who will the header will be displayed to.
- * @param display The responsible {@link ContentDisplay}.
- */
- default void sendHeader(@NotNull CommandSender sender, @NotNull ContentDisplay display) {
- if (!Strings.isNullOrEmpty(display.getHeader())) {
- sender.sendMessage(display.getHeader());
- }
- }
-
- /**
- * Sends info such as filter and page.
- *
- * @param sender The {@link CommandSender} who will the sub header will be displayed to.
- * @param display The responsible {@link ContentDisplay}.
- */
- default void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay display) {
- if (display.getFilter().hasFilter()) {
- sender.sendMessage(String.format("%s[ %s ]", ChatColor.GRAY, display.getFilter().getFormattedString()));
- }
- }
-
- /**
- * Sends the content.
- *
- * @param sender The {@link CommandSender} who will the body will be displayed to.
- * @param display The responsible {@link ContentDisplay}.
- * @param formattedContent The content after being formatted by {@link #format(CommandSender, ContentDisplay)}
- */
- default void sendBody(@NotNull CommandSender sender, @NotNull ContentDisplay display,
- Collection formattedContent) {
- if (formattedContent == null || formattedContent.size() == 0) {
- sender.sendMessage(display.getEmptyMessage());
- return;
- }
- sender.sendMessage(formattedContent.toArray(new String[0]));
- }
-}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandlers.java b/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandlers.java
deleted file mode 100644
index 7343c6ad5..000000000
--- a/src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandlers.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.onarandombox.MultiverseCore.display;
-
-import com.onarandombox.MultiverseCore.display.handlers.InlineListDisplayHandler;
-import com.onarandombox.MultiverseCore.display.handlers.InlineMapDisplayHandler;
-import com.onarandombox.MultiverseCore.display.handlers.ListDisplayHandler;
-import com.onarandombox.MultiverseCore.display.handlers.PagedListDisplayHandler;
-import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
-import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
-import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Various implementations of {@link DisplayHandler}.
- */
-public class DisplayHandlers {
-
- /**
- * Standard list display.
- *
- * Supported settings: none.
- */
- public static final DisplayHandler> LIST = new ListDisplayHandler();
-
- /**
- * List display with paging.
- *
- * Supported settings: {@link PagedDisplaySettings#SHOW_PAGE}, {@link PagedDisplaySettings#LINES_PER_PAGE},
- * {@link PagedDisplaySettings#PAGE_IN_CONSOLE}, {@link PagedDisplaySettings#DO_END_PADDING}.
- */
- public static final DisplayHandler> PAGE_LIST = new PagedListDisplayHandler();
-
- /**
- * Display a list inline.
- *
- * Supported settings: {@link InlineDisplaySettings#SEPARATOR}.
- */
- public static final DisplayHandler> INLINE_LIST = new InlineListDisplayHandler();
-
- /**
- * Display key value pair inline.
- *
- * Supported settings: {@link InlineDisplaySettings#SEPARATOR}, {@link MapDisplaySettings#OPERATOR}.
- */
- public static final DisplayHandler