Compare commits

..

3 Commits

Author SHA1 Message Date
Auxilor
92f8787eb9 Updated to 6.26.3 2022-03-01 13:03:56 +00:00
Auxilor
5403f7a9ed Fixed multiple option display 2022-03-01 11:29:51 +00:00
Auxilor
2924d6f560 All options are now shown to players in crafting 2022-03-01 11:22:31 +00:00
2 changed files with 31 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ import com.willfp.eco.core.Prerequisite;
import com.willfp.eco.core.items.TestableItem; import com.willfp.eco.core.items.TestableItem;
import com.willfp.eco.core.recipe.Recipes; import com.willfp.eco.core.recipe.Recipes;
import com.willfp.eco.core.recipe.parts.EmptyTestableItem; import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
import com.willfp.eco.core.recipe.parts.GroupedTestableItems;
import com.willfp.eco.core.recipe.parts.TestableStack; import com.willfp.eco.core.recipe.parts.TestableStack;
import com.willfp.eco.util.ListUtils; import com.willfp.eco.util.ListUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -104,23 +105,38 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
} }
char character = String.valueOf(i).toCharArray()[0]; char character = String.valueOf(i).toCharArray()[0];
ItemStack item = parts.get(i).getItem();
if (parts.get(i) instanceof TestableStack) { List<TestableItem> items = new ArrayList<>();
ItemMeta meta = item.getItemMeta(); if (parts.get(i) instanceof GroupedTestableItems group) {
assert meta != null; items.addAll(group.getChildren());
} else {
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>(); items.add(parts.get(i));
assert lore != null;
lore.add("");
String add = Eco.getHandler().getEcoPlugin().getLangYml().getFormattedString("multiple-in-craft");
add = add.replace("%amount%", String.valueOf(item.getAmount()));
lore.add(add);
meta.setLore(lore);
item.setItemMeta(meta);
} }
displayedRecipe.setIngredient(character, new RecipeChoice.ExactChoice(item)); List<ItemStack> displayedItems = new ArrayList<>();
for (TestableItem testableItem : items) {
if (testableItem instanceof TestableStack) {
ItemStack item = testableItem.getItem().clone();
ItemMeta meta = item.getItemMeta();
assert meta != null;
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
assert lore != null;
lore.add("");
String add = Eco.getHandler().getEcoPlugin().getLangYml().getFormattedString("multiple-in-craft");
add = add.replace("%amount%", String.valueOf(item.getAmount()));
lore.add(add);
meta.setLore(lore);
item.setItemMeta(meta);
displayedItems.add(item);
} else {
displayedItems.add(testableItem.getItem());
}
}
displayedRecipe.setIngredient(character, new RecipeChoice.ExactChoice(displayedItems));
} }
if (Prerequisite.HAS_1_18.isMet() && !Prerequisite.HAS_PAPER.isMet()) { if (Prerequisite.HAS_1_18.isMet() && !Prerequisite.HAS_PAPER.isMet()) {

View File

@@ -1,3 +1,3 @@
version = 6.26.2 version = 6.26.3
plugin-name = eco plugin-name = eco
kotlin.code.style = official kotlin.code.style = official