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


Java NbtFactory.fromItemTag方法代码示例

本文整理汇总了Java中com.comphenix.protocol.wrappers.nbt.NbtFactory.fromItemTag方法的典型用法代码示例。如果您正苦于以下问题:Java NbtFactory.fromItemTag方法的具体用法?Java NbtFactory.fromItemTag怎么用?Java NbtFactory.fromItemTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.comphenix.protocol.wrappers.nbt.NbtFactory的用法示例。


在下文中一共展示了NbtFactory.fromItemTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isExploit

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public boolean isExploit(ItemStack stack) {
    try {
        if (stack == null) {
            return false;
        }
        if (stack.getType() == Material.SKULL || stack.getType() == Material.SKULL_ITEM) {
            // Check human
            if (stack.getDurability() == 3) {
                NbtCompound tag = (NbtCompound) NbtFactory.fromItemTag(stack);
                if (isExploit(tag)) {
                    return true;
                }
            }
        }
    } catch (Exception e) {
        //nbt read error
    }
    return false;
}
 
开发者ID:MylesIsCool,项目名称:SkullExploitPatch,代码行数:20,代码来源:SkullExploitPatch.java

示例2: setSkullTexture

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack setSkullTexture(ItemStack itemStack, String value) {
    ItemStack newStack = itemStack;
    if (!MinecraftReflection.isCraftItemStack(itemStack)) {
        newStack = MinecraftReflection.getBukkitItemStack(itemStack);
    }

    NbtCompound tag = (NbtCompound) NbtFactory.fromItemTag(newStack);
    NbtCompound skullOwner = NbtFactory.ofCompound("SkullOwner");
    NbtCompound properties = NbtFactory.ofCompound("Properties");

    NbtCompound compound = NbtFactory.ofCompound("");
    compound.put("Value", value);

    NbtList<NbtCompound> textures = NbtFactory.ofList("textures", compound);
    properties.put(textures);
    skullOwner.put("Id", UUID.randomUUID().toString());
    skullOwner.put(properties);
    tag.put(skullOwner);

    NbtFactory.setItemTag(newStack, tag);
    return newStack;
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:23,代码来源:SkullUtils.java

示例3: removeAttributes

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private static ItemStack removeAttributes(ItemStack item) {
	if (!MinecraftReflection.isCraftItemStack(item)) {
		item = MinecraftReflection.getBukkitItemStack(item);
	}
	try {
		NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(item);
		compound.put(NbtFactory.ofList("AttributeModifiers"));
	} catch (IllegalArgumentException e) {
		return item;
	}
	return item;
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:13,代码来源:ItemStackGenerator.java

示例4: Attributes

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public Attributes(ItemStack stack)
{
	// Create a CraftItemStack (under the hood)
	this.stack = MinecraftReflection.getBukkitItemStack(stack);
	// Load NBT
	NbtCompound nbt = (NbtCompound) NbtFactory.fromItemTag(this.stack);
	attributes = nbt.getListOrDefault("AttributeModifiers");
	attributes.setElementType(NbtType.TAG_COMPOUND);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:10,代码来源:Attributes.java

示例5: addGlow

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private static void addGlow(ItemStack[] stacks) {
	for (ItemStack stack : stacks) {
		if (stack != null) {
			// Only update those stacks that have our flag enchantment
			if (stack.getEnchantmentLevel(Enchantment.SILK_TOUCH) == 32) {
				NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(stack);
				compound.put(NbtFactory.ofList("ench"));
			}
		}
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:12,代码来源:Util.java

示例6: removeAttributes

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
public static ItemStack removeAttributes(ItemStack item) {
    if (!MinecraftReflection.isCraftItemStack(item)) {
        item = MinecraftReflection.getBukkitItemStack(item);
    }
    NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(item);
    compound.put(NbtFactory.ofList("AttributeModifiers"));
    return item;
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:9,代码来源:RPProtocolLib.java

示例7: addGlow

import com.comphenix.protocol.wrappers.nbt.NbtFactory; //导入方法依赖的package包/类
private void addGlow(ItemStack[] stacks) {
	for (ItemStack stack : stacks) {
		if (stack != null && stack.hasItemMeta()) {
			if(stack.containsEnchantment(GLOW_ENCHANT_INDICATOR) && stack.getEnchantmentLevel(GLOW_ENCHANT_INDICATOR) == GLOW_ENCHANT_LEVEL){
				// If our custom enchant exists and is set to the appropriate value, overwrite enchantment glow so it will render as glow w/o enchants
				NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(stack);
				compound.put(NbtFactory.ofList("ench"));
				NbtFactory.setItemTag(stack, compound);
			}
		}
	}
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:13,代码来源:ProtocolLibUtilImplementation.java


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