Skip to content

Commit 0eea331

Browse files
committed
Try to fix EffImport in test mode
1 parent aa9422a commit 0eea331

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/org/skriptlang/reflect/java/elements/structures/StructImport.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,22 @@ public static class EffImport extends Effect {
183183

184184
@Override
185185
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
186-
if (!getParser().isCurrentEvent(EffectCommandEvent.class) && !Skript.testing()) {
186+
boolean inEffectCommand = getParser().isCurrentEvent(EffectCommandEvent.class);
187+
if (!inEffectCommand && !Skript.testing()) {
187188
Skript.error("The import effect can only be used in effect commands. " +
188189
"To use imports in scripts, use the section.");
189190
return false;
190191
}
191192

192193
className = parseResult.regexes.get(0).group();
193-
194-
return registerImport(className, null);
194+
if (inEffectCommand) {
195+
return registerImport(className, null);
196+
}
197+
boolean registrationResult = registerImport(className, getParser().getCurrentScript());
198+
if (registrationResult) {
199+
updateImports();
200+
}
201+
return registrationResult;
195202
}
196203

197204
@Override

src/test/scripts/StructImport.sk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ import:
55
test "import from structure available":
66
assert Math.PI is set with "Failed to use import from structure"
77
assert AliasForMath.PI is set with "Failed to use import alias from structure"
8-

0 commit comments

Comments
 (0)