diff options
author | Dico <dico.karssiens@gmail.com> | 2018-09-28 05:47:32 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-09-28 05:47:32 +0100 |
commit | bb6ae7d37037180f4cb29a084b1e2ab1a86c747a (patch) | |
tree | acabff0f5710c60a54ece8a7d0a38f34ee074e6d /dicore3 | |
parent | 09aaa9ff725787be4f56986d58e61ee41e3140cb (diff) |
Add /p global list, tweaks/fixes
Diffstat (limited to 'dicore3')
18 files changed, 153 insertions, 141 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/Command.java b/dicore3/command/src/main/java/io/dico/dicore/command/Command.java index e423529..53e5821 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/Command.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/Command.java @@ -139,7 +139,7 @@ public abstract class Command { try { executeWithContext(executionContext); } catch (Throwable t) { - caller.getChatController().handleException(sender, executionContext, t); + caller.getChatHandler().handleException(sender, executionContext, t); } } @@ -159,7 +159,7 @@ public abstract class Command { //System.out.println("Post-contextfilters"); String message = execute(context.getSender(), context); - context.getAddress().getChatController().sendMessage(context.getSender(), EMessageType.RESULT, message); + context.sendMessage(EMessageType.RESULT, message); } public abstract String execute(CommandSender sender, ExecutionContext context) throws CommandException; diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java b/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java index 76211c2..63628d3 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/CommandBuilder.java @@ -1,6 +1,6 @@ package io.dico.dicore.command; -import io.dico.dicore.command.chat.IChatController; +import io.dico.dicore.command.chat.IChatHandler; import io.dico.dicore.command.parameter.type.IParameterTypeSelector; import io.dico.dicore.command.parameter.type.MapBasedParameterTypeSelector; import io.dico.dicore.command.parameter.type.ParameterType; @@ -340,16 +340,16 @@ public final class CommandBuilder { } /** - * Configure the chat controller at this address. The chat controller + * Configure the chat handler at this address. The chat handler * is used for all children down the tree if they don't explicitly have - * their own chat controller configured. If this isn't configured, - * {@code ChatControllers.defaultChat()} is used. + * their own chat handler configured. If this isn't configured, + * {@code ChatHandlers.defaultChat()} is used. * - * @param chatController the chat controller + * @param chatHandler the chat handler * @return this */ - public CommandBuilder setChatController(IChatController chatController) { - cur.setChatController(chatController); + public CommandBuilder setChatHandler(IChatHandler chatHandler) { + cur.setChatHandler(chatHandler); return this; } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/ExecutionContext.java b/dicore3/command/src/main/java/io/dico/dicore/command/ExecutionContext.java index c473166..2a074e1 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/ExecutionContext.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/ExecutionContext.java @@ -229,7 +229,7 @@ public class ExecutionContext { } public Formatting getFormat(EMessageType type) { - return address.getChatController().getChatFormatForType(type); + return address.getChatHandler().getChatFormatForType(type); } /** @@ -345,7 +345,7 @@ public class ExecutionContext { if (translateColours) { message = Formatting.translateChars('&', message); } - address.getChatController().sendMessage(this, messageType, message); + address.getChatHandler().sendMessage(this, messageType, message); } } @@ -367,13 +367,13 @@ public class ExecutionContext { public void sendHelpMessage(int page) { if (!muted) { - address.getChatController().sendHelpMessage(sender, this, address, page); + address.getChatHandler().sendHelpMessage(sender, this, address, page); } } public void sendSyntaxMessage() { if (!muted) { - address.getChatController().sendSyntaxMessage(sender, this, address); + address.getChatHandler().sendSyntaxMessage(sender, this, address); } } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/ICommandAddress.java b/dicore3/command/src/main/java/io/dico/dicore/command/ICommandAddress.java index fb0d7b4..bef20e4 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/ICommandAddress.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/ICommandAddress.java @@ -1,6 +1,6 @@ package io.dico.dicore.command; -import io.dico.dicore.command.chat.IChatController; +import io.dico.dicore.command.chat.IChatHandler; import io.dico.dicore.command.parameter.ArgumentBuffer; import io.dico.dicore.command.predef.PredefinedCommand; import org.bukkit.command.CommandSender; @@ -161,9 +161,9 @@ public interface ICommandAddress { ICommandDispatcher getDispatcherForTree(); /** - * @return The desired chatcontroller for use by commands at this address and any sub-addresses, if they define no explicit chat controller. + * @return The desired chathandler for use by commands at this address and any sub-addresses, if they define no explicit chat handler. */ - IChatController getChatController(); + IChatHandler getChatHandler(); static ICommandAddress newChild() { return new ChildCommandAddress(); diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/ModifiableCommandAddress.java b/dicore3/command/src/main/java/io/dico/dicore/command/ModifiableCommandAddress.java index 6871462..0c4c476 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/ModifiableCommandAddress.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/ModifiableCommandAddress.java @@ -1,7 +1,7 @@ package io.dico.dicore.command; -import io.dico.dicore.command.chat.ChatControllers; -import io.dico.dicore.command.chat.IChatController; +import io.dico.dicore.command.chat.ChatHandlers; +import io.dico.dicore.command.chat.IChatHandler; import io.dico.dicore.command.predef.DefaultGroupCommand; import io.dico.dicore.command.predef.HelpCommand; import io.dico.dicore.command.predef.PredefinedCommand; @@ -12,10 +12,10 @@ public abstract class ModifiableCommandAddress implements ICommandAddress { Map<String, ChildCommandAddress> children; Collection<String> childrenMainKeys = Collections.emptyList(); - // the chat controller as configured by the programmer - IChatController chatController; - // cache for the algorithm that finds the first chat controller going up the tree - transient IChatController chatControllerCache; + // the chat handler as configured by the programmer + IChatHandler chatHandler; + // cache for the algorithm that finds the first chat handler going up the tree + transient IChatHandler cachedChatHandlerFallback; ModifiableCommandAddress helpChild; @@ -230,30 +230,30 @@ public abstract class ModifiableCommandAddress implements ICommandAddress { } @Override - public IChatController getChatController() { - if (chatControllerCache == null) { - if (chatController != null) { - chatControllerCache = chatController; + public IChatHandler getChatHandler() { + if (cachedChatHandlerFallback == null) { + if (chatHandler != null) { + cachedChatHandlerFallback = chatHandler; } else if (!hasParent()) { - chatControllerCache = ChatControllers.defaultChat(); + cachedChatHandlerFallback = ChatHandlers.defaultChat(); } else { - chatControllerCache = getParent().getChatController(); + cachedChatHandlerFallback = getParent().getChatHandler(); } } - return chatControllerCache; + return cachedChatHandlerFallback; } - public void setChatController(IChatController chatController) { - this.chatController = chatController; - resetChatControllerCache(new HashSet<>()); + public void setChatHandler(IChatHandler chatHandler) { + this.chatHandler = chatHandler; + resetChatHandlerCache(new HashSet<>()); } - void resetChatControllerCache(Set<ModifiableCommandAddress> dejaVu) { + void resetChatHandlerCache(Set<ModifiableCommandAddress> dejaVu) { if (dejaVu.add(this)) { - chatControllerCache = chatController; + cachedChatHandlerFallback = chatHandler; for (ChildCommandAddress address : children.values()) { - if (address.chatController == null) { - address.resetChatControllerCache(dejaVu); + if (address.chatHandler == null) { + address.resetChatHandlerCache(dejaVu); } } } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/RootCommandAddress.java b/dicore3/command/src/main/java/io/dico/dicore/command/RootCommandAddress.java index aa84b67..10dade5 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/RootCommandAddress.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/RootCommandAddress.java @@ -1,7 +1,6 @@ package io.dico.dicore.command; import io.dico.dicore.command.parameter.ArgumentBuffer; -import io.dico.dicore.command.predef.DefaultGroupCommand; import io.dico.dicore.command.registration.BukkitCommand; import org.bukkit.Location; import org.bukkit.command.CommandSender; @@ -197,7 +196,7 @@ public class RootCommandAddress extends ModifiableCommandAddress implements ICom if (targetAddress == null) { targetAddress = this; } - targetAddress.getChatController().handleException(sender, context, t); + targetAddress.getChatHandler().handleException(sender, context, t); } return true; diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/AbstractChatController.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/AbstractChatHandler.java index 000c094..c0d23ee 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/chat/AbstractChatController.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/AbstractChatHandler.java @@ -1,7 +1,6 @@ package io.dico.dicore.command.chat; import io.dico.dicore.Formatting; -import io.dico.dicore.command.CommandException; import io.dico.dicore.command.EMessageType; import io.dico.dicore.command.ExecutionContext; import io.dico.dicore.command.ICommandAddress; @@ -9,14 +8,14 @@ import io.dico.dicore.command.chat.help.HelpPages; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; -public class AbstractChatController implements IChatController { +public class AbstractChatHandler implements IChatHandler { private @NotNull HelpPages helpPages; - public AbstractChatController(@NotNull HelpPages helpPages) { + public AbstractChatHandler(@NotNull HelpPages helpPages) { this.helpPages = helpPages; } - public AbstractChatController() { + public AbstractChatHandler() { this(HelpPages.newDefaultHelpPages()); } @@ -30,43 +29,6 @@ public class AbstractChatController implements IChatController { } @Override - public void sendMessage(ExecutionContext context, EMessageType type, String message) { - sendMessage(context.getSender(), type, message); - } - - @Override - public void sendMessage(CommandSender sender, EMessageType type, String message) { - if (message != null && !message.isEmpty()) { - sender.sendMessage(filterMessage(getMessagePrefixForType(type) + getChatFormatForType(type) + message)); - } - } - - @Override - public void handleCommandException(CommandSender sender, ExecutionContext context, CommandException exception) { - sendMessage(sender, EMessageType.EXCEPTION, exception.getMessage()); - } - - @Override - public void handleException(CommandSender sender, ExecutionContext context, Throwable exception) { - if (exception instanceof CommandException) { - handleCommandException(sender, context, (CommandException) exception); - } else { - sendMessage(sender, EMessageType.EXCEPTION, "An internal error occurred whilst executing this command"); - exception.printStackTrace(); - } - } - - @Override - public void sendHelpMessage(CommandSender sender, ExecutionContext context, ICommandAddress address, int page) { - sender.sendMessage(helpPages.getHelpPage(sender, context, address, page)); - } - - @Override - public void sendSyntaxMessage(CommandSender sender, ExecutionContext context, ICommandAddress address) { - sender.sendMessage(helpPages.getSyntax(sender, context, address)); - } - - @Override public Formatting getChatFormatForType(EMessageType type) { switch (type) { case EXCEPTION: @@ -104,9 +66,29 @@ public class AbstractChatController implements IChatController { return ""; } + protected String createMessage(EMessageType type, String message) { + if (message == null || message.isEmpty()) return null; + return getMessagePrefixForType(type) + getChatFormatForType(type) + message; + } + + @Override + public String createMessage(ExecutionContext context, EMessageType type, String message) { + return createMessage(type, message); + } + + @Override + public String createMessage(CommandSender sender, EMessageType type, String message) { + return createMessage(type, message); + } + + @Override + public String createHelpMessage(CommandSender sender, ExecutionContext context, ICommandAddress address, int page) { + return helpPages.getHelpPage(sender, context, address, page); + } + @Override - public String filterMessage(String message) { - return message; + public String createSyntaxMessage(CommandSender sender, ExecutionContext context, ICommandAddress address) { + return helpPages.getSyntax(sender, context, address); } } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatControllers.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatControllers.java deleted file mode 100644 index 723edda..0000000 --- a/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatControllers.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.dico.dicore.command.chat; - -/** - * Static factory methods for {@link IChatController} - */ -public class ChatControllers { - private static final IChatController defaultChat; - - private ChatControllers() { - - } - - public static IChatController defaultChat() { - return defaultChat; - } - - static { - defaultChat = new AbstractChatController(); - } -} diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatHandlers.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatHandlers.java new file mode 100644 index 0000000..232d5cf --- /dev/null +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/ChatHandlers.java @@ -0,0 +1,20 @@ +package io.dico.dicore.command.chat; + +/** + * Static factory methods for {@link IChatHandler} + */ +public class ChatHandlers { + private static final IChatHandler defaultChat; + + private ChatHandlers() { + + } + + public static IChatHandler defaultChat() { + return defaultChat; + } + + static { + defaultChat = new AbstractChatHandler(); + } +} diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatController.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatController.java deleted file mode 100644 index a514499..0000000 --- a/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatController.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.dico.dicore.command.chat; - -import io.dico.dicore.Formatting; -import io.dico.dicore.command.CommandException; -import io.dico.dicore.command.EMessageType; -import io.dico.dicore.command.ExecutionContext; -import io.dico.dicore.command.ICommandAddress; -import org.bukkit.command.CommandSender; - -//TODO add methods to send JSON messages -public interface IChatController { - - void sendMessage(ExecutionContext context, EMessageType type, String message); - - void sendMessage(CommandSender sender, EMessageType type, String message); - - void handleCommandException(CommandSender sender, ExecutionContext context, CommandException exception); - - void handleException(CommandSender sender, ExecutionContext context, Throwable exception); - - void sendHelpMessage(CommandSender sender, ExecutionContext context, ICommandAddress address, int page); - - void sendSyntaxMessage(CommandSender sender, ExecutionContext context, ICommandAddress address); - - Formatting getChatFormatForType(EMessageType type); - - String getMessagePrefixForType(EMessageType type); - - String filterMessage(String message); - -} diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatHandler.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatHandler.java new file mode 100644 index 0000000..98283ef --- /dev/null +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/IChatHandler.java @@ -0,0 +1,60 @@ +package io.dico.dicore.command.chat; + +import io.dico.dicore.Formatting; +import io.dico.dicore.command.CommandException; +import io.dico.dicore.command.EMessageType; +import io.dico.dicore.command.ExecutionContext; +import io.dico.dicore.command.ICommandAddress; +import org.bukkit.command.CommandSender; + +//TODO add methods to send JSON messages +public interface IChatHandler { + + default void sendMessage(ExecutionContext context, EMessageType type, String message) { + message = createMessage(context, type, message); + if (message != null) { + context.getSender().sendMessage(message); + } + } + + default void sendMessage(CommandSender sender, EMessageType type, String message) { + message = createMessage(sender, type, message); + if (message != null) { + sender.sendMessage(message); + } + } + + default void handleCommandException(CommandSender sender, ExecutionContext context, CommandException exception) { + sendMessage(context, EMessageType.EXCEPTION, exception.getMessage()); + } + + default void handleException(CommandSender sender, ExecutionContext context, Throwable exception) { + if (exception instanceof CommandException) { + handleCommandException(sender, context, (CommandException) exception); + } else { + sendMessage(sender, EMessageType.EXCEPTION, "An internal error occurred whilst executing this command"); + exception.printStackTrace(); + } + } + + default void sendHelpMessage(CommandSender sender, ExecutionContext context, ICommandAddress address, int page) { + sender.sendMessage(createHelpMessage(sender, context, address, page)); + } + + default void sendSyntaxMessage(CommandSender sender, ExecutionContext context, ICommandAddress address) { + sender.sendMessage(createSyntaxMessage(sender, context, address)); + } + + Formatting getChatFormatForType(EMessageType type); + + String getMessagePrefixForType(EMessageType type); + + String createMessage(ExecutionContext context, EMessageType type, String message); + + String createMessage(CommandSender sender, EMessageType type, String message); + + String createHelpMessage(CommandSender sender, ExecutionContext context, ICommandAddress address, int page); + + String createSyntaxMessage(CommandSender sender, ExecutionContext context, ICommandAddress address); + +} diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java index 886b7b1..8d3d004 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java @@ -5,7 +5,7 @@ import io.dico.dicore.command.ExecutionContext; import io.dico.dicore.command.ICommandAddress; import io.dico.dicore.command.ModifiableCommandAddress; import io.dico.dicore.Formatting; -import io.dico.dicore.command.chat.IChatController; +import io.dico.dicore.command.chat.IChatHandler; import io.dico.dicore.command.chat.help.IPageBorder; import io.dico.dicore.command.chat.help.IPageLayout; import io.dico.dicore.command.chat.help.PageBorders; @@ -15,7 +15,7 @@ public class DefaultPageLayout implements IPageLayout { @Override public PageBorders getPageBorders(ICommandAddress target, Permissible viewer, ExecutionContext context, int pageNum) { - IChatController c = context.getAddress().getChatController(); + IChatHandler c = context.getAddress().getChatHandler(); String prefix = c.getMessagePrefixForType(EMessageType.INFORMATIVE); Formatting informative = c.getChatFormatForType(EMessageType.INFORMATIVE); Formatting number = c.getChatFormatForType(EMessageType.NEUTRAL); diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/SubcommandsHelpTopic.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/SubcommandsHelpTopic.java index cfa3bb1..0e680ae 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/SubcommandsHelpTopic.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/SubcommandsHelpTopic.java @@ -7,7 +7,6 @@ import io.dico.dicore.Formatting; import io.dico.dicore.command.chat.help.IHelpComponent; import io.dico.dicore.command.chat.help.IHelpTopic; import io.dico.dicore.command.chat.help.SimpleHelpComponent; -import io.dico.dicore.command.predef.PredefinedCommand; import org.bukkit.command.CommandSender; import org.bukkit.permissions.Permissible; @@ -54,7 +53,7 @@ public class SubcommandsHelpTopic implements IHelpTopic { } private static Formatting colorOf(ExecutionContext context, EMessageType type) { - return context.getAddress().getChatController().getChatFormatForType(type); + return context.getAddress().getChatHandler().getChatFormatForType(type); } } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/predef/DefaultGroupCommand.java b/dicore3/command/src/main/java/io/dico/dicore/command/predef/DefaultGroupCommand.java index 12483cc..3988da2 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/predef/DefaultGroupCommand.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/predef/DefaultGroupCommand.java @@ -30,7 +30,7 @@ public class DefaultGroupCommand extends PredefinedCommand<DefaultGroupCommand> @Override public String execute(CommandSender sender, ExecutionContext context) throws CommandException { - context.getAddress().getChatController().sendHelpMessage(sender, context, context.getAddress(), 1); + context.getAddress().getChatHandler().sendHelpMessage(sender, context, context.getAddress(), 1); return null; } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/predef/HelpCommand.java b/dicore3/command/src/main/java/io/dico/dicore/command/predef/HelpCommand.java index cadf4ae..def0db1 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/predef/HelpCommand.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/predef/HelpCommand.java @@ -33,7 +33,7 @@ public class HelpCommand extends PredefinedCommand<HelpCommand> { target = target.getParent(); } - context.getAddress().getChatController().sendHelpMessage(sender, context, target, context.<Integer>get("page") - 1); + context.getAddress().getChatHandler().sendHelpMessage(sender, context, target, context.<Integer>get("page") - 1); return null; } diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/predef/SyntaxCommand.java b/dicore3/command/src/main/java/io/dico/dicore/command/predef/SyntaxCommand.java index 4f26a7b..7ae8638 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/predef/SyntaxCommand.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/predef/SyntaxCommand.java @@ -21,7 +21,7 @@ public class SyntaxCommand extends PredefinedCommand<SyntaxCommand> { @Override public String execute(CommandSender sender, ExecutionContext context) throws CommandException { - context.getAddress().getChatController().sendSyntaxMessage(sender, context, context.getAddress().getParent()); + context.getAddress().getChatHandler().sendSyntaxMessage(sender, context, context.getAddress().getParent()); return null; } diff --git a/dicore3/command/src/main/kotlin/io/dico/dicore/command/registration/reflect/KotlinReflectiveRegistration.kt b/dicore3/command/src/main/kotlin/io/dico/dicore/command/registration/reflect/KotlinReflectiveRegistration.kt index 6fac845..c4aa134 100644 --- a/dicore3/command/src/main/kotlin/io/dico/dicore/command/registration/reflect/KotlinReflectiveRegistration.kt +++ b/dicore3/command/src/main/kotlin/io/dico/dicore/command/registration/reflect/KotlinReflectiveRegistration.kt @@ -41,7 +41,7 @@ fun callAsCoroutine( } job.invokeOnCompletion { - val cc = context.address.chatController + val cc = context.address.chatHandler try { val result = job.getResult() cc.sendMessage(context.sender, EMessageType.RESULT, result) diff --git a/dicore3/core/src/main/java/io/dico/dicore/Formatting.java b/dicore3/core/src/main/java/io/dico/dicore/Formatting.java index eac6ac5..9fdfe0e 100644 --- a/dicore3/core/src/main/java/io/dico/dicore/Formatting.java +++ b/dicore3/core/src/main/java/io/dico/dicore/Formatting.java @@ -9,11 +9,14 @@ package io.dico.dicore; +import org.jetbrains.annotations.NotNull; + public final class Formatting implements CharSequence { public static final char FORMAT_CHAR = '\u00a7'; private static final String CACHED_CHARS = "0123456789abcdefklmnor"; private static final Formatting[] singleCharInstances = new Formatting[CACHED_CHARS.length()]; - + + @NotNull public static final Formatting BLACK = from('0'), DARK_BLUE = from('1'), |