-
-
Notifications
You must be signed in to change notification settings - Fork 416
Adventure Text Component (Chat) Integration #8322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/feature
Are you sure you want to change the base?
Conversation
Significantly improves compatibility with string-based syntax. Note that usage of the 'colored' expression is required to process formatting.
Cursed, but it works
We actually only need to disable styling, not perform a full reset.
sovdeeth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good at 75/108
src/main/java/org/skriptlang/skript/bukkit/misc/expressions/ExprMOTD.java
Outdated
Show resolved
Hide resolved
Likely better for compatibility
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
sovdeeth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not fully review but most new syntax classes need origins
| } | ||
|
|
||
| private void reloading(RedirectingLogHandler logHandler) { | ||
| // TODO update usages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this pr or later?
| .supplier(ExprSignText::new) | ||
| .priority(PropertyExpression.DEFAULT_PRIORITY) | ||
| .addPatterns("[the] line %integer% [of %block%]", | ||
| "[the] (1:1st|1:first|2:2nd|2:second|3:3rd|3:third|4:4th|4:fourth) line [of %block%]") | ||
| .build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
origin?
|
|
||
| @Override | ||
| public Class<?> @Nullable [] acceptChange(ChangeMode mode) { | ||
| // TODO allow add, remove, and remove all (see ExprLore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pr or later?
| .supplier(ExprDeathMessage::new) | ||
| .priority(SyntaxInfo.SIMPLE) | ||
| .addPattern("[the] death( |-)message") | ||
| .build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
origin
JakeGBLP
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good PR, loving the communication with addon developers, great job @APickledWalrus !
Problem
Skript's existing text formatting system is outdated, buggy at times, and heavily integrated with the deprecated Bungeecord Component System. As a result, Skript is missing many of the modern text rendering features available through Adventure. Further, many syntax elements use deprecated methods (or just cannot be implemented) due to missing Component support.
Solution
This PR deprecates and replaces all internal usages of the existing text formatting API in favor of Adventure and MiniMessage. I am finalizing the work and testing, but this is generally ready for reviews. I have included a brief walkthrough of the primary changes below.
The Parser
The main parser is represented within TextComponentParser. This parser contains two MiniMessage instances: one for "safe" parsing (e.g. only color/styling codes) and one for "unsafe" parsing (e.g. hovers, click events). As an example,
colored "text"uses the former whileformatted "text"uses the latter.The parser also includes API methods for registering custom tags. This enables addons to register their own formatting codes with Skript's text parser.
Compatibility Efforts
The existing configuration options,
link parse modeandcolors cause resethave been fully preserved. The former is nicely implemented using the TextReplacement feature of Components, while the latter is somewhat hacked together due to how resets are implemented in MiniMessage.Legacy formatting codes/tags have also been preserved. There is a compatibility process built in for mapping them to known tags. There is also a compatibility process for supporting color tags with spaces, e.g.
<dark red>. One important note is that I have overridden the<u>tag, which is normally used for underlines in MiniMessage, to instead continue behaving as a tag for inserting unicode characters.There are converters registered for moving between Strings and Components, though Components are preferred whenever possible.
I have updated
AnyNamedto include support for Component based operations. The methods are default so that this is non-breaking.Conversion Efforts
Most, if not all, existing syntax places where Components can be used have been updated to use Components. I took this opportunity to implement several new modules:
BlockModulesignEntityModulemiscand submodulePlayerModuleItemModulemiscandbookMiscModulebukkit.miscsubpackage. Existing syntax there has not been converted.TextModuleTextComponentParserand text-related syntax, such as message effects and formatting expressions.For better compatibility (and readability), I have split up
ExprMessageinto multiple expressions (one per message type/event).This PR does not implement Component support for chat formatting. That is more complex and will require a dedicated pull request.
Breaking Changes
Many syntax classes have been relocated. If they were being directly referenced, then there will be breaking. I think we should generally consider syntax classes to be internal though.
Other
I have removed the BungeeCord Serializer dependency as it is no longer used.
Testing Completed
No extensive additional tests have been added yet. I performed basic in-game testing. I plan to implement more extensive testing.
Supporting Information
Completes:
<ttp:'<test'>unformatted x, which returns the plain text contentsendRichMessagemethod from Audiences in script #5792Related: none
AI assistance: none