mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
The Enhanced Auto Crafter now requires confirmation too
This commit is contained in:
parent
e8a67cdd6a
commit
0adc1c3192
@ -4,6 +4,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -12,8 +14,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
@ -55,10 +61,31 @@ public class EnhancedAutoCrafter extends AbstractAutoCrafter {
|
||||
AbstractRecipe recipe = AbstractRecipe.of(item);
|
||||
|
||||
if (recipe != null) {
|
||||
setSelectedRecipe(b, recipe);
|
||||
ChestMenu menu = new ChestMenu(getItemName());
|
||||
menu.setPlayerInventoryClickable(false);
|
||||
menu.setEmptySlotsClickable(false);
|
||||
|
||||
ChestMenuUtils.drawBackground(menu, background);
|
||||
ChestMenuUtils.drawBackground(menu, 45, 46, 47, 48, 50, 51, 52, 53);
|
||||
|
||||
menu.addItem(49, new CustomItem(Material.CRAFTING_TABLE, ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "messages.auto-crafting.select")));
|
||||
menu.addMenuClickHandler(49, (pl, stack, slot, action) -> {
|
||||
setSelectedRecipe(b, recipe);
|
||||
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.auto-crafting.recipe-set");
|
||||
showRecipe(p, b, recipe);
|
||||
return false;
|
||||
});
|
||||
|
||||
AsyncRecipeChoiceTask task = new AsyncRecipeChoiceTask();
|
||||
recipe.show(menu, task);
|
||||
menu.open(p);
|
||||
|
||||
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.auto-crafting.recipe-set");
|
||||
showRecipe(p, b, recipe);
|
||||
|
||||
if (!task.isEmpty()) {
|
||||
task.start(menu.toInventory());
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.auto-crafting.no-recipes");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user