9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-03 22:26:16 +00:00

refactor recipes

This commit is contained in:
XiaoMoMi
2025-04-04 03:21:35 +08:00
parent 6cadf524e4
commit 30588d86eb
19 changed files with 828 additions and 820 deletions

View File

@@ -63,4 +63,5 @@ warning.config.image.invalid_font_name: "<yellow>Issue found in file <arg:0> - T
warning.config.image.lack_char: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'char' argument.</yellow>"
warning.config.image.codepoint_in_use: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a character[<arg:3>(<arg:4>)] in font <arg:2> that has been used by another image '<arg:5>'.</yellow>"
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grind.</yellow>"
warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file <arg:2> not found for image '<arg:1>'.</yellow>"
warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file <arg:2> not found for image '<arg:1>'.</yellow>"
warning.config.recipe.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>"

View File

@@ -10,6 +10,7 @@ public class CraftEngineReloadEvent extends Event {
private final BukkitCraftEngine plugin;
public CraftEngineReloadEvent(BukkitCraftEngine plugin) {
super(true);
this.plugin = plugin;
}

View File

@@ -0,0 +1,10 @@
package net.momirealms.craftengine.bukkit.item.recipe;
import net.momirealms.craftengine.core.item.recipe.Recipe;
import net.momirealms.craftengine.core.util.Key;
import org.bukkit.inventory.ItemStack;
public interface BukkitRecipeConvertor<T extends Recipe<ItemStack>> {
Runnable convert(Key id, T recipe);
}

View File

@@ -82,12 +82,12 @@ public class CrafterEventListener implements Listener {
return;
}
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPELESS, input);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPELESS, input);
if (ceRecipe != null) {
event.setResult(ceRecipe.result(ItemBuildContext.EMPTY));
return;
}
ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPED, input);
ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPED, input);
if (ceRecipe != null) {
event.setResult(ceRecipe.result(ItemBuildContext.EMPTY));
return;

View File

@@ -85,7 +85,7 @@ public class RecipeEventListener implements Listener {
recipeType = RecipeTypes.SMOKING;
}
Recipe<ItemStack> ceRecipe = recipeManager.getRecipe(recipeType, input);
Recipe<ItemStack> ceRecipe = recipeManager.recipeByInput(recipeType, input);
// The item is an ingredient, we should never consider it as fuel firstly
if (ceRecipe != null) return;
@@ -345,7 +345,7 @@ public class RecipeEventListener implements Listener {
try {
@SuppressWarnings("unchecked")
Optional<Object> optionalMCRecipe = (Optional<Object>) Reflections.method$RecipeManager$getRecipeFor1.invoke(
BukkitRecipeManager.minecraftRecipeManager(),
BukkitRecipeManager.nmsRecipeManager(),
Reflections.instance$RecipeType$CAMPFIRE_COOKING,
Reflections.constructor$SingleRecipeInput.newInstance(Reflections.method$CraftItemStack$asNMSCopy.invoke(null, itemStack)),
FastNMS.INSTANCE.field$CraftWorld$ServerLevel(event.getPlayer().getWorld()),
@@ -360,7 +360,7 @@ public class RecipeEventListener implements Listener {
return;
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setCancelled(true);
}
@@ -392,7 +392,7 @@ public class RecipeEventListener implements Listener {
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setTotalCookTime(Integer.MAX_VALUE);
return;
@@ -427,7 +427,7 @@ public class RecipeEventListener implements Listener {
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setCancelled(true);
return;
@@ -802,14 +802,14 @@ public class RecipeEventListener implements Listener {
BukkitServerPlayer serverPlayer = this.plugin.adapt(player);
Key lastRecipe = serverPlayer.lastUsedRecipe();
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPELESS, input, lastRecipe);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPELESS, input, lastRecipe);
if (ceRecipe != null) {
inventory.setResult(ceRecipe.result(new ItemBuildContext(serverPlayer, ContextHolder.EMPTY)));
serverPlayer.setLastUsedRecipe(ceRecipe.id());
correctCraftingRecipeUsed(inventory, ceRecipe);
return;
}
ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPED, input, lastRecipe);
ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPED, input, lastRecipe);
if (ceRecipe != null) {
inventory.setResult(ceRecipe.result(new ItemBuildContext(serverPlayer, ContextHolder.EMPTY)));
serverPlayer.setLastUsedRecipe(ceRecipe.id());
@@ -821,7 +821,7 @@ public class RecipeEventListener implements Listener {
}
private void correctCraftingRecipeUsed(CraftingInventory inventory, Recipe<ItemStack> recipe) {
Object holderOrRecipe = recipeManager.getRecipeHolderByRecipe(recipe);
Object holderOrRecipe = recipeManager.nmsRecipeHolderByRecipe(recipe);
if (holderOrRecipe == null) {
// it's a vanilla recipe but not injected
return;
@@ -857,7 +857,7 @@ public class RecipeEventListener implements Listener {
getOptimizedIDItem(addition)
);
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SMITHING_TRANSFORM, input);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SMITHING_TRANSFORM, input);
if (ceRecipe == null) {
event.setResult(null);
return;
@@ -878,7 +878,7 @@ public class RecipeEventListener implements Listener {
}
private void correctSmithingRecipeUsed(SmithingInventory inventory, Recipe<ItemStack> recipe) {
Object holderOrRecipe = recipeManager.getRecipeHolderByRecipe(recipe);
Object holderOrRecipe = recipeManager.nmsRecipeHolderByRecipe(recipe);
if (holderOrRecipe == null) {
// it's a vanilla recipe but not injected
return;

View File

@@ -200,8 +200,10 @@ public class BukkitCraftEngine extends CraftEngine {
@Override
public void reload() {
super.reload();
CraftEngineReloadEvent event = new CraftEngineReloadEvent(this);
EventUtils.fireAndForget(event);
scheduler.async().execute(() -> {
CraftEngineReloadEvent event = new CraftEngineReloadEvent(this);
EventUtils.fireAndForget(event);
});
}
@Override
@@ -211,32 +213,6 @@ public class BukkitCraftEngine extends CraftEngine {
}
}
@Override
protected void registerParsers() {
// register template parser
this.packManager.registerConfigSectionParser(this.templateManager);
// register font parser
this.packManager.registerConfigSectionParsers(this.fontManager.parsers());
// register item parser
this.packManager.registerConfigSectionParser(this.itemManager);
// register furniture parser
this.packManager.registerConfigSectionParser(this.furnitureManager);
// register block parser
this.packManager.registerConfigSectionParser(this.blockManager);
// register recipe parser
this.packManager.registerConfigSectionParser(this.recipeManager);
// register category parser
this.packManager.registerConfigSectionParser(this.itemBrowserManager);
// register translation parser
this.packManager.registerConfigSectionParser(this.translationManager);
this.packManager.registerConfigSectionParser(this.translationManager.clientLangManager());
// register sound parser
this.packManager.registerConfigSectionParser(this.soundManager);
this.packManager.registerConfigSectionParser(this.soundManager.jukeboxSongManager());
// register vanilla loot parser
this.packManager.registerConfigSectionParser(this.vanillaLootManager);
}
@Override
public InputStream resourceStream(String filePath) {
return bootstrap.getResource(filePath.replace("\\", "/"));

View File

@@ -34,16 +34,18 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
argument = optional.get();
}
if (argument == ReloadArgument.CONFIG) {
try {
RELOAD_PACK_FLAG = true;
long time1 = System.currentTimeMillis();
plugin().reload();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
plugin().scheduler().executeAsync(() -> {
try {
RELOAD_PACK_FLAG = true;
long time1 = System.currentTimeMillis();
plugin().reload();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
});
} else if (argument == ReloadArgument.PACK) {
plugin().scheduler().executeAsync(() -> {
try {
@@ -57,23 +59,18 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
}
});
} else if (argument == ReloadArgument.ALL) {
long time1 = System.currentTimeMillis();
try {
plugin().scheduler().executeAsync(() -> {
long time1 = System.currentTimeMillis();
plugin().reload();
plugin().scheduler().executeAsync(() -> {
try {
plugin().packManager().generateResourcePack();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e);
}
});
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
try {
plugin().packManager().generateResourcePack();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e);
}
});
}
});
}

View File

@@ -47,7 +47,7 @@ public class SearchRecipeAdminCommand extends BukkitCommandFeature<CommandSender
for (Player player : players) {
BukkitServerPlayer serverPlayer = plugin().adapt(player);
Key itemId = Key.of(namespacedKey.namespace(), namespacedKey.value());
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByResult(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByResult(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
}

View File

@@ -35,7 +35,7 @@ public class SearchRecipePlayerCommand extends BukkitCommandFeature<CommandSende
return;
}
Key itemId = item.id();
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByResult(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByResult(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
} else {

View File

@@ -47,7 +47,7 @@ public class SearchUsageAdminCommand extends BukkitCommandFeature<CommandSender>
for (Player player : players) {
BukkitServerPlayer serverPlayer = plugin().adapt(player);
Key itemId = Key.of(namespacedKey.namespace(), namespacedKey.value());
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByIngredient(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByIngredient(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
}

View File

@@ -35,7 +35,7 @@ public class SearchUsagePlayerCommand extends BukkitCommandFeature<CommandSender
return;
}
Key itemId = item.id();
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByIngredient(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByIngredient(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
} else {

View File

@@ -357,7 +357,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -394,13 +394,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -412,7 +412,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(resourceLocation);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(pair.getSecond()));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(pair.getSecond()));
} else {
return Optional.empty();
}
@@ -425,7 +425,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -462,13 +462,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -480,7 +480,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}
@@ -493,7 +493,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -522,13 +522,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -540,7 +540,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}
@@ -553,7 +553,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -583,11 +583,11 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -599,7 +599,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}

View File

@@ -79,14 +79,14 @@ public class InteractUtils {
register(BlockKeys.SOUL_CAMPFIRE, (player, item, blockState, result) -> {
if (!ConfigManager.enableRecipeSystem()) return false;
Optional<Holder.Reference<Key>> optional = BuiltInRegistries.OPTIMIZED_ITEM_ID.get(item.id());
return optional.filter(keyReference -> BukkitRecipeManager.instance().getRecipe(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
return optional.filter(keyReference -> BukkitRecipeManager.instance().recipeByInput(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
keyReference, item.getItem()
))) != null).isPresent();
});
register(BlockKeys.CAMPFIRE, (player, item, blockState, result) -> {
if (!ConfigManager.enableRecipeSystem()) return false;
Optional<Holder.Reference<Key>> optional = BuiltInRegistries.OPTIMIZED_ITEM_ID.get(item.id());
return optional.filter(keyReference -> BukkitRecipeManager.instance().getRecipe(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
return optional.filter(keyReference -> BukkitRecipeManager.instance().recipeByInput(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
keyReference, item.getItem()
))) != null).isPresent();
});

View File

@@ -68,7 +68,7 @@ public abstract class AbstractFontManager implements FontManager {
@Override
public Collection<Font> fonts() {
return new ArrayList<>(this.fonts.values());
return Collections.unmodifiableCollection(this.fonts.values());
}
@Override

View File

@@ -0,0 +1,183 @@
package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.item.recipe.vanilla.VanillaRecipeReader;
import net.momirealms.craftengine.core.item.recipe.vanilla.reader.VanillaRecipeReader1_20;
import net.momirealms.craftengine.core.item.recipe.vanilla.reader.VanillaRecipeReader1_20_5;
import net.momirealms.craftengine.core.item.recipe.vanilla.reader.VanillaRecipeReader1_21_2;
import net.momirealms.craftengine.core.pack.LoadingSequence;
import net.momirealms.craftengine.core.pack.Pack;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.config.ConfigManager;
import net.momirealms.craftengine.core.plugin.config.ConfigSectionParser;
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.VersionHelper;
import org.jetbrains.annotations.Nullable;
import java.nio.file.Path;
import java.util.*;
public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
protected final VanillaRecipeReader recipeReader;
protected final Map<Key, List<Recipe<T>>> byType = new HashMap<>();
protected final Map<Key, Recipe<T>> byId = new HashMap<>();
protected final Map<Key, List<Recipe<T>>> byResult = new HashMap<>();
protected final Map<Key, List<Recipe<T>>> byIngredient = new HashMap<>();
protected final Set<Key> dataPackRecipes = new HashSet<>();
protected final Set<Key> customRecipes = new HashSet<>();
private final RecipeParser recipeParser;
public AbstractRecipeManager() {
this.recipeReader = initVanillaRecipeReader();
this.recipeParser = new RecipeParser();
}
@Override
public ConfigSectionParser parser() {
return this.recipeParser;
}
private VanillaRecipeReader initVanillaRecipeReader() {
if (VersionHelper.isVersionNewerThan1_21_2()) {
return new VanillaRecipeReader1_21_2();
} else if (VersionHelper.isVersionNewerThan1_20_5()) {
return new VanillaRecipeReader1_20_5();
} else {
return new VanillaRecipeReader1_20();
}
}
@Override
public void unload() {
this.dataPackRecipes.clear();
this.byType.clear();
this.byId.clear();
this.byResult.clear();
this.byIngredient.clear();
for (Key key : this.customRecipes) {
unregisterPlatformRecipe(key);
}
this.customRecipes.clear();
}
protected void markAsDataPackRecipe(Key key) {
this.dataPackRecipes.add(key);
}
protected void markAsCustomRecipe(Key key) {
this.customRecipes.add(key);
}
@Override
public boolean isDataPackRecipe(Key key) {
return this.dataPackRecipes.contains(key);
}
@Override
public boolean isCustomRecipe(Key key) {
return this.byId.containsKey(key);
}
@Override
public Optional<Recipe<T>> recipeById(Key key) {
return Optional.ofNullable(this.byId.get(key));
}
@Override
public List<Recipe<T>> recipesByType(Key type) {
return this.byType.getOrDefault(type, List.of());
}
@Override
public List<Recipe<T>> recipeByResult(Key result) {
return this.byResult.getOrDefault(result, List.of());
}
@Override
public List<Recipe<T>> recipeByIngredient(Key ingredient) {
return this.byIngredient.getOrDefault(ingredient, List.of());
}
@Nullable
@Override
public Recipe<T> recipeByInput(Key type, RecipeInput input) {
List<Recipe<T>> recipes = this.byType.get(type);
if (recipes == null) return null;
for (Recipe<T> recipe : recipes) {
if (recipe.matches(input)) {
return recipe;
}
}
return null;
}
@Nullable
@Override
public Recipe<T> recipeByInput(Key type, RecipeInput input, Key lastRecipe) {
if (lastRecipe != null) {
Recipe<T> last = byId.get(lastRecipe);
if (last != null && last.matches(input)) {
return last;
}
}
return recipeByInput(type, input);
}
protected void registerInternalRecipe(Key id, Recipe<T> recipe) {
this.byType.computeIfAbsent(recipe.type(), k -> new ArrayList<>()).add(recipe);
this.byId.put(id, recipe);
this.byResult.computeIfAbsent(recipe.result().item().id(), k -> new ArrayList<>()).add(recipe);
HashSet<Key> usedKeys = new HashSet<>();
for (Ingredient<T> ingredient : recipe.ingredientsInUse()) {
for (Holder<Key> holder : ingredient.items()) {
Key key = holder.value();
if (usedKeys.add(key)) {
this.byIngredient.computeIfAbsent(key, k -> new ArrayList<>()).add(recipe);
}
}
}
}
public class RecipeParser implements ConfigSectionParser {
public static final String[] CONFIG_SECTION_NAME = new String[] {"recipes", "recipe"};
@Override
public int loadingSequence() {
return LoadingSequence.RECIPE;
}
@Override
public String[] sectionId() {
return CONFIG_SECTION_NAME;
}
@Override
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
if (!ConfigManager.enableRecipeSystem()) return;
if (AbstractRecipeManager.this.byId.containsKey(id)) {
TranslationManager.instance().log("warning.config.recipe.duplicated", path.toString(), id.toString());
return;
}
Recipe<T> recipe;
try {
recipe = RecipeTypes.fromMap(id, section);
} catch (Exception e) {
CraftEngine.instance().logger().warn(path, "Failed to create recipe: " + id, e);
return;
}
try {
markAsCustomRecipe(id);
registerInternalRecipe(id, recipe);
registerPlatformRecipe(id, recipe);
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to register custom recipe " + id, e);
}
}
}
protected abstract void unregisterPlatformRecipe(Key key);
protected abstract void registerPlatformRecipe(Key key, Recipe<T> recipe);
}

View File

@@ -1,7 +1,6 @@
package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.pack.LoadingSequence;
import net.momirealms.craftengine.core.plugin.Reloadable;
import net.momirealms.craftengine.core.plugin.config.ConfigSectionParser;
import net.momirealms.craftengine.core.util.Key;
@@ -9,35 +8,28 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
public interface RecipeManager<T> extends Reloadable, ConfigSectionParser {
String[] CONFIG_SECTION_NAME = new String[] {"recipes", "recipe"};
public interface RecipeManager<T> extends Reloadable {
default String[] sectionId() {
return CONFIG_SECTION_NAME;
}
ConfigSectionParser parser();
boolean isDataPackRecipe(Key key);
boolean isCustomRecipe(Key key);
Optional<Recipe<T>> getRecipeById(Key id);
Optional<Recipe<T>> recipeById(Key id);
List<Recipe<T>> getRecipes(Key type);
List<Recipe<T>> recipesByType(Key type);
List<Recipe<T>> getRecipeByResult(Key result);
List<Recipe<T>> recipeByResult(Key result);
List<Recipe<T>> getRecipeByIngredient(Key ingredient);
List<Recipe<T>> recipeByIngredient(Key ingredient);
@Nullable
Recipe<T> getRecipe(Key type, RecipeInput input);
Recipe<T> recipeByInput(Key type, RecipeInput input);
@Nullable Recipe<T> getRecipe(Key type, RecipeInput input, @Nullable Key lastRecipe);
@Nullable
Recipe<T> recipeByInput(Key type, RecipeInput input, @Nullable Key lastRecipe);
CompletableFuture<Void> asyncDelayedLoad();
default int loadingSequence() {
return LoadingSequence.RECIPE;
}
void runSyncTasks();
}

View File

@@ -101,39 +101,43 @@ public abstract class CraftEngine implements Plugin {
public void reload() {
if (this.isReloading) return;
this.isReloading = true;
try {
this.configManager.reload();
this.translationManager.reload();
this.templateManager.reload();
this.furnitureManager.reload();
this.fontManager.reload();
this.itemManager.reload();
this.soundManager.reload();
this.recipeManager.reload();
this.itemBrowserManager.reload();
this.blockManager.reload();
this.worldManager.reload();
this.vanillaLootManager.reload();
// load configs here
this.packManager.reload();
// load at last
this.guiManager.reload();
// delayed load
this.translationManager.delayedLoad();
this.blockManager.delayedLoad();
this.furnitureManager.delayedLoad();
this.itemBrowserManager.delayedLoad();
this.soundManager.delayedLoad();
this.fontManager.delayedLoad();
// reset debugger
if (ConfigManager.debug()) {
this.debugger = (s) -> logger.info("[Debug] " + s.get());
} else {
this.debugger = (s) -> {};
}
} finally {
this.recipeManager.asyncDelayedLoad().thenRun(() -> this.isReloading = false);
this.configManager.reload();
this.translationManager.reload();
this.templateManager.reload();
this.furnitureManager.reload();
this.fontManager.reload();
this.itemManager.reload();
this.soundManager.reload();
this.recipeManager.reload();
this.itemBrowserManager.reload();
this.blockManager.reload();
this.worldManager.reload();
this.vanillaLootManager.reload();
// load configs here
this.packManager.reload();
// load at last
this.guiManager.reload();
// delayed load
this.translationManager.delayedLoad();
this.blockManager.delayedLoad();
this.furnitureManager.delayedLoad();
this.itemBrowserManager.delayedLoad();
this.soundManager.delayedLoad();
this.fontManager.delayedLoad();
this.recipeManager.delayedLoad();
// reset debugger
if (ConfigManager.debug()) {
this.debugger = (s) -> logger.info("[Debug] " + s.get());
} else {
this.debugger = (s) -> {};
}
scheduler().sync().run(() -> {
try {
this.recipeManager.runSyncTasks();
} finally {
this.isReloading = false;
}
});
}
@Override
@@ -181,7 +185,30 @@ public abstract class CraftEngine implements Plugin {
ResourcePackHost.instance().disable();
}
protected abstract void registerParsers();
protected void registerParsers() {
// register template parser
this.packManager.registerConfigSectionParser(this.templateManager);
// register font parser
this.packManager.registerConfigSectionParsers(this.fontManager.parsers());
// register item parser
this.packManager.registerConfigSectionParser(this.itemManager);
// register furniture parser
this.packManager.registerConfigSectionParser(this.furnitureManager);
// register block parser
this.packManager.registerConfigSectionParser(this.blockManager);
// register recipe parser
this.packManager.registerConfigSectionParser(this.recipeManager.parser());
// register category parser
this.packManager.registerConfigSectionParser(this.itemBrowserManager);
// register translation parser
this.packManager.registerConfigSectionParser(this.translationManager);
this.packManager.registerConfigSectionParser(this.translationManager.clientLangManager());
// register sound parser
this.packManager.registerConfigSectionParser(this.soundManager);
this.packManager.registerConfigSectionParser(this.soundManager.jukeboxSongManager());
// register vanilla loot parser
this.packManager.registerConfigSectionParser(this.vanillaLootManager);
}
protected abstract void delayedEnable();

View File

@@ -239,7 +239,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(itemId);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(itemId);
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
openRecipePage(c.clicker(), e.gui(), inRecipes, 0, 0, canOpenNoRecipePage);
@@ -247,7 +247,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, itemId, e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(itemId);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(itemId);
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
openRecipePage(c.clicker(), e.gui(), inRecipes, 0, 0, canOpenNoRecipePage);
@@ -288,7 +288,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
item.count(item.maxStackSize());
c.setItemOnCursor(item);
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(result);
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
openRecipePage(c.clicker(), e.gui(), inRecipes, 0, depth + 1, true);
@@ -377,7 +377,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -386,7 +386,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, result, e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -460,7 +460,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -469,7 +469,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -493,7 +493,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -502,7 +502,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -526,7 +526,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -535,7 +535,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -584,7 +584,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -593,7 +593,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, result, e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -620,7 +620,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -629,7 +629,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -717,7 +717,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -726,7 +726,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, result, e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -759,7 +759,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -768,7 +768,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -862,7 +862,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -871,7 +871,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, result, e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(result);
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(result);
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -954,7 +954,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -963,7 +963,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -997,7 +997,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
return;
}
if (LEFT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByResult(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByResult(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {
@@ -1006,7 +1006,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
openNoRecipePage(player, e.item().id(), e.gui(), 0);
}
} else if (RIGHT_CLICK.contains(c.type())) {
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().getRecipeByIngredient(e.item().id());
List<Recipe<Object>> inRecipes = this.plugin.recipeManager().recipeByIngredient(e.item().id());
if (inRecipes == recipes) return;
player.playSound(Constants.SOUND_CLICK_BUTTON);
if (!inRecipes.isEmpty()) {