Skip to content

Commit 8c5a1e3

Browse files
authored
replaceOptions (#17)
1 parent 2ef321a commit 8c5a1e3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/com/sovdee/oopsk/elements/structures/StructStructTemplate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sovdee.oopsk.elements.structures;
22

3+
import ch.njol.skript.ScriptLoader;
34
import ch.njol.skript.Skript;
45
import ch.njol.skript.classes.ClassInfo;
56
import ch.njol.skript.config.Node;
@@ -121,7 +122,7 @@ private List<Field<?>> getFields(@NotNull SectionNode node) {
121122
for (Node child : node) {
122123
if (child instanceof SimpleNode simpleNode) {
123124
// match the field pattern
124-
String key = simpleNode.getKey();
125+
String key = ScriptLoader.replaceOptions(simpleNode.getKey());
125126
Matcher matcher;
126127
if (key == null || !(matcher = fieldPattern.matcher(key)).matches()) {
127128
Skript.error("invalid field: " + key);

src/test/scripts/basics.sk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
options:
2+
a: 17
3+
14
struct basic:
25
a: int
36
b: strings
47
c: entitytype = cow
8+
d{@a}: number = {@a}
59

610
test "basic struct behavior":
711
set {_struct} to a basic struct
812
assert {_struct}->a is not set with "struct field a was somehow set"
913
assert {_struct}->b is not set with "struct field b was somehow set"
1014
assert {_struct}->c is a cow with "struct field c was not set to cow"
15+
assert {_struct}->d{@a} is {@a} with "struct field {@a} was not set to {@a}"
1116

1217
set {_struct}->a to 1
1318
assert {_struct}->a is 1 with "struct field a was not set to 1"

0 commit comments

Comments
 (0)