small fixes

This commit is contained in:
BuildTools committed 2024-04-09 14:22:37 +05:00
1 parent 722e9acf36
commit 2c1394f7f1
5 files changed
+20 -7

No files matched your search

@@ -9,6 +9,10 @@ import su.nightexpress.nightcore.command.api.NightCommand;
import su.nightexpress.nightcore.core.CoreLang;
import su.nightexpress.nightcore.util.Placeholders;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
public class HelpSubCommand extends AbstractCommand<NightCorePlugin> {
public HelpSubCommand(@NotNull NightCorePlugin plugin) {
@@ -29,7 +33,9 @@ public class HelpSubCommand extends AbstractCommand<NightCorePlugin> {
CoreLang.COMMAND_HELP_LIST.getMessage()
.replace(Placeholders.GENERIC_NAME, this.plugin.getNameLocalized())
.replace(Placeholders.GENERIC_ENTRY, list -> {
parent.getChildrens().forEach(children -> {
Set<NightCommand> commands = new HashSet<>(parent.getChildrens());
commands.stream().sorted(Comparator.comparing(command -> command.getAliases()[0])).forEach(children -> {
if (!children.hasPermission(sender)) return;
list.add(children.replacePlaceholders().apply(CoreLang.COMMAND_HELP_ENTRY.getString()));
@@ -143,7 +143,7 @@ public abstract class AbstractCommand<P extends NightCorePlugin> implements Nigh
@Override
@NotNull
public Collection<NightCommand> getChildrens() {
return new ArrayList<>(this.childrens.values());
return this.childrens.values();
}
@Override
@@ -87,14 +87,12 @@ public class FileConfig extends YamlConfiguration {
@NotNull
public static List<FileConfig> loadAll(@NotNull String path) {
return FileUtil.getConfigFiles(path).stream().map(FileConfig::new).toList();
return loadAll(path, false);
}
@NotNull
@Deprecated
public static List<FileConfig> loadAll(@NotNull String path, boolean deep) {
return loadAll(path);
//return FileUtil.getConfigFiles(path).stream().map(FileConfig::new).toList();
return FileUtil.getConfigFiles(path, deep).stream().map(FileConfig::new).toList();
}
public void initializeOptions(@NotNull Class<?> clazz) {
@@ -12,6 +12,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
public class BukkitThing {
@@ -25,6 +26,9 @@ public class BukkitThing {
@NotNull
public static <T extends Keyed> Set<T> allFromRegistry(@NotNull Registry<T> registry) {
if (Version.isBehind(Version.V1_20_R2)) {
return StreamSupport.stream(registry.spliterator(), false).collect(Collectors.toSet());
}
return registry.stream().collect(Collectors.toSet());
}
@@ -52,7 +52,12 @@ public class FileUtil {
@NotNull
public static List<File> getConfigFiles(@NotNull String path) {
return getFiles(path, FileConfig.EXTENSION, false);
return getConfigFiles(path, false);
}
@NotNull
public static List<File> getConfigFiles(@NotNull String path, boolean deep) {
return getFiles(path, FileConfig.EXTENSION, deep);
}
@NotNull