Skip to content

Commit

Permalink
Move Bukkit recipe iterator warm-up code to BukkitFcRecipeProvider_1_13
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWoodworth committed Jul 18, 2020
1 parent 11757cc commit c0a27ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.benwoodworth.fastcraft.bukkit.recipe

import net.benwoodworth.fastcraft.bukkit.util.BukkitVersion
import org.bukkit.Server
import org.bukkit.plugin.Plugin
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
open class BukkitFcRecipeProvider_1_13 @Inject constructor(
plugin: Plugin,
bukkitVersion: BukkitVersion,
private val server: Server,
recipeFactory: BukkitFcCraftingRecipe.Factory,
) : BukkitFcRecipeProvider_1_7(
plugin = plugin,
bukkitVersion = bukkitVersion,
server = server,
recipeFactory = recipeFactory
) {
init {
warmUpRecipeIterator()
}

private fun warmUpRecipeIterator() {
server.recipeIterator().forEach { _ -> }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class BukkitFcRecipeProvider_1_15 @Inject constructor(
bukkitVersion: BukkitVersion,
server: Server,
recipeFactory: BukkitFcCraftingRecipe.Factory,
) : BukkitFcRecipeProvider_1_7(
) : BukkitFcRecipeProvider_1_13(
plugin = plugin,
bukkitVersion = bukkitVersion,
server = server,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class BukkitFastCraft : JavaPlugin() {
fastCraft = factory.createFastCraft()

MetricsLite(this)

// Initial iteration can be slow, so do it now instead of when FastCraft is opened
server.recipeIterator().forEach { _ -> }
}

override fun onDisable() {
Expand Down

0 comments on commit c0a27ca

Please sign in to comment.