mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Did the requested changes and some fixes.
This commit is contained in:
parent
52dc7585fc
commit
73973a00b7
@ -47,6 +47,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
* @see Research
|
||||
* @see Waypoint
|
||||
* @see PlayerBackpack
|
||||
* @see HashedArmorpiece
|
||||
*
|
||||
*/
|
||||
public final class PlayerProfile {
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -302,25 +303,33 @@ public final class SlimefunItems {
|
||||
|
||||
ItemMeta scubaHelmetMeta = SCUBA_HELMET.getItemMeta();
|
||||
List<String> scubaHelmetMetaLore = scubaHelmetMeta.getLore();
|
||||
scubaHelmetMetaLore.addAll(Arrays.asList("", "&7Equip the full set for:", "&7+Bee Protection"));
|
||||
scubaHelmetMetaLore.addAll(Arrays.asList("",
|
||||
ChatColor.translateAlternateColorCodes('&', "&7Equip the full set for:"),
|
||||
ChatColor.translateAlternateColorCodes('&', "&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"));
|
||||
hazmatChestplateItemMetaLore.addAll(Arrays.asList("",
|
||||
ChatColor.translateAlternateColorCodes('&', "&7Equip the full set for:"),
|
||||
ChatColor.translateAlternateColorCodes('&', "&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"));
|
||||
hazmatLeggingsItemMetaLore.addAll(Arrays.asList("",
|
||||
ChatColor.translateAlternateColorCodes('&', "&7Equip the full set for:"),
|
||||
ChatColor.translateAlternateColorCodes('&', "&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"));
|
||||
rubberBootsItemMetaLore.addAll(Arrays.asList("",
|
||||
ChatColor.translateAlternateColorCodes('&', "&7Equip the full set for:"),
|
||||
ChatColor.translateAlternateColorCodes('&', "&7+Bee Protection")));
|
||||
rubberBootsItemMeta.setLore(rubberBootsItemMetaLore);
|
||||
RUBBER_BOOTS.setItemMeta(rubberBootsItemMeta);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -8,8 +10,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
/**
|
||||
@ -30,18 +33,36 @@ public class BeeListener implements Listener {
|
||||
if (e.getDamager() instanceof Bee) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player p = (Player) e.getEntity();
|
||||
PlayerProfile.get(p, profile -> {
|
||||
|
||||
// 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);
|
||||
HashedArmorpiece[] armors = profile.getArmor();
|
||||
if (hasFullHazmat(armors)) {
|
||||
for (ItemStack armor : p.getInventory().getArmorContents()) {
|
||||
ItemUtils.damageItem(armor, 1, false);
|
||||
}
|
||||
e.setDamage(0D);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasFullHazmat(HashedArmorpiece[] armors) {
|
||||
int hazmatCount = 0;
|
||||
|
||||
// Check for a Hazmat Suit
|
||||
for (HashedArmorpiece armor : armors) {
|
||||
Optional<SlimefunArmorPiece> armorPiece = armor.getItem();
|
||||
if (!armorPiece.isPresent()) return false;
|
||||
|
||||
if (armorPiece.get().getID().equals("SCUBA_HELMET") ||
|
||||
armorPiece.get().getID().equals("HAZMAT_CHESTPLATE") ||
|
||||
armorPiece.get().getID().equals("HAZMAT_LEGGINGS") ||
|
||||
armorPiece.get().getID().equals("RUBBER_BOOTS")) {
|
||||
hazmatCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return hazmatCount == 4;
|
||||
}
|
||||
}
|
||||
|
@ -348,12 +348,12 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {SlimefunItems.SALT, new ItemStack(Material.ROTTEN_FLESH), null, null, null, null, null, null, null})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_HELMET, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), null, null, null})
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_HELMET, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT), null, null, null}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT)})
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT)}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_LEGGINGS, RecipeType.ARMOR_FORGE,
|
||||
@ -913,12 +913,12 @@ public final class SlimefunItemSetup {
|
||||
new PotionEffect[] {new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 300, 1)})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.armor, SlimefunItems.HAZMAT_LEGGINGS, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.ORANGE_WOOL), null, new ItemStack(Material.ORANGE_WOOL), new ItemStack(Material.ORANGE_WOOL), null, new ItemStack(Material.ORANGE_WOOL)})
|
||||
new SlimefunArmorPiece(categories.armor, SlimefunItems.HAZMAT_LEGGINGS, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.ORANGE_WOOL), null, new ItemStack(Material.ORANGE_WOOL), new ItemStack(Material.ORANGE_WOOL), null, new ItemStack(Material.ORANGE_WOOL)}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.armor, SlimefunItems.RUBBER_BOOTS, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {null, null, null, new ItemStack(Material.BLACK_WOOL), null, new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), null, new ItemStack(Material.BLACK_WOOL)})
|
||||
new SlimefunArmorPiece(categories.armor, SlimefunItems.RUBBER_BOOTS, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {null, null, null, new ItemStack(Material.BLACK_WOOL), null, new ItemStack(Material.BLACK_WOOL), new ItemStack(Material.BLACK_WOOL), null, new ItemStack(Material.BLACK_WOOL)}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.misc, SlimefunItems.CRUSHED_ORE, RecipeType.ORE_CRUSHER,
|
||||
@ -1002,12 +1002,12 @@ public final class SlimefunItemSetup {
|
||||
new TableSaw(categories.basicMachines, SlimefunItems.TABLE_SAW).register(plugin);
|
||||
}
|
||||
|
||||
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_HELMET_STEEL, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), null, null, null})
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_HELMET_STEEL, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), null, null, null}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE_STEEL, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL)})
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE_STEEL, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL)}, null)
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_LEGGINGS_STEEL, RecipeType.ARMOR_FORGE,
|
||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.tasks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -63,7 +64,7 @@ public class ArmorTask implements Runnable {
|
||||
checkForSolarHelmet(p);
|
||||
}
|
||||
|
||||
checkForRadiation(p);
|
||||
checkForRadiation(profile);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -119,13 +120,26 @@ public class ArmorTask implements Runnable {
|
||||
return (world.getTime() < 12300 || world.getTime() > 23850) && p.getEyeLocation().getBlock().getLightFromSky() == 15;
|
||||
}
|
||||
|
||||
private void checkForRadiation(Player p) {
|
||||
private void checkForRadiation(PlayerProfile profile) {
|
||||
HashedArmorpiece[] armor = profile.getArmor();
|
||||
Player p = profile.getPlayer();
|
||||
|
||||
// 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(p.getInventory().getHelmet(), SlimefunItems.SCUBA_HELMET, true) || !SlimefunUtils.isItemSimilar(p.getInventory().getChestplate(), SlimefunItems.HAZMAT_CHESTPLATE, true) || !SlimefunUtils.isItemSimilar(p.getInventory().getLeggings(), SlimefunItems.HAZMAT_LEGGINGS, true) || !SlimefunUtils.isItemSimilar(p.getInventory().getBoots(), SlimefunItems.RUBBER_BOOTS, true)) {
|
||||
boolean hasHazmat = false;
|
||||
for (HashedArmorpiece armorPiece : armor) {
|
||||
|
||||
Optional<SlimefunArmorPiece> sfArmor = armorPiece.getItem();
|
||||
if (!sfArmor.isPresent()) continue;
|
||||
|
||||
if (sfArmor.get().getID().equals("SCUBA_HELMET") ||
|
||||
sfArmor.get().getID().equals("HAZMAT_CHESTPLATE") ||
|
||||
sfArmor.get().getID().equals("HAZMAT_LEGGINGS") ||
|
||||
sfArmor.get().getID().equals("RUBBER_BOOTS")) {
|
||||
hasHazmat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasHazmat) {
|
||||
for (ItemStack item : p.getInventory()) {
|
||||
if (isRadioactive(p, item)) {
|
||||
break;
|
||||
|
@ -2,7 +2,6 @@ package me.mrCookieSlime.Slimefun.api;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
Loading…
Reference in New Issue
Block a user