mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Quick soulbound key to speed this up
This commit is contained in:
parent
c3c23a683a
commit
8795900ec6
@ -67,7 +67,6 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
ItemMeta enchMeta = ench.getItemMeta();
|
ItemMeta enchMeta = ench.getItemMeta();
|
||||||
List<String> lore = enchMeta.hasLore() ? enchMeta.getLore() : new ArrayList<>();
|
|
||||||
|
|
||||||
// This lightning is just an effect, it deals no damage.
|
// This lightning is just an effect, it deals no damage.
|
||||||
l.getWorld().strikeLightningEffect(l);
|
l.getWorld().strikeLightningEffect(l);
|
||||||
@ -80,9 +79,8 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
|
|||||||
l.getWorld().createExplosion(l, 0.0F);
|
l.getWorld().createExplosion(l, 0.0F);
|
||||||
l.getWorld().playSound(l, Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
l.getWorld().playSound(l, Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||||
|
|
||||||
lore.add(ChatColor.GRAY + "Soulbound");
|
SlimefunUtils.setSoulbound(ench);
|
||||||
|
|
||||||
enchMeta.setLore(lore);
|
|
||||||
ench.setItemMeta(enchMeta);
|
ench.setItemMeta(enchMeta);
|
||||||
|
|
||||||
ent.remove();
|
ent.remove();
|
||||||
|
@ -2,15 +2,18 @@ package io.github.thebusybiscuit.slimefun4.utils;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta;
|
import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
||||||
@ -36,6 +39,8 @@ public final class SlimefunUtils {
|
|||||||
private static final String SOULBOUND_LORE = ChatColor.GRAY + "Soulbound";
|
private static final String SOULBOUND_LORE = ChatColor.GRAY + "Soulbound";
|
||||||
private static final String NO_PICKUP_METADATA = "no_pickup";
|
private static final String NO_PICKUP_METADATA = "no_pickup";
|
||||||
|
|
||||||
|
private static final NamespacedKey SOULBOUND_KEY = new NamespacedKey(SlimefunPlugin.instance, "soulbound");
|
||||||
|
|
||||||
private SlimefunUtils() {}
|
private SlimefunUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +80,9 @@ public final class SlimefunUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (PersistentDataAPI.getOptionalBoolean(item.getItemMeta(), SOULBOUND_KEY).isPresent())
|
||||||
|
return true;
|
||||||
|
|
||||||
SlimefunItem backpack = SlimefunItems.BOUND_BACKPACK.getItem();
|
SlimefunItem backpack = SlimefunItems.BOUND_BACKPACK.getItem();
|
||||||
|
|
||||||
if (backpack != null && backpack.isItem(item)) {
|
if (backpack != null && backpack.isItem(item)) {
|
||||||
@ -104,6 +112,16 @@ public final class SlimefunUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setSoulbound(@Nonnull ItemStack item) {
|
||||||
|
final ItemMeta meta = item.getItemMeta();
|
||||||
|
final List<String> lore = meta.getLore();
|
||||||
|
lore.add(SOULBOUND_LORE);
|
||||||
|
meta.setLore(lore);
|
||||||
|
|
||||||
|
PersistentDataAPI.setBoolean(item.getItemMeta(), SOULBOUND_KEY, true);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean containsSimilarItem(Inventory inventory, ItemStack itemStack, boolean checkLore) {
|
public static boolean containsSimilarItem(Inventory inventory, ItemStack itemStack, boolean checkLore) {
|
||||||
if (inventory == null || itemStack == null) return false;
|
if (inventory == null || itemStack == null) return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user