diff --git a/pom.xml b/pom.xml index 19afbda70..35f8fb0d9 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ com.wolfyscript.customcrafting customcrafting-spigot - 3.16.2.1 + 3.16.2.2 diff --git a/src/main/java/me/wolfyscript/customcrafting/commands/recipes/ToggleSubCommand.java b/src/main/java/me/wolfyscript/customcrafting/commands/recipes/ToggleSubCommand.java index 97c58c882..5c1ef61a5 100644 --- a/src/main/java/me/wolfyscript/customcrafting/commands/recipes/ToggleSubCommand.java +++ b/src/main/java/me/wolfyscript/customcrafting/commands/recipes/ToggleSubCommand.java @@ -28,6 +28,7 @@ import me.wolfyscript.customcrafting.utils.ChatUtils; import me.wolfyscript.utilities.util.Pair; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; @@ -57,7 +58,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull String var3, @N api.getChat().sendMessage((Player) sender, "$commands.recipes.toggle.disabled$", new Pair<>("%recipe%", args[0])); customCrafting.getDisableRecipesHandler().getRecipes().add(namespacedKey); if (namespacedKey != null) { - Bukkit.getOnlinePlayers().forEach(player -> player.undiscoverRecipe(namespacedKey.toBukkit(customCrafting))); + Bukkit.getOnlinePlayers().forEach(player -> player.undiscoverRecipe(new NamespacedKey(namespacedKey.getNamespace(), namespacedKey.getKey()))); } } } diff --git a/src/main/java/me/wolfyscript/customcrafting/gui/recipe_creator/ClusterRecipeCreator.java b/src/main/java/me/wolfyscript/customcrafting/gui/recipe_creator/ClusterRecipeCreator.java index fc7df4859..7992e6133 100644 --- a/src/main/java/me/wolfyscript/customcrafting/gui/recipe_creator/ClusterRecipeCreator.java +++ b/src/main/java/me/wolfyscript/customcrafting/gui/recipe_creator/ClusterRecipeCreator.java @@ -166,7 +166,7 @@ private void registerSaveButtons() { StringUtil.copyPartialMatches(args[0], registryRecipes.folders(NamespacedKeyUtils.NAMESPACE), results); } else if (args.length == 2) { results.add(""); - StringUtil.copyPartialMatches(args[1], registryRecipes.get(NamespacedKeyUtils.NAMESPACE, args[0]).stream().filter(recipe -> cache.getRecipeCreatorCache().getRecipeType().isInstance(recipe)).map(recipe -> recipe.getNamespacedKey().getKey()).toList(), results); + StringUtil.copyPartialMatches(args[1], registryRecipes.get(NamespacedKeyUtils.NAMESPACE, args[0]).stream().filter(recipe -> cache.getRecipeCreatorCache().getRecipeType().isInstance(recipe)).map(recipe -> NamespacedKeyUtils.getRelativeKeyObjPath(recipe.getNamespacedKey())).toList(), results); } } Collections.sort(results); diff --git a/src/main/java/me/wolfyscript/customcrafting/handlers/DisableRecipesHandler.java b/src/main/java/me/wolfyscript/customcrafting/handlers/DisableRecipesHandler.java index 5131b07b4..dff3c7556 100644 --- a/src/main/java/me/wolfyscript/customcrafting/handlers/DisableRecipesHandler.java +++ b/src/main/java/me/wolfyscript/customcrafting/handlers/DisableRecipesHandler.java @@ -90,7 +90,7 @@ public void disableRecipe(CustomRecipe recipe) { var namespacedKey = recipe.getNamespacedKey(); recipes.add(namespacedKey); if (recipe instanceof ICustomVanillaRecipe) { - Bukkit.removeRecipe(namespacedKey.toBukkit(customCrafting)); + Bukkit.removeRecipe(new org.bukkit.NamespacedKey(namespacedKey.getNamespace(), namespacedKey.getKey())); } saveDisabledRecipes(); } diff --git a/src/main/java/me/wolfyscript/customcrafting/listeners/CraftListener.java b/src/main/java/me/wolfyscript/customcrafting/listeners/CraftListener.java index 917aa364f..914efc4e0 100644 --- a/src/main/java/me/wolfyscript/customcrafting/listeners/CraftListener.java +++ b/src/main/java/me/wolfyscript/customcrafting/listeners/CraftListener.java @@ -110,7 +110,7 @@ public void onPreCraft(PrepareItemCraftEvent e) { //Vanilla Recipe is available. //Check for custom recipe that overrides the vanilla recipe var namespacedKey = NamespacedKey.fromBukkit(((Keyed) e.getRecipe()).getKey()); - if (customCrafting.getDisableRecipesHandler().getRecipes().contains(namespacedKey) || customCrafting.getRegistries().getRecipes().getAdvancedCrafting(NamespacedKeyUtils.toInternal(namespacedKey)) != null) { + if (customCrafting.getDisableRecipesHandler().getRecipes().contains(namespacedKey) || customCrafting.getRegistries().getRecipes().getAdvancedCrafting(namespacedKey) != null) { //Recipe is disabled or it is a custom recipe! e.getInventory().setResult(ItemUtils.AIR); Bukkit.getScheduler().runTask(customCrafting, player::updateInventory); @@ -136,7 +136,7 @@ public void onPreCraft(PrepareItemCraftEvent e) { public void onRecipeDiscover(PlayerRecipeDiscoverEvent event) { org.bukkit.NamespacedKey key = event.getRecipe(); if (key.getNamespace().equals(NamespacedKeyUtils.NAMESPACE)) { - CustomRecipe recipe = customCrafting.getRegistries().getRecipes().get(NamespacedKeyUtils.toInternal(NamespacedKey.fromBukkit(key))); + CustomRecipe recipe = customCrafting.getRegistries().getRecipes().get(NamespacedKey.fromBukkit(key)); if (recipe instanceof ICustomVanillaRecipe vanillaRecipe && vanillaRecipe.isVisibleVanillaBook()) { event.setCancelled(recipe.isHidden() || recipe.isDisabled()); } else { @@ -155,7 +155,7 @@ public void onJoin(PlayerJoinEvent event) { List discoveredCustomRecipes = player.getDiscoveredRecipes().stream().filter(namespacedKey -> namespacedKey.getNamespace().equals(NamespacedKeyUtils.NAMESPACE)).toList(); customCrafting.getRegistries().getRecipes().getAvailable(player).stream() .filter(recipe -> recipe instanceof ICustomVanillaRecipe) - .map(recipe -> recipe.getNamespacedKey().toBukkit(customCrafting)) + .map(recipe -> new org.bukkit.NamespacedKey(recipe.getNamespacedKey().getNamespace(), recipe.getNamespacedKey().getKey())) .filter(namespacedKey -> !discoveredCustomRecipes.contains(namespacedKey)) .forEach(player::discoverRecipe); } diff --git a/src/main/java/me/wolfyscript/customcrafting/recipes/CustomRecipeBlasting.java b/src/main/java/me/wolfyscript/customcrafting/recipes/CustomRecipeBlasting.java index ad35d1c29..25d927cec 100644 --- a/src/main/java/me/wolfyscript/customcrafting/recipes/CustomRecipeBlasting.java +++ b/src/main/java/me/wolfyscript/customcrafting/recipes/CustomRecipeBlasting.java @@ -49,7 +49,7 @@ public CustomRecipeBlasting(CustomRecipeBlasting customRecipeBlasting) { @Override public BlastingRecipe getVanillaRecipe() { if (!getSource().isEmpty()) { - var recipe = new BlastingRecipe(org.bukkit.NamespacedKey.fromString(getNamespacedKey().toString()), getResult().getChoices().get(0).create(), getRecipeChoice(), getExp(), getCookingTime()); + var recipe = new BlastingRecipe(new org.bukkit.NamespacedKey(getNamespacedKey().getNamespace(), getNamespacedKey().getKey()), getResult().getChoices().get(0).create(), getRecipeChoice(), getExp(), getCookingTime()); recipe.setGroup(group); return recipe; } diff --git a/src/main/java/me/wolfyscript/customcrafting/utils/other_plugins/ProtocolLib.java b/src/main/java/me/wolfyscript/customcrafting/utils/other_plugins/ProtocolLib.java index 09b6378e7..1af9666d4 100644 --- a/src/main/java/me/wolfyscript/customcrafting/utils/other_plugins/ProtocolLib.java +++ b/src/main/java/me/wolfyscript/customcrafting/utils/other_plugins/ProtocolLib.java @@ -72,7 +72,7 @@ private void init() { private void registerServerSide() { recipeFilter = minecraftKey -> { if (minecraftKey.getPrefix().equals(NamespacedKeyUtils.NAMESPACE)) { - CustomRecipe recipe = plugin.getRegistries().getRecipes().get(NamespacedKeyUtils.toInternal(NamespacedKey.of(minecraftKey.getFullKey()))); + CustomRecipe recipe = plugin.getRegistries().getRecipes().get(NamespacedKey.of(minecraftKey.getFullKey())); if (recipe instanceof ICustomVanillaRecipe vanillaRecipe && vanillaRecipe.isVisibleVanillaBook()) { return !recipe.isHidden() && !recipe.isDisabled(); }