diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 7deb21d4d..0e16a5ce4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -56,7 +56,7 @@ public final class SlimefunItems { public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can"); public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision"); - public static final SlimefunItemStack CRASH_HELMET = new SlimefunItemStack("CRASH_HELMET", Material.IRON_HELMET, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); + public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("CRASH_HELMET", Material.LEATHER_HELMET, Color.PURPLE, "&5Crash Helmet", "", "&7This helmet will protect you from", "&7crashing while flying elytra."); public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops"); public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items"); public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 6f1a32240..b8edb1107 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -20,7 +20,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CrashHelmetListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCapListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; @@ -454,7 +454,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new EntityInteractionListener(this); new MobDropListener(this); new VillagerTradingListener(this); - new CrashHelmetListener(this); + new ElytraCapListener(this); if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { new BeeListener(this); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java new file mode 100644 index 000000000..3f95744f3 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -0,0 +1,19 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.armor; + +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import org.bukkit.inventory.ItemStack; + +/** + * A class for the Elytra Cap. + * + * @author Seggan + */ +public class ElytraCap extends SlimefunItem { + + public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java index d18f6b484..25b37bffa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CrashHelmetListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCapListener.java @@ -1,7 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -10,9 +12,14 @@ import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; -public class CrashHelmetListener implements Listener { +/** + * The {@link Listener} for the {@link ElytraCap}. + * + * @author Seggan + */ +public class ElytraCapListener implements Listener { - public CrashHelmetListener(@Nonnull SlimefunPlugin plugin) { + public ElytraCapListener(@Nonnull SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @@ -26,8 +33,9 @@ public class CrashHelmetListener implements Listener { if (p.isGliding()) { ItemStack stack = p.getInventory().getHelmet(); SlimefunItem item = SlimefunItem.getByItem(stack); - if ((item != null) && (item.getID().equals("CRASH_HELMET"))) { - e.setDamage(0); + if (item instanceof ElytraCap) { + e.setCancelled(true); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 10, 1); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index 87074f103..a83b23872 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -276,7 +276,7 @@ public final class ResearchSetup { register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN); - register("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.CRASH_HELMET); + register("crash_helmet", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { 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 f6d93646c..e87da5234 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 @@ -5,6 +5,7 @@ import java.util.List; import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -1016,7 +1017,7 @@ public final class SlimefunItemSetup { new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 20)}) .register(plugin); - new SlimefunItem(categories.technicalGadgets, SlimefunItems.CRASH_HELMET, RecipeType.ARMOR_FORGE, + new ElytraCap(categories.technicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) .register(plugin);