From f19485f24fe97731319ee50faa4f31c4491a8d1f Mon Sep 17 00:00:00 2001 From: Phoenix-Starlight Date: Sat, 11 Mar 2023 13:42:08 -0800 Subject: [PATCH 1/2] Make Fire Staff not disenchantable by default --- .../items/magical/staves/FireStaff.java | 29 +++++++++++++++++++ .../setup/SlimefunItemSetup.java | 9 +++--- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java new file mode 100644 index 000000000..7fd8530b2 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java @@ -0,0 +1,29 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + +/** + * The {@link FireStaff} is a magical {@link SlimefunItem}, enchanted with Fire Aspect 5. + * + * @author Fury_Phoenix + * + */ +public class FireStaff extends SlimefunItem { + + @ParametersAreNonnullByDefault + public FireStaff(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(itemGroup, item, recipeType, recipe); + disenchantable = false; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index f4c8fffc3..a7a0becb5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -152,6 +152,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.Enc import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.SoulboundRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.FireStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WaterStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WindStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; @@ -688,6 +689,10 @@ public final class SlimefunItemSetup { new ItemStack[] {null, new ItemStack(Material.LILY_PAD), SlimefunItems.MAGIC_LUMP_2, null, SlimefunItems.STAFF_ELEMENTAL, new ItemStack(Material.LILY_PAD), SlimefunItems.STAFF_ELEMENTAL, null, null}) .register(plugin); + new FireStaff(itemGroups.magicalGadgets, SlimefunItems.STAFF_FIRE, RecipeType.MAGIC_WORKBENCH, + new ItemStack[] {null, null, SlimefunItems.LAVA_CRYSTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, null}) + .register(plugin); + String[] multiToolItems = new String[] {"PORTABLE_CRAFTER", "MAGIC_EYE_OF_ENDER", "STAFF_ELEMENTAL_WIND", "GRAPPLING_HOOK"}; new MultiTool(itemGroups.technicalGadgets, SlimefunItems.DURALUMIN_MULTI_TOOL, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -792,10 +797,6 @@ public final class SlimefunItemSetup { new UnplaceableBlock(itemGroups.magicalResources, SlimefunItems.LAVA_CRYSTAL, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.BLAZE_POWDER), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.BLAZE_POWDER), SlimefunItems.FIRE_RUNE, new ItemStack(Material.BLAZE_POWDER), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.BLAZE_POWDER), SlimefunItems.MAGIC_LUMP_1}) .register(plugin); - - new SlimefunItem(itemGroups.magicalGadgets, SlimefunItems.STAFF_FIRE, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, null, SlimefunItems.LAVA_CRYSTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, null}) - .register(plugin); new StormStaff(itemGroups.magicalGadgets, SlimefunItems.STAFF_STORM, RecipeType.ANCIENT_ALTAR, new ItemStack[] {SlimefunItems.LIGHTNING_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.LIGHTNING_RUNE, SlimefunItems.STAFF_WATER, SlimefunItems.MAGIC_SUGAR, SlimefunItems.STAFF_WIND, SlimefunItems.LIGHTNING_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.LIGHTNING_RUNE}) From 5d5d00f9fa8deb8594a565b0a1691c9dbf1166d3 Mon Sep 17 00:00:00 2001 From: Phoenix-Starlight Date: Sun, 12 Mar 2023 13:15:56 -0700 Subject: [PATCH 2/2] Generalize the class --- .../staves/FireStaff.java => EnchantedItem.java} | 9 +++++---- .../implementation/setup/SlimefunItemSetup.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/{magical/staves/FireStaff.java => EnchantedItem.java} (66%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java index 7fd8530b2..a7525c997 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/FireStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; +package io.github.thebusybiscuit.slimefun4.implementation.items; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,15 +13,16 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; /** - * The {@link FireStaff} is a magical {@link SlimefunItem}, enchanted with Fire Aspect 5. + * The {@link EnchantedItem} is an enchanted {@link SlimefunItem}. + * By default, this class sets items to be not disenchantable. * * @author Fury_Phoenix * */ -public class FireStaff extends SlimefunItem { +public class EnchantedItem extends SlimefunItem { @ParametersAreNonnullByDefault - public FireStaff(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public EnchantedItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); disenchantable = false; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index a7a0becb5..ba137f993 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -26,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.items.EnchantedItem; import io.github.thebusybiscuit.slimefun4.implementation.items.HiddenItem; import io.github.thebusybiscuit.slimefun4.implementation.items.RadioactiveItem; import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; @@ -152,7 +153,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.Enc import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.SoulboundRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.FireStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WaterStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WindStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; @@ -689,7 +689,7 @@ public final class SlimefunItemSetup { new ItemStack[] {null, new ItemStack(Material.LILY_PAD), SlimefunItems.MAGIC_LUMP_2, null, SlimefunItems.STAFF_ELEMENTAL, new ItemStack(Material.LILY_PAD), SlimefunItems.STAFF_ELEMENTAL, null, null}) .register(plugin); - new FireStaff(itemGroups.magicalGadgets, SlimefunItems.STAFF_FIRE, RecipeType.MAGIC_WORKBENCH, + new EnchantedItem(itemGroups.magicalGadgets, SlimefunItems.STAFF_FIRE, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {null, null, SlimefunItems.LAVA_CRYSTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, null}) .register(plugin);