Skip to content

Commit 1efebbb

Browse files
Merge branch 'J4C0B3Y:main' into main
2 parents d7526ca + c8ade8e commit 1efebbb

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Flexible and robust static access configuration api.
1818
- Annotation based field modifiers
1919
- Automatic header and footer comments
2020
- User friendly message utility class
21+
- Supports kotlin's static classes
2122
- Small and lightweight (~500kb)
2223

2324
## Support
@@ -110,13 +111,10 @@ all fields in your class will be loaded and saved to the yaml document.
110111

111112
- The file specified in the constructor should be in the plugin's data folder, else it will appear in the main server directory.
112113

113-
- You can optionally set the defaults for the plugin by using `getResource`, this shouldn't be used by most people unless you are directly accessing values.
114-
115114
```java
116115
public Settings(ExamplePlugin plugin) {
117116
super(
118-
new File(plugin.getDataFolder(), "settings.yml"), // Point 1 (Required)
119-
plugin.getResource("settings.yml"), // Point 2 (Optional)
117+
new File(plugin.getDataFolder(), "settings.yml"),
120118
plugin.getConfigHandler()
121119
);
122120
}
@@ -292,6 +290,26 @@ override: true
292290
# OVERRIDE is set to true.
293291
```
294292

293+
#### @Priority
294+
295+
Used to set the position / order of a node instead of
296+
using the position of the static member in the class.
297+
298+
Nodes have a priority of `Integer.MAX_VALUE` by default.
299+
300+
```java
301+
@Priority(2)
302+
public static int EXAMPLE = 3;
303+
304+
@Priority(1)
305+
public static class TEST { }
306+
```
307+
308+
```yaml
309+
test: {}
310+
example: 3
311+
```
312+
295313
#### @Header & @Footer
296314

297315
- @Header is used to add a header comment to the top of a config document.
@@ -413,7 +431,7 @@ For more information about resolvers, please refer to the internal javadocs.
413431
### Limitations
414432

415433
Due to the way that class members are retrieved in java, fields are always above
416-
subclasses meaning the following is not possible.
434+
subclasses meaning the following is not possible without using @Priority.
417435

418436
<details>
419437
<summary>Expand</summary>

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
object Project {
1414
const val NAME = "ConfigAPI"
1515
const val GROUP = "net.j4c0b3y"
16-
const val VERSION = "1.2.5"
16+
const val VERSION = "1.2.6"
1717
}
1818

1919
allprojects {

core/src/main/java/net/j4c0b3y/api/config/StaticConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ private void step(String path) throws ReflectiveOperationException {
333333

334334
// Set the associated comment for the route's block if present.
335335
document.setComment(document.getBlock(route), field.getAnnotation(Comment.class));
336+
337+
// Ensure position is forced when structure formatting is enabled.
338+
if (handler.isFormatStructure()) {
339+
document.move(route, route);
340+
}
341+
336342
continue;
337343
}
338344

@@ -352,6 +358,12 @@ private void step(String path) throws ReflectiveOperationException {
352358
// If the section exists, and we shouldn't skip, set the comment and recurse.
353359
if (section != null) {
354360
document.setComment(section, member.getAnnotation(Comment.class));
361+
362+
// Ensure position is forced when structure formatting is enabled.
363+
if (handler.isFormatStructure()) {
364+
document.move(route, route);
365+
}
366+
355367
step(route);
356368
}
357369
}

0 commit comments

Comments
 (0)