本文整理汇总了Java中com.comphenix.protocol.wrappers.nbt.NbtFactory.asCompound方法的典型用法代码示例。如果您正苦于以下问题:Java NbtFactory.asCompound方法的具体用法?Java NbtFactory.asCompound怎么用?Java NbtFactory.asCompound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.comphenix.protocol.wrappers.nbt.NbtFactory
的用法示例。
在下文中一共展示了NbtFactory.asCompound方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveDeathTime
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static void saveDeathTime(ItemStack item, long deathTime) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (deathTime == 0) {
nbt.remove(DEATH_TIME_TAG);
} else {
nbt.put(DEATH_TIME_TAG, deathTime);
}
NbtFactory.setItemTag(item, nbt);
}
示例2: getDeathTime
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static long getDeathTime(ItemStack item) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item.clone()));
if (!nbt.containsKey(DEATH_TIME_TAG)) {
return 0;
}
return nbt.getLong(DEATH_TIME_TAG);
}
示例3: saveHealth
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static void saveHealth(ItemStack item, double health) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (health == 0) {
nbt.remove("pet.health");
} else {
nbt.put("pet.health", health);
}
NbtFactory.setItemTag(item, nbt);
}
示例4: getHealth
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static double getHealth(ItemStack item, double maxHealth) {
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item.clone()));
if (!nbt.containsKey("pet.health")) {
return maxHealth;
}
return nbt.getDouble("pet.health");
}
示例5: setTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack setTag(ItemStack item, String tag, String value) {
item = toBukkitItemStack(item);
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (!nbt.containsKey(tag)) {
if (UNBREAKABLE_TAG.equals(tag) || HIDE_FLAGS_TAG.equals(tag)) {
nbt.put(tag, Integer.parseInt(value));
} else {
nbt.put(tag, value);
}
}
NbtFactory.setItemTag(item, nbt);
return item;
}
示例6: getTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
@SuppressWarnings("WeakerAccess")
public static String getTag(ItemStack item, String tag, @Nullable String defaultValue) {
item = toBukkitItemStack(item);
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (!nbt.containsKey(tag)) {
return defaultValue;
}
return nbt.getString(tag);
}
示例7: hasTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static boolean hasTag(@Nullable ItemStack originalItem, String tag) {
if (originalItem == null || !originalItem.hasItemMeta()) {
return false;
}
ItemStack item = toBukkitItemStack(originalItem.clone());
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
return nbt.containsKey(tag);
}
示例8: getTexturedItem
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
@NotNull
public static ItemStack getTexturedItem(String texture) {
String[] textures = texture.split(":");
if (Material.getMaterial(textures[0]) == null) {
RPGInventory.getPluginLogger().warning("Material " + textures[0] + " not found");
return new ItemStack(Material.AIR);
}
ItemStack item = new ItemStack(Material.getMaterial(textures[0]));
if (textures.length == 2) {
if (item.getType() == Material.MONSTER_EGG) {
item = toBukkitItemStack(item);
NbtCompound nbt = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
nbt.put("EntityTag", NbtFactory.ofCompound("temp").put("id", textures[1]));
} else {
item.setDurability(Short.parseShort(textures[1]));
if (isItemHasDurability(item)) {
item = setTag(item, UNBREAKABLE_TAG, "1");
item = setTag(item, HIDE_FLAGS_TAG, "63");
}
}
}
return item;
}
示例9: itemStackToNBT
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static NbtCompound itemStackToNBT(ItemStack originalItem, String name) {
NbtCompound nbt = NbtFactory.ofCompound(name);
nbt.put("material", originalItem.getType().name());
nbt.put("amount", originalItem.getAmount());
nbt.put("data", originalItem.getDurability());
ItemStack item = toBukkitItemStack(originalItem.clone());
NbtCompound tag = ItemUtils.isEmpty(item) ? null : NbtFactory.asCompound(NbtFactory.fromItemTag(item));
if (tag != null) {
nbt.put("tag", tag);
}
return nbt;
}
示例10: addGlow
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
static void addGlow(ItemStack itemStack) {
itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 88);
NbtCompound compound = NbtFactory.asCompound(NbtFactory.fromItemTag(itemStack));
compound.put(NbtFactory.ofList("ench"));
}
示例11: getTag
import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public NbtCompound getTag() {
return NbtFactory.asCompound(NbtFactory.fromItemTag(this.item));
}