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 0f177404d..d78ef5c93 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.implementation; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.bukkit.Color; @@ -297,10 +299,30 @@ public final class SlimefunItems { REINFORCED_ALLOY_BOOTS.addUnsafeEnchantments(reinforced); if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { - SCUBA_HELMET.addLore("", "&7Equip the full set for:", "&7+Bee Protection"); - HAZMAT_CHESTPLATE.addLore("", "&7Equip the full set for:", "&7+Bee Protection"); - HAZMAT_LEGGINGS.addLore("", "&7Equip the full set for:", "&7+Bee Protection"); - RUBBER_BOOTS.addLore("", "&7Equip the full set for:", "&7+Bee Protection"); + + ItemMeta scubaHelmetMeta = SCUBA_HELMET.getItemMeta(); + List scubaHelmetMetaLore = scubaHelmetMeta.getLore(); + scubaHelmetMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection")); + scubaHelmetMeta.setLore(scubaHelmetMetaLore); + SCUBA_HELMET.setItemMeta(scubaHelmetMeta); + + ItemMeta hazmatChestplateItemMeta = HAZMAT_CHESTPLATE.getItemMeta(); + List hazmatChestplateItemMetaLore = hazmatChestplateItemMeta.getLore(); + hazmatChestplateItemMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection")); + hazmatChestplateItemMeta.setLore(hazmatChestplateItemMetaLore); + HAZMAT_CHESTPLATE.setItemMeta(hazmatChestplateItemMeta); + + ItemMeta hazmatLeggingsItemMeta = HAZMAT_LEGGINGS.getItemMeta(); + List hazmatLeggingsItemMetaLore = hazmatLeggingsItemMeta.getLore(); + hazmatLeggingsItemMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection")); + hazmatLeggingsItemMeta.setLore(hazmatLeggingsItemMetaLore); + HAZMAT_LEGGINGS.setItemMeta(hazmatLeggingsItemMeta); + + ItemMeta rubberBootsItemMeta = RUBBER_BOOTS.getItemMeta(); + List rubberBootsItemMetaLore = rubberBootsItemMeta.getLore(); + rubberBootsItemMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection")); + rubberBootsItemMeta.setLore(rubberBootsItemMetaLore); + RUBBER_BOOTS.setItemMeta(rubberBootsItemMeta); } Map gilded = new HashMap<>(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HazmatSuitListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeListener.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HazmatSuitListener.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeListener.java index 3af80370a..b7738e1b7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HazmatSuitListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeListener.java @@ -8,8 +8,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.SlimefunPlugin; /** @@ -18,36 +18,24 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin; * * @author Linox * - * @see Bee - * */ -public class HazmatSuitListener implements Listener { +public class BeeListener implements Listener { - public HazmatSuitListener(SlimefunPlugin plugin) { + public BeeListener(SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @EventHandler public void onDamage(EntityDamageByEntityEvent e) { - if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) return; - if (e.getDamager() instanceof Bee) { if (e.getEntity() instanceof Player) { Player p = (Player) e.getEntity(); - int hazmatCount = 0; - for (ItemStack armor : p.getInventory().getArmorContents()) { - SlimefunItem sfItem = SlimefunItem.getByItem(armor); - if (sfItem == null) return; - - String id = sfItem.getID(); - if (id.equals("SCUBA_HELMET")) hazmatCount++; - if (id.equals("HAZMAT_CHESTPLATE")) hazmatCount++; - if (id.equals("HAZMAT_LEGGINGS")) hazmatCount++; - if (id.equals("RUBBER_BOOTS")) hazmatCount++; - } - - if (hazmatCount == 4) { + // Check for a Hazmat Suit + if (!SlimefunUtils.isItemSimilar(SlimefunItems.SCUBA_HELMET, p.getInventory().getHelmet(), true) && + !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_CHESTPLATE, p.getInventory().getChestplate(), true) && + !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_LEGGINGS, p.getInventory().getLeggings(), true) && + !SlimefunUtils.isItemSimilar(SlimefunItems.RUBBER_BOOTS, p.getInventory().getBoots(), true)) { e.setDamage(0D); for (ItemStack armor : p.getInventory().getArmorContents()) { ItemUtils.damageItem(armor, 1, false); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java index e3809b012..db7a6ed1e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java @@ -107,7 +107,10 @@ public class ArmorTask implements Runnable { private void checkForRadiation(Player p) { // Check for a Hazmat Suit - if (!SlimefunUtils.isItemSimilar(SlimefunItems.SCUBA_HELMET, p.getInventory().getHelmet(), true) || !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_CHESTPLATE, p.getInventory().getChestplate(), true) || !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_LEGGINGS, p.getInventory().getLeggings(), true) || !SlimefunUtils.isItemSimilar(SlimefunItems.RUBBER_BOOTS, p.getInventory().getBoots(), true)) { + if (!SlimefunUtils.isItemSimilar(SlimefunItems.SCUBA_HELMET, p.getInventory().getHelmet(), true) || + !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_CHESTPLATE, p.getInventory().getChestplate(), true) || + !SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_LEGGINGS, p.getInventory().getLeggings(), true) || + !SlimefunUtils.isItemSimilar(SlimefunItems.RUBBER_BOOTS, p.getInventory().getBoots(), true)) { for (ItemStack item : p.getInventory()) { if (isRadioactive(p, item)) { break; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index 0c5480ad8..1f125642c 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -10,7 +10,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.HazmatSuitListener; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.command.Command; @@ -54,6 +53,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAx import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade; import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; @@ -238,7 +238,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new WitherListener(this); new IronGolemListener(this); new PlayerInteractEntityListener(this); - new HazmatSuitListener(this); + if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + new BeeListener(this); + } new MobDropListener(this, (BasicCircuitBoard) SlimefunItems.BASIC_CIRCUIT_BOARD.getItem()); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index aab0762b3..0b3f1975b 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -245,21 +245,4 @@ public class SlimefunItemStack extends CustomItem { throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); } } - - /** - * Adds additional lores for the {@link ItemStack}. - * - * @param newLore - * New lores to be added to the {@link ItemStack} - */ - public void addLore(String... newLore) { - ItemMeta meta = getItemMeta(); - if (meta == null) return; - List oldLore = meta.getLore(); - if (oldLore == null) return; - - oldLore.addAll(Arrays.asList(newLore)); - meta.setLore(oldLore); - setItemMeta(meta); - } }