diff --git a/src/main/java/io/github/itzispyder/ogredupealias/events/EntityDeathListener.java b/src/main/java/io/github/itzispyder/ogredupealias/events/EntityDeathListener.java index 67bb30d..bc4c84a 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/events/EntityDeathListener.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/events/EntityDeathListener.java @@ -1,13 +1,16 @@ package io.github.itzispyder.ogredupealias.events; -import io.github.itzispyder.ogredupealias.utils.ItemUtils; +import io.github.itzispyder.ogredupealias.plugin.ItemPresets; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; +import java.util.Objects; + public class EntityDeathListener implements Listener { @EventHandler @@ -17,7 +20,7 @@ public class EntityDeathListener implements Listener { final Location loc = ent.getLocation(); if (type == EntityType.WARDEN) { - loc.getWorld().dropItemNaturally(loc, ItemUtils.skullOf("DeepWarden")); + e.getDrops().stream().filter(Objects::nonNull).filter(i -> i.getType() == Material.SCULK_CATALYST).forEach(i -> i.setItemMeta(ItemPresets.SCULK_CATALYST.getItemMeta())); } } } diff --git a/src/main/java/io/github/itzispyder/ogredupealias/plugin/ItemPresets.java b/src/main/java/io/github/itzispyder/ogredupealias/plugin/ItemPresets.java index 9020e47..550e484 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/plugin/ItemPresets.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/plugin/ItemPresets.java @@ -2,13 +2,24 @@ package io.github.itzispyder.ogredupealias.plugin; import io.github.itzispyder.ogredupealias.data.builder.ItemBuilder; import io.github.itzispyder.ogredupealias.utils.Text; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; public abstract class ItemPresets { + public static final ItemFactory ITEM_FACTORY = Bukkit.getItemFactory(); + + public static ItemStack TROLL_SWORD = ITEM_FACTORY.createItemStack("wooden_sword{Enchantments:[],HideFlags:127,PublicUniVaultValues:[{\"univault:from\":\"Plugin made by ImproperIssues, visit https://github.com/ItziSpyder/UniVault\"}],Unbreakable:1b,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"- No I\\'m not joking, it\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\" really is real!\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"- Don\\'t believe me? Search it up yourself!\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\" \"},{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://google.com/search?q=what+is+the+penis+joke\"},\"text\":\"https://google.com/search?q=what+is+the+penis+joke\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"(\"},{\"italic\":false,\"color\":\"gold\",\"text\":\"The Penis Joke is Real\"},{\"italic\":false,\"color\":\"gray\",\"text\":\") \"},{\"italic\":false,\"color\":\"dark_gray\",\"text\":\"(real)\"}],\"text\":\"\"}'}}"); + + public static ItemStack SCULK_CATALYST = ItemBuilder.create() + .material(Material.SCULK_CATALYST) + .customModelData(1111) + .build(); + public static ItemStack LEGENDARY_CORE = ItemBuilder.create() .material(Material.STRUCTURE_BLOCK) .name(Text.color("&cLegendary Core")) diff --git a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKey.java b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKey.java index 061e7d6..c32afd5 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKey.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKey.java @@ -1,6 +1,7 @@ package io.github.itzispyder.ogredupealias.plugin.custom.forging; import io.github.itzispyder.ogredupealias.utils.ArrayUtils; +import io.github.itzispyder.ogredupealias.utils.ItemUtils; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -11,11 +12,7 @@ public class CraftingKey { public final String key; public CraftingKey(Iterable input) { - this.key = String.join("-", ArrayUtils.toNewList(input,this::keyOfStack)); - } - - private String keyOfStack(ItemStack item) { - return item != null && item.getItemMeta() != null ? item.getType().name().toLowerCase() + ":" + item.getItemMeta().getAsString() : "air:{}"; + this.key = "[" + String.join(", ", ArrayUtils.toNewList(input, ItemUtils::nbtOf)) + "]"; } public CraftingKey(ItemStack[] input) { diff --git a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKeys.java b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKeys.java index 3209520..748342c 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKeys.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CraftingKeys.java @@ -12,9 +12,9 @@ public abstract class CraftingKeys { private static final Map REGISTERED_KEYS = new HashMap<>(); public static void initRecipes() { - register(ItemPresets.LEGENDARY_CORE,"netherite_scrap:{}-trident:{}-netherite_scrap:{}-enchanted_golden_apple:{}-player_head:{SkullOwner:{Id:[I;1216354028,1738164382,-1623044432,661086651],Name:\"DeepWarden\",Properties:{textures:[{Signature:\"pXTxO6vKSFkC2d9rWQc0cgSZoNTUsOb1lTiJKr2XwfL6k6XBZifYZramoitpB+NEav3GlVlIcgmC7+dcLIjVQTZAw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resets.LEGENDARY_CORE,"netherite_scrap:{}-trident:{}-netherite_scrap:{}-enchanted_golden_apple:{}-player_head:{SkullOwner:{Id:[I;1216354028,1738164382,-1623044432,661086651],Name:\"DeepWarden\",Properties:{textures:[{Signature:\"DjztLlK1EwqCe+I14DWq9GLO2wfykaWl0RR//OT/Bt0mZoTgooVS61hrqM5Xkd6aXDxlDe9th9dhU1qD4PnFKKTQ/NrV8Ma09XcV56KcfaonVwtJ1D/jN02rTqPDF5Hk08yFEw/aBeU7QHtQJl86YyUdW7Yq+yJEAsa+CLr5HgKniGZGehENpx/jwEBWVxJOjIBTr5GXaEeiPpJ7STz3Qnswt+NNmppNhBoYChp+64jgnn/EtIxSuyNtJ/qghrvNMjrcTb1hMjgVcWB4XuEOkjPSSdAnKzwRRdTTpzx7qkb80SdKi1j9UYctyzbS/mqDQ5VQjbbRUhZXmUxq9c/2vBbAX9ftbyV37nzqoG+2x1TMs33ZRRPbuK9TJixLK2FpOk/XB9pQyH4VBcLn+UD8AnB/u5f9G3VvPZXNs4YC3Oi9bvGwbyaLzNeoi9F0nNbM+k3TL4c2TVj8pz+oAx7kogIAfRfSravST7GTAFNRhsF+xD8hGZYg4h6xsibVK7I2smoNdeatTbIZH0Q+QqIIjua6fdbFIEvAU/pltDoxDeP+fcJ+JA7+e9VH/o7xIhKHYtiojUHJiSICW8WM7sGKd4/Pc/OC5werAlHtNGc70Nip2wdzKWgRr8ozCNPanp4yqVwzUigT47wiH5xvC8m1X8Vm3b8OkwXT5ec+VIcIrR4=\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTY4MTY1OTU2MjQxNiwKICAicHJvZmlsZUlkIiA6ICI0ODgwMTZlYzY3OWE0ODllOWY0MjRlYjAyNzY3NjFiYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJEZWVwV2FyZGVuIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2E4MDRhYTg3YzlmNGQwNmNhODJkNzk3ZWUyYjk0YjdlMjhjZmQ2MDcxMDI3NmEyODhlMjNmNzkwNjI5NDA0NjAiCiAgICB9CiAgfQp9\"}]}}}-enchanted_golden_apple:{}-netherite_scrap:{}-dragon_head:{}-netherite_scrap:{}"); - register(ItemPresets.LEGENDARY_INGOT,"totem_of_undying:{}-netherite_ingot:{}-totem_of_undying:{}-netherite_ingot:{}-structure_block:{Enchantments:[{id:\"minecraft:lure\",lvl:1s}],HideFlags:1,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"dark_gray\",\"text\":\"- \"},{\"italic\":false,\"color\":\"gray\",\"text\":\"Used for forging\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"red\",\"text\":\"Legendary Core\"}],\"text\":\"\"}'}}-netherite_ingot:{}-totem_of_undying:{}-netherite_ingot:{}-totem_of_undying:{}"); + register(ItemPresets.LEGENDARY_CORE,"[netherite_scrap{}, trident{}, netherite_scrap{}, enchanted_golden_apple{}, sculk_catalyst{CustomModelData:1111}, enchanted_golden_apple{}, netherite_scrap{}, dragon_head{}, netherite_scrap{}]"); + register(ItemPresets.LEGENDARY_INGOT,"[totem_of_undying{}, netherite_ingot{}, totem_of_undying{}, netherite_ingot{}, structure_block{Enchantments:[{id:\"minecraft:lure\",lvl:1s}],HideFlags:1,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"dark_gray\",\"text\":\"- \"},{\"italic\":false,\"color\":\"gray\",\"text\":\"Used for forging\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"red\",\"text\":\"Legendary Core\"}],\"text\":\"\"}'}}, netherite_ingot{}, totem_of_undying{}, netherite_ingot{}, totem_of_undying{}]"); + register(ItemPresets.TROLL_SWORD,"[dirt{}]"); } public static void register(ItemStack result, CraftingKey key) { diff --git a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CustomTable.java b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CustomTable.java index 40d9c1d..d879962 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CustomTable.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/plugin/custom/forging/CustomTable.java @@ -64,10 +64,15 @@ public class CustomTable { } public boolean attemptCraft() { - if (CraftingKeys.getResult(this.getGridKey()).getType().isAir()) return false; ItemStack resultSlotItem = inv.getItem(this.getResultSlot()); if (resultSlotItem != null && !resultSlotItem.getType().isAir()) return false; - ItemStack result = CraftingKeys.getResult(this.getGridKey()); + + ItemStack result = CraftingKeys.getResult(this.getGridKey(false)); + if (result.getType().isAir()) { + result = CraftingKeys.getResult(this.getGridKey(true)); + if (result.getType().isAir()) return false; + } + this.clearGrid(); inv.setItem(this.getResultSlot(),result); return true; @@ -113,7 +118,9 @@ public class CustomTable { final Player p = (Player) e.getPlayer(); final CustomTable table = new CustomTable(inv); - table.getGrid().stream().filter(Objects::nonNull).forEach(item -> { + List items = table.getGrid(); + items.add(table.getResult()); + items.stream().filter(Objects::nonNull).forEach(item -> { p.getWorld().dropItem(p.getLocation(),item); }); } diff --git a/src/main/java/io/github/itzispyder/ogredupealias/utils/ItemUtils.java b/src/main/java/io/github/itzispyder/ogredupealias/utils/ItemUtils.java index 4f204b5..e073965 100644 --- a/src/main/java/io/github/itzispyder/ogredupealias/utils/ItemUtils.java +++ b/src/main/java/io/github/itzispyder/ogredupealias/utils/ItemUtils.java @@ -10,6 +10,13 @@ import java.util.UUID; public abstract class ItemUtils { + public static String nbtOf(ItemStack item) { + if (item == null || item.getType().isAir()) return "air{}"; + String name = item.getType().name().toLowerCase(); + if (!item.hasItemMeta() || item.getItemMeta() == null) return name + "{}"; + return name + item.getItemMeta().getAsString(); + } + public static boolean isSkullOf(ItemStack item, String name) { if (item == null || item.getType().isAir()) return false; if (item.getType() != Material.PLAYER_HEAD) return false;