Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
feat: auto-discover all vanilla recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Feb 4, 2024
1 parent 219469e commit 4b8d17b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/com/mineinabyss/looty/LootyCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package com.mineinabyss.looty

import com.mineinabyss.idofront.commands.execution.IdofrontCommandExecutor
import com.mineinabyss.looty.config.looty
import org.bukkit.Bukkit

class LootyCommands : IdofrontCommandExecutor() {
override val commands = commands(looty.plugin) {
"looty" {
"reload" {
action {
looty.configController.reload()
Bukkit.updateRecipes()
sender.sendMessage("Reloaded Looty config")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/com/mineinabyss/looty/config/LootyConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import kotlinx.serialization.Serializable
@Serializable
data class LootyConfig(
val debug: Boolean = false,
val migrateByCustomModelData: Boolean = false
val migrateByCustomModelData: Boolean = false,
val autoDiscoverVanillaRecipes: Boolean = false
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mineinabyss.looty.features.recipes

import com.mineinabyss.looty.config.looty
import org.bukkit.Bukkit
import org.bukkit.Keyed
import org.bukkit.NamespacedKey
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
Expand All @@ -11,5 +14,8 @@ class RecipeDiscoverySystem(
@EventHandler
fun PlayerJoinEvent.showRecipesOnJoin() {
player.discoverRecipes(discoveredRecipes)
if (looty.config.autoDiscoverVanillaRecipes)
player.discoverRecipes(Bukkit.recipeIterator().asSequence().filterIsInstance<Keyed>()
.filter { it.key.namespace == "minecraft" && it.key !in discoveredRecipes }.map { it.key }.toList())
}
}
2 changes: 0 additions & 2 deletions src/main/resources/config.yml

This file was deleted.

0 comments on commit 4b8d17b

Please sign in to comment.