Skip to content

Commit

Permalink
fix: tabcompletion & minor oopsies
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Aug 9, 2024
1 parent 828024f commit 22bf6e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.inventory.ItemStack
import org.bukkit.plugin.java.JavaPlugin
import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import kotlin.io.path.isDirectory
import kotlin.io.path.listDirectoryEntries
Expand Down Expand Up @@ -106,10 +107,7 @@ class GearyPluginImpl : GearyPlugin() {
}

// Load prefabs in Geary/prefabs folder, each subfolder is considered its own namespace
dataPath.resolve("prefabs")
.createParentDirectories()
.listDirectoryEntries()
.filter { it.isDirectory() }
dataPath.resolve("prefabs").createParentDirectories().listDirectoryEntries().filter(Path::isDirectory)
.forEach { folder ->
namespace(folder.name) {
geary.logger.i("Loading prefabs from $folder")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ internal class GearyCommands : IdofrontCommandExecutor(), TabCompleter {
}.map { it.toString() }

"load" -> return when (args.size) {
3 -> plugin.dataFolder.listFiles()?.filter {
3 -> plugin.dataFolder.resolve("prefabs").listFiles()?.filter {
it.isDirectory && it.name.startsWith(args[2].lowercase())
}?.map { it.name } ?: listOf()

4 -> {
plugin.dataFolder.resolve(args[2])
.walk()
plugin.dataFolder.resolve("prefabs").resolve(args[2]).walk()
.filter {
it.extension == "yml"
&& it.nameWithoutExtension.startsWith(args[3].lowercase())
&& prefabManager[PrefabKey.of(args[2], it.nameWithoutExtension)] == null
it.name.startsWith(args[3].lowercase()) && it.extension == "yml" && prefabManager[PrefabKey.of(args[2], it.nameWithoutExtension)] == null
}.map {
it.relativeTo(plugin.dataFolder.resolve(args[2])).toString()
}
Expand Down

0 comments on commit 22bf6e1

Please sign in to comment.