mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
fix: misjudgment of the attribute of radioactive items (#4198)
This commit is contained in:
parent
45601c8aef
commit
a00e4baa7f
@ -1,30 +1,26 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RadiationSymptom;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.RadioactivityListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.RadioactiveItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.RadioactivityListener;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils;
|
||||
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The {@link RadiationTask} handles radioactivity for
|
||||
@ -48,13 +44,15 @@ public class RadiationTask extends AbstractArmorTask {
|
||||
}
|
||||
|
||||
int exposureTotal = 0;
|
||||
if (!profile.hasFullProtectionAgainst(ProtectionType.RADIATION) && p.getGameMode() != GameMode.CREATIVE && p.getGameMode() != GameMode.SPECTATOR) {
|
||||
if (!profile.hasFullProtectionAgainst(ProtectionType.RADIATION)
|
||||
&& p.getGameMode() != GameMode.CREATIVE
|
||||
&& p.getGameMode() != GameMode.SPECTATOR) {
|
||||
for (ItemStack item : p.getInventory()) {
|
||||
if (item == null || item.getType().isAir()) {
|
||||
continue;
|
||||
}
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
if (sfItem instanceof RadioactiveItem radioactiveItem) {
|
||||
if (sfItem instanceof Radioactive radioactiveItem) {
|
||||
exposureTotal += item.getAmount() * radioactiveItem.getRadioactivity().getExposureModifier();
|
||||
}
|
||||
}
|
||||
@ -72,7 +70,7 @@ public class RadiationTask extends AbstractArmorTask {
|
||||
|
||||
int exposureLevelAfter = RadiationUtils.getExposure(p);
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
for (RadiationSymptom symptom : symptoms) {
|
||||
if (symptom.shouldApply(exposureLevelAfter)) {
|
||||
symptom.apply(p);
|
||||
@ -81,8 +79,11 @@ public class RadiationTask extends AbstractArmorTask {
|
||||
});
|
||||
|
||||
if (exposureLevelAfter > 0 || exposureLevelBefore > 0) {
|
||||
String msg = Slimefun.getLocalization().getMessage(p, "actionbar.radiation").replace("%level%", "" + exposureLevelAfter);
|
||||
BaseComponent[] components = new ComponentBuilder().append(ChatColors.color(msg)).create();
|
||||
String msg = Slimefun.getLocalization()
|
||||
.getMessage(p, "actionbar.radiation")
|
||||
.replace("%level%", "" + exposureLevelAfter);
|
||||
BaseComponent[] components =
|
||||
new ComponentBuilder().append(ChatColors.color(msg)).create();
|
||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user