-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Config navigation syntax. #6719
base: feature/script-reflection
Are you sure you want to change the base?
Config navigation syntax. #6719
Conversation
8c12473
to
a2455d0
Compare
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.
How does the navigation work if some line has a dot in it already?
like
options:
a.b:
c: hi
if I wanted to get the c: line using the script navigation could I do that?
@@ -116,6 +118,9 @@ public void move(final SectionNode newParent) { | |||
newParent.add(this); | |||
} | |||
|
|||
@SuppressWarnings("null") | |||
private final static Pattern linePattern = Pattern.compile("^((?:[^#]|##)*)(\\s*#(?!#).*)$"); |
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.
I think you should comment what this matches since it was kinda hard to understand at first sight
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.
I don't actually know what this matches, I think I moved it from somewhere else.
Description
Rudimentary config reading & navigation.
Additions
This adds:
- The types for a
Config
and aNode
:-
Config
s are the key-value structures used internally by script configuration (and code) files-
Node
s are lines in a config, potentially entries (key: value
) or sections (key:)
- A getter for the loaded Skript
config.sk
- Navigators for nodes in the node tree (node "..." of X, nodes of X)
- Type-based value parsers for nodes
- Downstream converters for (skript* ->) config -> node
Syntax
What does this actually do?
It allows you to read a Config node tree and its values.
This does not add support for editing config files or structures.
Caveat: Scripts
Internally,
Script
s are loaded asConfig
s. This contains a fun little experimentalScript -> Config
converter, which means that, technically, script files are also navigable.The output of the above would be:
This would normally be something I would never include, but because it just happens to be supported (by coincidence more than intention) I'm personally okay with leaving it accessible, I think people could make some really cool things with it (even self-programming scripts with the follow-up PR) and I don't think it's very damaging by itself.
That said, I recognise it's probably a bit scary for some people so I don't mind what happens to it too much.
This is part of a series of linked stages around config and script management.
Related Issues: requires #6702