Fixed #1377 keep-on-death

This commit is contained in:
Jules 2023-11-05 23:11:34 +01:00
parent 152518532c
commit 86d1e18baa
2 changed files with 8 additions and 5 deletions

View File

@ -11,9 +11,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.Validate;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Entity;
@ -41,6 +39,11 @@ public class MMOUtils {
return particle.getDataType() == Particle.DustOptions.class;
}
public static boolean isSoulboundTo(@NotNull NBTItem item, @NotNull Player player) {
final @Nullable String foundNbt = item.getString("MMOITEMS_SOULBOUND");
return foundNbt != null && foundNbt.contains(player.getUniqueId().toString());
}
/**
* Should cancel interaction if one of the two cases:
* - the item type no longer exists

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.interaction.util.InteractItem;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.DeathDowngrading;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
@ -41,7 +42,7 @@ public class PlayerListener implements Listener {
if (!PlayerData.has(event.getEntity())) return;
// See description of DelayedDeathDowngrade child class for full explanation
(new DelayedDeathDowngrade(event)).runTaskLater(MMOItems.plugin, 3L);
new DelayedDeathDowngrade(event).runTaskLater(MMOItems.plugin, 3L);
}
/**
@ -67,8 +68,7 @@ public class PlayerListener implements Listener {
* using a JsonParser followed by map checkups in the SoulboundData
* constructor
*/
if ((MMOItems.plugin.getLanguage().keepSoulboundOnDeath && nbt.getBoolean("MMOITEMS_DISABLE_DEATH_DROP"))
|| (nbt.hasTag("MMOITEMS_SOULBOUND") && nbt.getString("MMOITEMS_SOULBOUND").contains(player.getUniqueId().toString()))) {
if (nbt.getBoolean("MMOITEMS_DISABLE_DEATH_DROP") || (MMOItems.plugin.getLanguage().keepSoulboundOnDeath && MMOUtils.isSoulboundTo(nbt, player))) {
iterator.remove();
soulboundInfo.registerItem(item);
}