1
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:
LinoxGH 2020-06-27 12:26:15 +03:00
parent 52dc7585fc
commit 73973a00b7
6 changed files with 79 additions and 35 deletions

View File

@ -47,6 +47,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
* @see Research * @see Research
* @see Waypoint * @see Waypoint
* @see PlayerBackpack * @see PlayerBackpack
* @see HashedArmorpiece
* *
*/ */
public final class PlayerProfile { public final class PlayerProfile {

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -302,25 +303,33 @@ public final class SlimefunItems {
ItemMeta scubaHelmetMeta = SCUBA_HELMET.getItemMeta(); ItemMeta scubaHelmetMeta = SCUBA_HELMET.getItemMeta();
List<String> scubaHelmetMetaLore = scubaHelmetMeta.getLore(); 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); scubaHelmetMeta.setLore(scubaHelmetMetaLore);
SCUBA_HELMET.setItemMeta(scubaHelmetMeta); SCUBA_HELMET.setItemMeta(scubaHelmetMeta);
ItemMeta hazmatChestplateItemMeta = HAZMAT_CHESTPLATE.getItemMeta(); ItemMeta hazmatChestplateItemMeta = HAZMAT_CHESTPLATE.getItemMeta();
List<String> hazmatChestplateItemMetaLore = hazmatChestplateItemMeta.getLore(); 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); hazmatChestplateItemMeta.setLore(hazmatChestplateItemMetaLore);
HAZMAT_CHESTPLATE.setItemMeta(hazmatChestplateItemMeta); HAZMAT_CHESTPLATE.setItemMeta(hazmatChestplateItemMeta);
ItemMeta hazmatLeggingsItemMeta = HAZMAT_LEGGINGS.getItemMeta(); ItemMeta hazmatLeggingsItemMeta = HAZMAT_LEGGINGS.getItemMeta();
List<String> hazmatLeggingsItemMetaLore = hazmatLeggingsItemMeta.getLore(); 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); hazmatLeggingsItemMeta.setLore(hazmatLeggingsItemMetaLore);
HAZMAT_LEGGINGS.setItemMeta(hazmatLeggingsItemMeta); HAZMAT_LEGGINGS.setItemMeta(hazmatLeggingsItemMeta);
ItemMeta rubberBootsItemMeta = RUBBER_BOOTS.getItemMeta(); ItemMeta rubberBootsItemMeta = RUBBER_BOOTS.getItemMeta();
List<String> rubberBootsItemMetaLore = rubberBootsItemMeta.getLore(); 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); rubberBootsItemMeta.setLore(rubberBootsItemMetaLore);
RUBBER_BOOTS.setItemMeta(rubberBootsItemMeta); RUBBER_BOOTS.setItemMeta(rubberBootsItemMeta);
} }

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners; package io.github.thebusybiscuit.slimefun4.implementation.listeners;
import java.util.Optional;
import org.bukkit.entity.Bee; import org.bukkit.entity.Bee;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -8,8 +10,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
/** /**
@ -30,18 +33,36 @@ public class BeeListener implements Listener {
if (e.getDamager() instanceof Bee) { if (e.getDamager() instanceof Bee) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity(); Player p = (Player) e.getEntity();
PlayerProfile.get(p, profile -> {
// Check for a Hazmat Suit HashedArmorpiece[] armors = profile.getArmor();
if (!SlimefunUtils.isItemSimilar(SlimefunItems.SCUBA_HELMET, p.getInventory().getHelmet(), true) && if (hasFullHazmat(armors)) {
!SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_CHESTPLATE, p.getInventory().getChestplate(), true) && for (ItemStack armor : p.getInventory().getArmorContents()) {
!SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_LEGGINGS, p.getInventory().getLeggings(), true) && ItemUtils.damageItem(armor, 1, false);
!SlimefunUtils.isItemSimilar(SlimefunItems.RUBBER_BOOTS, p.getInventory().getBoots(), true)) { }
e.setDamage(0D); e.setDamage(0D);
for (ItemStack armor : p.getInventory().getArmorContents()) {
ItemUtils.damageItem(armor, 1, false);
} }
} });
} }
} }
} }
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;
}
} }

View File

@ -348,12 +348,12 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.SALT, new ItemStack(Material.ROTTEN_FLESH), null, null, null, null, null, null, null}) new ItemStack[] {SlimefunItems.SALT, new ItemStack(Material.ROTTEN_FLESH), null, null, null, null, null, null, null})
.register(plugin); .register(plugin);
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_HELMET, RecipeType.ARMOR_FORGE, 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}) 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); .register(plugin);
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE, RecipeType.ARMOR_FORGE, 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)}) 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); .register(plugin);
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_LEGGINGS, RecipeType.ARMOR_FORGE, 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)}) new PotionEffect[] {new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 300, 1)})
.register(plugin); .register(plugin);
new SlimefunItem(categories.armor, SlimefunItems.HAZMAT_LEGGINGS, RecipeType.ARMOR_FORGE, 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)}) 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); .register(plugin);
new SlimefunItem(categories.armor, SlimefunItems.RUBBER_BOOTS, RecipeType.ARMOR_FORGE, 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)}) 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); .register(plugin);
new SlimefunItem(categories.misc, SlimefunItems.CRUSHED_ORE, RecipeType.ORE_CRUSHER, 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 TableSaw(categories.basicMachines, SlimefunItems.TABLE_SAW).register(plugin);
} }
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_HELMET_STEEL, RecipeType.ARMOR_FORGE, 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}) 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); .register(plugin);
new SlimefunItem(categories.magicalArmor, SlimefunItems.SLIME_CHESTPLATE_STEEL, RecipeType.ARMOR_FORGE, 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)}) 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); .register(plugin);
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_LEGGINGS_STEEL, RecipeType.ARMOR_FORGE, new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_LEGGINGS_STEEL, RecipeType.ARMOR_FORGE,

View File

@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.tasks;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -63,7 +64,7 @@ public class ArmorTask implements Runnable {
checkForSolarHelmet(p); 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; 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 // Check for a Hazmat Suit
if (!SlimefunUtils.isItemSimilar(SlimefunItems.SCUBA_HELMET, p.getInventory().getHelmet(), true) || boolean hasHazmat = false;
!SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_CHESTPLATE, p.getInventory().getChestplate(), true) || for (HashedArmorpiece armorPiece : armor) {
!SlimefunUtils.isItemSimilar(SlimefunItems.HAZMAT_LEGGINGS, p.getInventory().getLeggings(), true) ||
!SlimefunUtils.isItemSimilar(SlimefunItems.RUBBER_BOOTS, p.getInventory().getBoots(), true)) { Optional<SlimefunArmorPiece> sfArmor = armorPiece.getItem();
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)) { 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()) { for (ItemStack item : p.getInventory()) {
if (isRadioactive(p, item)) { if (isRadioactive(p, item)) {
break; break;

View File

@ -2,7 +2,6 @@ package me.mrCookieSlime.Slimefun.api;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;