Interface PlainFormat<T>
- Type Parameters:
T- the result type produced by this format when applied to input text
- All Superinterfaces:
Format<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Format for formats that do not rely on regular-expression matching.
PlainFormat is intended for cases where your formatting logic cannot be captured
(or need not be captured) by a single regex. By default, the regex-based methods are stubbed
out—implementors should override them only if they actually require regex support.
Format.accept(Player, String) methods directly.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PlainFormat<String> APlainFormatimplementation that integrates with InteractiveChat.static final PlainFormat<String> APlainFormatimplementation that integrates with PlaceholderAPI.static final PlainFormat<String> -
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull StringgetRegex()Returns the regular expression used for matching format tokens in the input.default booleanisFormatted(String string) Checks whether this format applies to the given input.default @NotNull MatcherCreates aMatcherfor the given input text.default StringremoveFormat(String string) Removes the formatting syntax from the input text.Methods inherited from interface me.croabeast.takion.format.Format
accept, accept, toFormattedString
-
Field Details
-
PLACEHOLDER_API
APlainFormatimplementation that integrates with PlaceholderAPI.If the input
stringis non‑blank and the PlaceholderAPI plugin is present (enabled), it will replace any PlaceholderAPI placeholders in the text for the providedPlayer; otherwise, it returns the original text. -
INTERACTIVE_CHAT
APlainFormatimplementation that integrates with InteractiveChat.If the input
stringis non‑blank and the InteractiveChat plugin is present (enabled), it will mark the text so that clicking it in chat triggers an interactive chat action for the providedPlayer; otherwise, it returns the original text. -
TRIM_START_SPACES
-
-
Method Details
-
getRegex
Returns the regular expression used for matching format tokens in the input.Since
PlainFormatimplementations typically do not use regex matching, the default implementation returns an empty string. Override only if your plain format needs to expose a regex for some reason. -
matcher
Creates aMatcherfor the given input text.The default implementation always throws
Otherwise, perform any necessary matching directly in yourUnsupportedOperationExceptionbecause plain formats do not support regex-based matching out of the box. If you need regex matching, override this method with your ownPatterncompilation and matching logic.accept(...)implementation.- Specified by:
matcherin interfaceFormat<T>- Parameters:
string- the input text to be matched- Returns:
- a
Matcherfor the provided input - Throws:
UnsupportedOperationException- always, unless overridden by the implementor
-
isFormatted
Checks whether this format applies to the given input.The default implementation always returns
false. If your plain format can detect its pattern without regex (for example, via prefix checks or other heuristics), override this method to provide that logic.- Specified by:
isFormattedin interfaceFormat<T>- Parameters:
string- the input text to test- Returns:
trueif this format should process the input;falseotherwise
-
removeFormat
Removes the formatting syntax from the input text.The default implementation returns the input unchanged. If your plain format supports stripping its own custom markers or tokens, override this method to implement the removal logic.
- Specified by:
removeFormatin interfaceFormat<T>- Parameters:
string- the input text from which to remove formatting- Returns:
- the text with formatting removed
-