Package pers.neige.neigeitems.hook.nms
Class NMSHooker
-
- All Implemented Interfaces:
public class NMSHooker
-
-
Constructor Summary
Constructors Constructor Description NMSHooker()
-
Method Summary
Modifier and Type Method Description boolean
hasCustomModelData(@Nullable() ItemMeta itemMeta)
检测 ItemMeta 是否存在 CustomModelData. Integer
getCustomModelData(@Nullable() ItemMeta itemMeta)
获取 ItemMeta 中的 CustomModelData. void
setCustomModelData(@Nullable() ItemMeta itemMeta, int data)
设置 ItemMeta 中的 CustomModelData. NamespacedKey
getNamespacedKey(Material material)
通过物品材质, 获取 NamespacedKey. Item
dropItem(@NonNull() World world, @NonNull() Location location, @NonNull() ItemStack itemStack, @NonNull() Consumer<Item> function)
在指定世界的指定坐标生成一个掉落物, 生成实体前对实体进行一些操作. HoverEvent
hoverText(@NonNull() String text)
根据给定的文本生成一个 HoverEvent. HoverEvent
hoverItem(@NonNull() ItemStack itemStack)
根据给定的物品生成一个 HoverEvent. ItemBuilder
newItemBuilder()
ItemBuilder
newItemBuilder(@Nullable() Material material)
ItemBuilder
newItemBuilder(@Nullable() ItemStack itemStack)
ItemBuilder
newItemBuilder(@Nullable() ConfigReader config)
Material
getMaterial(@Nullable() String material)
等效于Material#getMaterial, 但为1.12.2版本添加了数字ID处理. void
giveExp(@NonNull() Player player, int exp)
给予玩家经验, 修复了1.12.2的逻辑谬误. ConfigurationSection
save(@Nullable() ItemStack itemStack)
将物品保存为NI可识别的配置文件, 性能较差, 不建议于性能敏感处使用. -
-
Method Detail
-
hasCustomModelData
boolean hasCustomModelData(@Nullable() ItemMeta itemMeta)
检测 ItemMeta 是否存在 CustomModelData. 对于不存在 CustomModelData 的版本, 将永远返回 false.
- Parameters:
itemMeta
- 待操作 ItemMeta- Returns:
是否存在 CustomModelData
-
getCustomModelData
@Nullable() Integer getCustomModelData(@Nullable() ItemMeta itemMeta)
获取 ItemMeta 中的 CustomModelData. 如果 ItemMeta 中不存在 CustomModelData, 将返回 null. 对于不存在 CustomModelData 的版本, 将永远返回 null.
- Parameters:
itemMeta
- 待操作 ItemMeta- Returns:
是否存在 CustomModelData
-
setCustomModelData
void setCustomModelData(@Nullable() ItemMeta itemMeta, int data)
设置 ItemMeta 中的 CustomModelData. 对于不存在 CustomModelData 的版本, 将等同于空方法.
- Parameters:
itemMeta
- 待操作 ItemMeta
-
getNamespacedKey
NamespacedKey getNamespacedKey(Material material)
通过物品材质, 获取 NamespacedKey.
- Parameters:
material
- 待获取材质
-
dropItem
@Deprecated()@NonNull() Item dropItem(@NonNull() World world, @NonNull() Location location, @NonNull() ItemStack itemStack, @NonNull() Consumer<Item> function)
在指定世界的指定坐标生成一个掉落物, 生成实体前对实体进行一些操作.
- Parameters:
world
- 待掉落世界.location
- 待掉落坐标.itemStack
- 待掉落物品.function
- 掉落前对物品执行的操作.- Returns:
生成的掉落物.
-
hoverText
@NonNull() HoverEvent hoverText(@NonNull() String text)
根据给定的文本生成一个 HoverEvent.
- Parameters:
text
- 待操作物品.- Returns:
生成的 HoverEvent.
-
hoverItem
@NonNull() HoverEvent hoverItem(@NonNull() ItemStack itemStack)
根据给定的物品生成一个 HoverEvent.
- Parameters:
itemStack
- 待操作物品.- Returns:
生成的 HoverEvent.
-
newItemBuilder
@NonNull() ItemBuilder newItemBuilder()
-
newItemBuilder
@NonNull() ItemBuilder newItemBuilder(@Nullable() Material material)
-
newItemBuilder
@NonNull() ItemBuilder newItemBuilder(@Nullable() ItemStack itemStack)
-
newItemBuilder
@NonNull() ItemBuilder newItemBuilder(@Nullable() ConfigReader config)
-
getMaterial
@Nullable() Material getMaterial(@Nullable() String material)
等效于Material#getMaterial, 但为1.12.2版本添加了数字ID处理.
-
giveExp
void giveExp(@NonNull() Player player, int exp)
给予玩家经验, 修复了1.12.2的逻辑谬误.
- Parameters:
player
- 接收经验的玩家.exp
- 经验数量.
-
save
@Nullable() ConfigurationSection save(@Nullable() ItemStack itemStack)
将物品保存为NI可识别的配置文件, 性能较差, 不建议于性能敏感处使用.
- Parameters:
itemStack
- 待转换物品.- Returns:
NI可识别的配置文件
-
-
-
-