Skip to content

Commit

Permalink
SkriptCommand - fix sending hidden files (#7315)
Browse files Browse the repository at this point in the history
* SkriptCommand - fix sending hidden files

* SkriptCommand - fix directory issue

* SkriptCommand - only show scripts

* SkriptCommand - fix spacing

---------

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 29, 2024
1 parent bc0c5ee commit e033942
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/java/ch/njol/skript/SkriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -457,7 +458,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
ScriptLoader.getDisabledScripts().stream()
.flatMap(file -> {
if (file.isDirectory()) {
return Arrays.stream(file.listFiles());
return getSubFiles(file).stream();
}
return Arrays.stream(new File[]{file});
})
Expand All @@ -479,6 +480,20 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
private static final ArgsMessage m_invalid_script = new ArgsMessage(CONFIG_NODE + ".invalid script");
private static final ArgsMessage m_invalid_folder = new ArgsMessage(CONFIG_NODE + ".invalid folder");

private static List<File> getSubFiles(File file) {
List<File> files = new ArrayList<>();
if (file.isDirectory()) {
for (File listFile : file.listFiles(f -> !f.isHidden())) {
if (listFile.isDirectory()) {
files.addAll(getSubFiles(listFile));
} else if (listFile.getName().endsWith(".sk")) {
files.add(listFile);
}
}
}
return files;
}

private static @Nullable File getScriptFromArgs(CommandSender sender, String[] args) {
return getScriptFromArgs(sender, args, Skript.getInstance().getScriptsFolder());
}
Expand Down

0 comments on commit e033942

Please sign in to comment.