com.comphenix.protocol.wrappers.nbt.NbtBase Java Examples

The following examples show how to use com.comphenix.protocol.wrappers.nbt.NbtBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NBTUtil.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
/**
 * Sets a player profile onto the given tag
 *
 * @param nbt           the tag to set the profile to
 * @param playerProfile the profile to set
 */
public static void setPlayerProfile(NbtCompound nbt, PlayerProfile playerProfile) {
    nbt.put("Id", (playerProfile.getId() == null ? UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerProfile.getName()).getBytes()) : playerProfile.getId()).toString());
    nbt.put("Name", playerProfile.getName());
    if (!nbt.containsKey("Properties")) return;
    NbtCompound properties = nbt.getCompound("Properties");
    NbtList list = properties.getList("textures");
    Map<String, NbtBase> texture = (Map<String, NbtBase>) list.getValue(0);
    for (ProfileProperty property : playerProfile.getProperties()) {
        texture.put("name", NbtFactory.of("name", property.getValue()));
        texture.put("Signature", NbtFactory.of("Signature", property.getSignature()));
        texture.put("Value", NbtFactory.of("Value", property.getValue()));
    }
}
 
Example #2
Source File: WrapperPlayServerTileEntityData.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Retrieve the NBT data of the current tile entity.
 * @return The current tile entity.
*/
public NbtBase<?> getNbtData() {
    return handle.getNbtModifier().read(0);
}
 
Example #3
Source File: WrapperPlayServerTileEntityData.java    From PacketWrapper with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Set the NBT data of the current tile entity.
 * @param value - new value.
*/
public void setNbtData(NbtBase<?> value) {
    handle.getNbtModifier().write(0, value);
}