From a48fe97b4d412227fb18a6f561dbc5f528a157b5 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Fri, 3 Jan 2025 13:54:48 +0100 Subject: [PATCH] Elaborate on slow module Not even my fault --- .../java/eu/m724/tweaks/redstone/GatewayItem.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/m724/tweaks/redstone/GatewayItem.java b/src/main/java/eu/m724/tweaks/redstone/GatewayItem.java index 5d24f05..4082bf3 100644 --- a/src/main/java/eu/m724/tweaks/redstone/GatewayItem.java +++ b/src/main/java/eu/m724/tweaks/redstone/GatewayItem.java @@ -1,11 +1,12 @@ /* - * Copyright (C) 2024 Minecon724 + * Copyright (C) 2025 Minecon724 * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file * in the project root for the full license text. */ package eu.m724.tweaks.redstone; +import eu.m724.tweaks.DebugLogger; import eu.m724.tweaks.Language; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -18,14 +19,21 @@ public class GatewayItem { private final NamespacedKey gatewayKey; public GatewayItem(Plugin plugin) { - this.gatewayKey = new NamespacedKey(plugin, "gateway"); + var start = System.nanoTime(); + this.gatewayKey = new NamespacedKey(plugin, "gateway"); var recipe = new ShapelessRecipe(gatewayKey, itemStack()); + + // this takes a long time for some reason. The first one especially + // do this somewhere off measure to JIT and skew the measurement: new RecipeChoice.MaterialChoice(Material.DIRT); recipe.addIngredient(Material.NETHER_STAR); recipe.addIngredient(Material.ENDER_CHEST); recipe.addIngredient(Material.CHORUS_FLOWER); recipe.addIngredient(Material.DAYLIGHT_DETECTOR); + plugin.getServer().addRecipe(recipe); + + DebugLogger.finer("Adding the recipe took %d ms, which is a long time", (System.nanoTime() - start) / 1000000); } public ItemStack itemStack() {