> For the complete documentation index, see [llms.txt](https://itemsadder.devs.beer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itemsadder.devs.beer/adding-content/scripting/java.md).

# Java

{% hint style="warning" %}

### Warning

This scripting feature is a work-in-progress (WIP) and subject to change in future updates. Always check the latest documentation for updates and compatibility.
{% endhint %}

## `.java`

These are pure Java code classes.

Advantages:

* Pure Java, nothing new to learn for developers.
* No need to create a plugin or setup a complex IDE to code in Java.
* Compatible with VSCode debugger. You can attach the debugger easily.
* Autocomplete of libraries methods, fields etc.
* Easy to identify and fix bugs in your code.

Disadvantages:

* Requires Java knowledge.
* Requires writing package, imports, and logic methods manually (otherwise the intellisense and debugger won't work).

### Item Scripts

This script is called by item events.\
To create an item script you have to extend the ItemScript class that offers the `handleEvent` method.

```java
package iascript;

import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import dev.lone.itemsadder.api.*;
import dev.lone.itemsadder.api.scriptinginternal.*;

public class example extends ItemScript {
  public void handleEvent(Plugin plugin, Event event, Player player, CustomStack $customStack, ItemStack $itemStack) {
    // Your code...    
  }
}
```

### Entity Scripts

This script is called by entity events.\
To create an entity script you have to extend the ItemScript class that offers the `handleEvent` method.

```java
package iascript;

import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin;
import org.bukkit.entity.Player;
import dev.lone.itemsadder.api.*;
import dev.lone.itemsadder.api.scriptinginternal.*;

public class example extends EntityScript {
  public void handleEvent(Plugin plugin, Event event, Player player, CustomEntity customEntity) {
    // Your code...    
  }
}
```


---

# 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, and the optional `goal` query parameter:

```
GET https://itemsadder.devs.beer/adding-content/scripting/java.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
