Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to remove recipes #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add API to remove recipes #143

wants to merge 1 commit into from

Conversation

Doclic
Copy link

@Doclic Doclic commented Jul 25, 2024

Adds removeRecipe methods to org.bukkit.Bukkit, org.bukkit.Server, and org.bukkit.World.
This is mostly useful for removing Vanilla recipes like this:

for (Recipe recipe : Bukkit.getRecipesFor(new ItemStack(Material.STICK))) {
        Bukkit.removeRecipe(recipe);
}

@Pablete1234
Copy link
Contributor

You can accomplish the same effect via listener:

  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  public void removeDisabledRecipe(PrepareItemCraftEvent event) {
    CraftingInventory crafting = event.getInventory();
    ItemStack result = crafting.getResult();
    if (result == null) return;

    if (disabledRecipes.matches(result)) crafting.setResult(null);
  }

where disabledRecipes is your way of matching

@Doclic
Copy link
Author

Doclic commented Jul 25, 2024

You can accomplish the same effect via listener:

It felt like it would make sense for there to be a way to remove recipes if you can add some.
Since 1.15, Spigot has had a similar API that uses NamespacedKeys.

@Pablete1234
Copy link
Contributor

Modern versions have better ways of handling these, but if the api isn't going to be compatible anyways there's little point in adding a method in the older software, i don't think anyone will benefit from adding this except for the added maintenance burden to a version that is already struggling to get maintained.

Just do it via event, it works all the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants