1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Did the requested Changes

This commit is contained in:
LinoxGH 2020-06-27 01:51:38 +03:00
parent 29fe881768
commit ffd57ec760
5 changed files with 43 additions and 45 deletions

View File

@ -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<String> 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<String> 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<String> 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<String> rubberBootsItemMetaLore = rubberBootsItemMeta.getLore();
rubberBootsItemMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection"));
rubberBootsItemMeta.setLore(rubberBootsItemMetaLore);
RUBBER_BOOTS.setItemMeta(rubberBootsItemMeta);
}
Map<Enchantment, Integer> gilded = new HashMap<>();

View File

@ -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);

View File

@ -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;

View File

@ -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());

View File

@ -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<String> oldLore = meta.getLore();
if (oldLore == null) return;
oldLore.addAll(Arrays.asList(newLore));
meta.setLore(oldLore);
setItemMeta(meta);
}
}