Added discover-recipes
This commit is contained in:
@@ -7,6 +7,7 @@ import com.willfp.eco.util.toSingletonList
|
||||
import com.willfp.ecopets.commands.CommandEcopets
|
||||
import com.willfp.ecopets.commands.CommandPets
|
||||
import com.willfp.ecopets.config.PetsYml
|
||||
import com.willfp.ecopets.pets.DiscoverRecipeListener
|
||||
import com.willfp.ecopets.pets.PetDisplay
|
||||
import com.willfp.ecopets.pets.PetLevelListener
|
||||
import com.willfp.ecopets.pets.PetTriggerXPGainListener
|
||||
@@ -73,7 +74,8 @@ class EcoPetsPlugin : LibReforgePlugin() {
|
||||
PetLevelListener(this),
|
||||
PetTriggerXPGainListener,
|
||||
SpawnEggHandler(this),
|
||||
petDisplay
|
||||
petDisplay,
|
||||
DiscoverRecipeListener(this)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.willfp.ecopets.pets
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Keyed
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerJoinEvent
|
||||
import org.bukkit.inventory.Recipe
|
||||
|
||||
class DiscoverRecipeListener(private val plugin: EcoPlugin) : Listener {
|
||||
@EventHandler
|
||||
fun onJoin(event: PlayerJoinEvent) {
|
||||
if (!plugin.configYml.getBool("discover-recipes")) {
|
||||
return
|
||||
}
|
||||
mutableListOf<Recipe>()
|
||||
.apply { Bukkit.getServer().recipeIterator().forEachRemaining(this::add) }
|
||||
.filterIsInstance<Keyed>().map { it.key }
|
||||
.filter { it.namespace == plugin.name.lowercase() }
|
||||
.filter { !it.key.contains("displayed") }
|
||||
.forEach { event.player.discoverRecipe(it) }
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
# by Auxilor
|
||||
#
|
||||
|
||||
discover-recipes: true
|
||||
|
||||
gui:
|
||||
rows: 6
|
||||
|
||||
|
||||
Reference in New Issue
Block a user