Skip to content

Commit

Permalink
Fix imports not updating after unloading when unloading the 'import' …
Browse files Browse the repository at this point in the history
…structure

Fix custom syntax elements erroring if they don't have a 'parse' entry
  • Loading branch information
UnderscoreTud committed Nov 5, 2023
1 parent 8f42246 commit 190ccc5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class StructImport extends Structure {

// TODO try replacing ImportHandler with JavaType's literal parsing
Skript.registerExpression(ImportHandler.class, JavaType.class, ExpressionType.SIMPLE);
thisInfo = StreamSupport.stream(
Spliterators.spliteratorUnknownSize(Skript.getExpressions(), Spliterator.ORDERED), false)
thisInfo = StreamSupport.stream(Spliterators.spliteratorUnknownSize(Skript.getExpressions(), Spliterator.ORDERED), false)
.filter(i -> i.c == ImportHandler.class)
.findFirst().orElseGet(() -> {
Skript.warning("Could not find custom import class. Custom imports will not work.");
Expand Down Expand Up @@ -74,6 +73,7 @@ public boolean load() {
@Override
public void unload() {
imports.remove(script);
updateImports();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected SectionNode[] getParseNode() {
+ " Please use the 'parse' entry instead");
return new SectionNode[] {safeParseNode};
}
return new SectionNode[] {parseNode};
return new SectionNode[] {parseNode};
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public boolean preLoad() {
if (parseNode == null)
return false;
this.parseNode = parseNode[0];
whichInfo.forEach(which -> parseSectionLoaded.put(which, false));
whichInfo.forEach(which -> parseSectionLoaded.put(which, this.parseNode == null));

SectionNode usableInNode = entryContainer.getOptional("usable in", SectionNode.class, false);
return usableInNode == null || handleUsableEntry(usableInNode, usableSuppliers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public boolean preLoad() {
if (parseNode == null)
return false;
this.parseNode = parseNode[0];
whichInfo.forEach(which -> parseSectionLoaded.put(which, false));
whichInfo.forEach(which -> parseSectionLoaded.put(which, this.parseNode == null));

SectionNode usableInNode = entryContainer.getOptional("usable in", SectionNode.class, false);
return usableInNode == null || handleUsableEntry(usableInNode, usableSuppliers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean preLoad() {
if (parseNode == null)
return false;
this.parseNode = parseNode[0];
whichInfo.forEach(which -> parseSectionLoaded.put(which, false));
whichInfo.forEach(which -> parseSectionLoaded.put(which, this.parseNode == null));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public boolean preLoad() {
if (parseNode == null)
return false;
this.parseNode = parseNode[0];
whichInfo.forEach(which -> parseSectionLoaded.put(which, false));
whichInfo.forEach(which -> parseSectionLoaded.put(which, this.parseNode == null));

Class<?> returnType = entryContainer.getOptional("return type", Class.class, false);
if (returnType != null)
Expand Down

0 comments on commit 190ccc5

Please sign in to comment.