Object ItemUtils
-
- All Implemented Interfaces:
public class ItemUtils
物品相关工具类
-
-
Method Summary
Modifier and Type Method Description final static String
getName(ItemStack $self)
根据物品获取显示名, 无显示名则返回翻译名. final static NbtCompound
toNbtCompound(Map<?, ?> $self)
HashMap 转 NbtCompound final static NbtCompound
toNbtCompound(ConfigurationSection $self)
ConfigurationSection 转 NbtCompound final static NbtCompound
toNbtCompound(ConfigReader $self)
ConfigReader 转 NbtCompound final static Object
cast(String $self)
类型强制转换 用于解析 NeigeItems 物品 NBT 配置中的类型强制转换 final static Object
cast(Object $self)
类型强制转换 用于解析 NeigeItems 物品 NBT 配置中的类型强制转换 final static Nbt<?>
castToNbt(String $self)
类型强制转换 用于解析 NeigeItems 物品 NBT 配置中的类型强制转换 final static Nbt<?>
toNbt(Object $self)
将任意值转换为对应的 NBT final static HashMap<String, Object>
toStringMap(NbtCompound $self)
将 NbtCompound 转换为 Map, 其中所有值都被转换为 String 的形式, 形似 (Int) 1 final static Object
toStringValue(Nbt<?> $self)
将 Nbt 转换为 String, List<String> 或 Map<String, String> , 形似 (Int) 1 final static HashMap<String, Object>
toMap(NbtCompound $self, List<String> invalidNBT)
将 NbtCompound 转换为 Map final static HashMap<String, Object>
toMap(NbtCompound $self)
将 NbtCompound 转换为 Map final static Object
toValue(Nbt<?> $self)
将 Nbt 解析为对应的值 final static NbtCompound
getNbt(ItemStack $self)
获取物品NBT final static NbtCompound
getNbtOrNull(ItemStack $self)
获取物品NBT(无nbt则返回null) final static NbtComponentLike
getDirectTag(ItemStack $self)
获取物品NBT(无nbt则返回null) final static NbtItemStack
toNbtItemStack(ItemStack $self)
获取NBT物品 final static ItemStack
copy(ItemStack $self)
获取物品复制 final static ItemStack
asBukkitCopy(ItemStack $self)
获取CraftItemStack形式的物品复制 final static ItemStack
asCraftCopy(ItemStack $self)
获取ItemStack形式的物品复制 final static Boolean
isCraftItem(ItemStack $self)
检测ItemStack是否属于CraftItemStack final static String
getItemName(ItemStack itemStack)
获取物品显示名, 这个方法的意义在于, 方便让js脚本调用 final static Unit
dropNiItems(Location $self, ItemStack itemStack, Integer amount, Entity entity)
掉落指定数量NI物品并触发掉落技能及掉落归属 final static CompletableFuture<Item>
dropNiItem(Location $self, ItemStack itemStack, Entity entity, NbtCompound itemTag, NbtCompound neigeItems)
掉落NI物品并触发掉落技能及掉落归属 final static ItemInfo
isNiItem(ItemStack $self)
判断ItemStack是否为NI物品并返回NI物品信息 final static ItemInfo
isNiItem(ItemStack $self, Boolean parseData)
判断ItemStack是否为NI物品并返回NI物品信息 final static String
getItemId(ItemStack $self)
根据ItemStack获取对应的NI物品ID final static ArrayList<ItemStack>
getItems(ItemStack $self, Integer amount)
根据数量将物品超级加倍, 返回一个列表 final static Unit
loadItems(ArrayList<ItemStack> items, List<String> itemInfos, Player player)
用于兼容旧版本API final static Unit
loadItems(ArrayList<ItemStack> items, List<String> itemInfos, Player player, Map<String, String> cache, ConfigurationSection sections)
用于兼容旧版本API final static Unit
loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player, Map<String, String> cache, ConfigurationSection sections)
用于兼容旧版本API final static Unit
loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player)
根据信息加载物品 final static Unit
loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player, Map<String, String> cache, ConfigurationSection sections, Boolean parse)
根据信息加载物品 final static ArrayList<ItemStack>
loadItems(List<String> itemInfos, OfflinePlayer player)
根据信息加载物品 final static ArrayList<ItemStack>
loadItems(String info, OfflinePlayer player)
根据信息加载物品 final static Unit
loadItems(ArrayList<ItemStack> items, String info, OfflinePlayer player)
根据信息加载物品 final static Unit
dropItems(List<ItemStack> dropItems, Location location, Entity entity, String offsetXString, String offsetYString, String angleType)
根据信息进行物品掉落 final static Vector
getCaughtVelocity(Location caughtLocation, Location playerLocation)
计算钓鱼产物到钓鱼者之间的需要产生的向量 final static Unit
putDeepWithList(NbtCompound $self, String key, Nbt<?> value, Character escape, Character separator)
向NbtCompound中插入一个值(key默认以.作分隔, 默认以\转义, 如果key可以转换成Int, 就认为你当前层级是一个NbtList, 而非NbtCompound). final static Unit
saveToSafe(NbtCompound $self, ItemStack itemStack)
如果物品不是CraftItemStack则将NBT应用到物品上. final static Unit
removeOwnerNbt(ItemStack $self)
移除物品上用于记录NI物品拥有者的NBT. final static Unit
setDamage(ItemStack $self, Short damage)
设置物品损伤值, 在1.13到1.20.4版本中拥有更佳的性能表现. final static Short
getDamage(ItemStack $self)
获取物品损伤值, 在1.13到1.20.4版本中拥有更佳的性能表现. -
-
Method Detail
-
toNbtCompound
final static NbtCompound toNbtCompound(Map<?, ?> $self)
HashMap 转 NbtCompound
- Returns:
转换结果
-
toNbtCompound
final static NbtCompound toNbtCompound(ConfigurationSection $self)
ConfigurationSection 转 NbtCompound
- Returns:
转换结果
-
toNbtCompound
final static NbtCompound toNbtCompound(ConfigReader $self)
ConfigReader 转 NbtCompound
- Returns:
转换结果
-
castToNbt
final static Nbt<?> castToNbt(String $self)
类型强制转换 用于解析 NeigeItems 物品 NBT 配置中的类型强制转换
- Returns:
转换结果
-
toStringMap
final static HashMap<String, Object> toStringMap(NbtCompound $self)
将 NbtCompound 转换为 Map, 其中所有值都被转换为 String 的形式, 形似 (Int) 1
- Returns:
转换结果
-
toStringValue
final static Object toStringValue(Nbt<?> $self)
将 Nbt 转换为 String, List<String> 或 Map<String, String> , 形似 (Int) 1
- Returns:
转换结果
-
toMap
final static HashMap<String, Object> toMap(NbtCompound $self, List<String> invalidNBT)
将 NbtCompound 转换为 Map
- Parameters:
invalidNBT
- 不进行转换的顶层 NBT- Returns:
转换结果
-
toMap
final static HashMap<String, Object> toMap(NbtCompound $self)
将 NbtCompound 转换为 Map
- Returns:
转换结果
-
getNbt
final static NbtCompound getNbt(ItemStack $self)
获取物品NBT
- Returns:
物品NBT
-
getNbtOrNull
final static NbtCompound getNbtOrNull(ItemStack $self)
获取物品NBT(无nbt则返回null)
- Returns:
物品NBT
-
getDirectTag
final static NbtComponentLike getDirectTag(ItemStack $self)
获取物品NBT(无nbt则返回null)
- Returns:
物品NBT
-
toNbtItemStack
final static NbtItemStack toNbtItemStack(ItemStack $self)
获取NBT物品
- Returns:
NBT物品
-
copy
final static ItemStack copy(ItemStack $self)
获取物品复制
- Returns:
物品复制
-
asBukkitCopy
final static ItemStack asBukkitCopy(ItemStack $self)
获取CraftItemStack形式的物品复制
- Returns:
CraftItemStack形式的物品复制
-
asCraftCopy
final static ItemStack asCraftCopy(ItemStack $self)
获取ItemStack形式的物品复制
- Returns:
ItemStack形式的物品复制
-
isCraftItem
final static Boolean isCraftItem(ItemStack $self)
检测ItemStack是否属于CraftItemStack
- Returns:
ItemStack是否属于CraftItemStack
-
getItemName
final static String getItemName(ItemStack itemStack)
获取物品显示名, 这个方法的意义在于, 方便让js脚本调用
- Parameters:
itemStack
- 待操作物品- Returns:
物品显示名
-
dropNiItems
final static Unit dropNiItems(Location $self, ItemStack itemStack, Integer amount, Entity entity)
掉落指定数量NI物品并触发掉落技能及掉落归属
- Parameters:
itemStack
- 待掉落物品amount
- 掉落数量entity
- 掉落技能触发者
-
dropNiItem
final static CompletableFuture<Item> dropNiItem(Location $self, ItemStack itemStack, Entity entity, NbtCompound itemTag, NbtCompound neigeItems)
掉落NI物品并触发掉落技能及掉落归属
- Parameters:
itemStack
- 待掉落物品entity
- 掉落技能触发者itemTag
- 物品NBT, 用于解析NI物品数据neigeItems
- NI物品NBT- Returns:
掉落物品
-
isNiItem
final static ItemInfo isNiItem(ItemStack $self)
判断ItemStack是否为NI物品并返回NI物品信息
- Returns:
NI物品信息, 非NI物品返回null
-
isNiItem
final static ItemInfo isNiItem(ItemStack $self, Boolean parseData)
判断ItemStack是否为NI物品并返回NI物品信息
- Parameters:
parseData
- 是否将data解析为HashMap- Returns:
NI物品信息, 非NI物品返回null
-
getItemId
final static String getItemId(ItemStack $self)
根据ItemStack获取对应的NI物品ID
- Returns:
NI物品ID, 非NI物品返回null
-
getItems
final static ArrayList<ItemStack> getItems(ItemStack $self, Integer amount)
根据数量将物品超级加倍, 返回一个列表
- Parameters:
amount
- 需要的物品数量- Returns:
物品列表
-
loadItems
@Deprecated(message = "已弃用", replaceWith = @ReplaceWith(imports = {"pers.neige.neigeitems.utils.ItemUtils.loadItems", "org.bukkit.OfflinePlayer"}, expression = "loadItems(items, itemInfos, player as? OfflinePlayer, null, null, true)")) final static Unit loadItems(ArrayList<ItemStack> items, List<String> itemInfos, Player player)
用于兼容旧版本API
-
loadItems
@Deprecated(message = "已弃用", replaceWith = @ReplaceWith(imports = {"pers.neige.neigeitems.utils.ItemUtils.loadItems", "org.bukkit.OfflinePlayer"}, expression = "loadItems(items, itemInfos, player as? OfflinePlayer, cache, sections, true)")) final static Unit loadItems(ArrayList<ItemStack> items, List<String> itemInfos, Player player, Map<String, String> cache, ConfigurationSection sections)
用于兼容旧版本API
-
loadItems
@Deprecated(message = "已弃用", replaceWith = @ReplaceWith(imports = {"pers.neige.neigeitems.utils.ItemUtils.loadItems", "org.bukkit.OfflinePlayer"}, expression = "loadItems(items, itemInfos, player, cache, sections, true)")) final static Unit loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player, Map<String, String> cache, ConfigurationSection sections)
用于兼容旧版本API
-
loadItems
final static Unit loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player)
根据信息加载物品
- Parameters:
items
- 用于存储待生成物品itemInfos
- 物品信息player
- 用于解析物品的玩家
-
loadItems
final static Unit loadItems(ArrayList<ItemStack> items, List<String> itemInfos, OfflinePlayer player, Map<String, String> cache, ConfigurationSection sections, Boolean parse)
根据信息加载物品
- Parameters:
items
- 用于存储待生成物品itemInfos
- 物品信息player
- 用于解析物品的玩家cache
- 随机节点缓存sections
- 随机节点parse
- 是否解析其中的节点
-
loadItems
final static ArrayList<ItemStack> loadItems(List<String> itemInfos, OfflinePlayer player)
根据信息加载物品
- Parameters:
itemInfos
- 物品信息player
- 用于解析物品的玩家- Returns:
物品
-
loadItems
final static ArrayList<ItemStack> loadItems(String info, OfflinePlayer player)
根据信息加载物品
- Parameters:
info
- 物品信息player
- 用于解析物品的玩家- Returns:
物品
-
loadItems
final static Unit loadItems(ArrayList<ItemStack> items, String info, OfflinePlayer player)
根据信息加载物品
- Parameters:
items
- 用于存储待生成物品info
- 物品信息player
- 用于解析物品的玩家
-
dropItems
final static Unit dropItems(List<ItemStack> dropItems, Location location, Entity entity, String offsetXString, String offsetYString, String angleType)
根据信息进行物品掉落
- Parameters:
dropItems
- 掉落物列表location
- 掉落位置offsetXString
- 发射横向偏移量offsetYString
- 发射纵向偏移量angleType
- 发射角度类型
-
getCaughtVelocity
final static Vector getCaughtVelocity(Location caughtLocation, Location playerLocation)
计算钓鱼产物到钓鱼者之间的需要产生的向量
- Parameters:
caughtLocation
- 渔获坐标playerLocation
- 玩家坐标- Returns:
渔获->玩家 的向量
-
putDeepWithList
final static Unit putDeepWithList(NbtCompound $self, String key, Nbt<?> value, Character escape, Character separator)
向NbtCompound中插入一个值(key默认以.作分隔, 默认以\转义, 如果key可以转换成Int, 就认为你当前层级是一个NbtList, 而非NbtCompound). 我向前追溯500年, 向后预测500年, 也找不出比这还烂的代码了, 建议不要细看, 能用就行, 避免脏了眼睛.
- Parameters:
key
- NbtCompound键value
- Nbt值escape
- 转义符separator
- 分隔符
-
saveToSafe
final static Unit saveToSafe(NbtCompound $self, ItemStack itemStack)
如果物品不是CraftItemStack则将NBT应用到物品上.
- Parameters:
itemStack
- 待应用NBT的物品
-
removeOwnerNbt
final static Unit removeOwnerNbt(ItemStack $self)
移除物品上用于记录NI物品拥有者的NBT.
-
setDamage
final static Unit setDamage(ItemStack $self, Short damage)
设置物品损伤值, 在1.13到1.20.4版本中拥有更佳的性能表现.
- Parameters:
damage
- 损伤值
-
-
-
-