当前位置: 首页>>代码示例>>Java>>正文


Java NbtFactory.asCompound方法代码示例

本文整理汇总了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);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:12,代码来源:PetManager.java

示例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);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:10,代码来源:PetManager.java

示例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);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:12,代码来源:PetManager.java

示例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");
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:10,代码来源:PetManager.java

示例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;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:ItemUtils.java

示例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);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:12,代码来源:ItemUtils.java

示例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);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:10,代码来源:ItemUtils.java

示例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;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:29,代码来源:ItemUtils.java

示例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;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:ItemUtils.java

示例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"));
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:6,代码来源:PetManager.java

示例11: getTag

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public NbtCompound getTag() {		
	return NbtFactory.asCompound(NbtFactory.fromItemTag(this.item));
}
 
开发者ID:FastFelix771,项目名称:TownyWands,代码行数:4,代码来源:ItemWrapper.java


注:本文中的com.comphenix.protocol.wrappers.nbt.NbtFactory.asCompound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。