Skip to content

Commit b65abe0

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

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,18 @@ 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+
return registerImport(className, getParser().getCurrentScript());
195198
}
196199

197200
@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)