mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
fix getting radiated when not supposed to
This commit is contained in:
parent
7da1af0383
commit
27f4ecbacf
@ -493,24 +493,17 @@ public class PlayerProfile {
|
||||
|
||||
for (HashedArmorpiece armorpiece : armor) {
|
||||
Optional<SlimefunArmorPiece> armorPiece = armorpiece.getItem();
|
||||
|
||||
if (!armorPiece.isPresent()) {
|
||||
setId = null;
|
||||
} else if (armorPiece.get() instanceof ProtectiveArmor protectedArmor) {
|
||||
if (setId == null && protectedArmor.isFullSetRequired()) {
|
||||
setId = protectedArmor.getArmorSetId();
|
||||
}
|
||||
|
||||
for (ProtectionType protectionType : protectedArmor.getProtectionTypes()) {
|
||||
if (armorPiece.isPresent() && armorPiece.get() instanceof ProtectiveArmor protectiveArmor) {
|
||||
for (ProtectionType protectionType : protectiveArmor.getProtectionTypes()) {
|
||||
if (protectionType == type) {
|
||||
if (setId == null) {
|
||||
if (!protectiveArmor.isFullSetRequired()) {
|
||||
return true;
|
||||
} else if (setId.equals(protectedArmor.getArmorSetId())) {
|
||||
} else if (setId == null || setId.equals(protectiveArmor.getArmorSetId())) {
|
||||
armorCount++;
|
||||
setId = protectiveArmor.getArmorSetId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHook
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.HopperListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.JoinListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiddleClickListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiningAndroidListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
|
||||
@ -646,6 +647,7 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon {
|
||||
new BeeWingsListener(this, (BeeWings) SlimefunItems.BEE_WINGS.getItem());
|
||||
new PiglinListener(this);
|
||||
new SmithingTableListener(this);
|
||||
new JoinListener(this);
|
||||
|
||||
// Item-specific Listeners
|
||||
new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem());
|
||||
|
@ -0,0 +1,43 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask;
|
||||
|
||||
/**
|
||||
* This {@link Listener} caches the armor of the player on join.
|
||||
* This is mainly for the {@link RadiationTask}.
|
||||
*
|
||||
* @author iTwins
|
||||
*/
|
||||
public class JoinListener implements Listener {
|
||||
|
||||
public JoinListener(@Nonnull Slimefun plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(@Nonnull PlayerJoinEvent e) {
|
||||
PlayerProfile.get(e.getPlayer(), playerProfile -> {
|
||||
final ItemStack[] armorContents = e.getPlayer().getInventory().getArmorContents();
|
||||
final HashedArmorpiece[] hashedArmorpieces = playerProfile.getArmor();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (armorContents[i] != null && armorContents[i].getType() != Material.AIR && SlimefunItem.getByItem(armorContents[i]) instanceof SlimefunArmorPiece sfArmorPiece) {
|
||||
hashedArmorpieces[i].update(armorContents[i], sfArmorPiece);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -85,6 +85,8 @@ public class RadiationTask extends AbstractArmorTask {
|
||||
BaseComponent[] components = new ComponentBuilder().append(ChatColors.color(msg)).create();
|
||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
|
||||
}
|
||||
} else {
|
||||
RadiationUtils.removeExposure(p, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user