> For the complete documentation index, see [llms.txt](https://thisistails.gitbook.io/tailslib/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thisistails.gitbook.io/tailslib/tailslib-rus/custom-items/item-manager.md).

# Item manager

## Access the manager

To access item manager you can use:

```java
CustomItemManager.getManager(); // Shortcut of second version.
// OR
Managers.getCustomItemManager();
```

## About manager

Manager uses Optional for minimizing NullPointerException moments. If you don't know how Optional works in this page you gonna understand it.

## Finding and getting the item

To get the CustomItem object you can use this:

```java
CustomItemManager manager = CustomItemManager.getManager();
manager.customItem("ID").ifPresent((item) -> {
    // Some code
});
// OR
CustomItem item = manager.customItem("ID").orElse(null); // If you don't like lambda
```

If we talk about runtime object of custom items:

```java
ItemStack item = // some item here
CustomItemManager manager = CustomItemManager.getManager();
manager.tryGetCustomItem(item).ifPresent((runtime) -> {
    // Code here
});
// OR
// If you don't like lambda
CustomItemRuntime runtime = manager.tryGetCustomItem(item).orElse(null);
```

## Creating ItemStack

To create ItemStack we need CustomItem object and manager:

```java
CustomItemManager manager = CustomItemManager.getManager();
manager.customItem("ID").ifPresent((item) -> {
    ItemStack itemStack = manager.createItem(item);
    // Code here
});
// OR
CustomItem item = manager.customItem("ID").orElse(null); // If you don't like lambda
if (item != null) {
    ItemStack itemStack = manager.createItem(item);
}
```

## Checking if item is custom

```java
CustomItemManager manager = CustomItemManager.getManager();
boolean check = manager.isCustomItem(itemStack); // recomended
// OR
boolean check = manager.tryGetCustomItem(itemStack).isPresent();
```

## Register the item

```java
CustomItemManager.getManager().register(new MyItem());
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://thisistails.gitbook.io/tailslib/tailslib-rus/custom-items/item-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
