i found a thing to improve
Johvu opened this issue ยท 4 comments
So I found a thing to improve in the code at CraftEnhance there is getserver.resetRecipes();
that makes some plugins that interfere crafting to duplicate items
Basically some plugins register the recipes via the Bukkit api but also save them in their own data structures to handle them later.
Removing them using the bukkit api via Bukkit.resetRecipes() breaks these plugins.
An easy fix to avoid breaking other plugins is that one, basically you just have to check if the recipe has CraftEnhance namespace to avoid removing other plugins recipes (code not tested but should work if the namespace is correct) .
Iterator<Recipe> it = Bukkit.getServer().recipeIterator();
while (it.hasNext()) {
Recipe r = it.next();
// do your comparisions with the recipe
if(recipe instanceof Keyed)
{
if(((Keyed) recipe).getKey().getNamespace().equals("craftenhance"))
{
it.remove();
}
}
}
Here is the code that should be changed, I think it's the only problematic one
Also refer to this warning
Should be modifiable, I'm quite sure since I think I use a similar method in my plugins, to avoid breaking others :D
Let me know if you need more help