Skip to content

Conversation

Efnilite
Copy link
Member

@Efnilite Efnilite commented Aug 10, 2025

Problem

Newly added nodes during config updating appear in unpredictable ways due to bad design of the Node classes and some bugs in the config updating code.

Solution

Comments are now associated to a SectionNode, SimpleNode or InvalidNode

For config files, comments have been changed to be associated to a section node, simple node or invalid node. This reduces the complexity of updating the config and allows comments to be deleted or changed. They will only be added if the actual node is deleted. Void nodes are now no longer taken into account.

To allow saving of nodes with comments, a new getAsStrings method has been added, which serializes the node and its comments to a string format. This allows the node to be added to a config. Since the functionality of save(PrintWriter) does not support this, and to allow developers to use a writer of their own choosing, this method has been deprecated.

Fix some problems with adding at a specified index

Due to the previously mentioned complexity of the Node classes, adding a node at an index during the updating process would have an unreliable result. To fix this, a new addRelative method has been added, which now adds a Node correctly. Since this requires ignoring void nodes, its behaviour differs from add.

Move node parsing to SectionNode.NodeParser

In an attempt to clean up SectionNode, the node parsing logic has been moved to a static nested class. Furthermore, documentation has been added. This is a good setup to allow someone to improve this quite messy code down the line.

Comments now appear before the key of a node

In an attempt to standardize our config format with existing formats, and to reduce the complexity of finding/associating comments, config comments now appear before the key of the node.

Testing Completed

  • Manual testing
  • JUnit tests for various scenarios using the actual Skript config

Supporting Information

  • Improve testing with converting existing configs to the new format

Completes: #7533
Related: none

@Efnilite Efnilite added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant