Compatibility
Minecraft: Java Edition
Platforms
Creators
Details
denizen-reflect
Allows Denizen scripts to directly interact with and manipulate Java objects.
⚠️ Attention: Denizen-Reflect is in beta.
The plugin is still being tested, so bugs and flaws are possible. Please report any errors or issues in Discord.
🔹 For now, we recommend warming up tags before active use. (temporarily)
🔹 We are aware of some shortcomings and temporary workarounds — they will be fixed in future updates.
Examples
This example shows how to shift a list by 2 using Collections.rotate().
Original: [1, 2, 3, 4, 5] → Result: [4, 5, 1, 2, 3]
RotateList:
type: task
debug: false
script:
- import java.util.Collections as:Collections
- narrate <[Collections].invoke[rotate(<list[1|2|3|4|5]>, 2)].interpret>
? — This example shows how to get all disabled slots from a Crafter.
disabledSlots:
type: task
debug: false
script:
- import org.bukkit.Location constructor:<[1].world>|<[1].x>|<[1].y>|<[1].z> as:crafter
- define crafter <[crafter].invoke[getBlock().getState()]>
#
- repeat 9 from:0 as:x:
- define disabledSlots:|:<[x].add[1]> if:<[crafter].invoke[isSlotDisabled(<[x]>)]>
Docs:
Object Types
JavaObjectTag
- Prefix:
java
- Description: A wrapper for any Java object. Can hold an instance of an object (identified as
java@<UUID>
) or a static reference to a class (identified asjava@<full.class.name>
).
Tags on JavaObjectTag
-
<JavaObjectTag.field[<field_name>]>
Returns the value of a specific field from the object or class. -
<JavaObjectTag.interpret>
Converts the held Java object back into its best-matching standard Denizen object type (eg., a JavaString
becomes anElementTag
). -
<JavaObjectTag.class_name>
Returns the fully qualified class name of the held object.
Commands
import
- Name:
import
- Syntax:
import [<class_name>] [constructor:[<param>|...]] [as:<definition_name>]
- Description: Creates a new Java object instance or gets a static class reference. Use the
constructor
argument to create a new instance. Omit it to get a static reference. - Usage:
# Get a static reference to the Bukkit class
- import org.bukkit.Bukkit as:bukkit
# Create a new ArrayList instance
- import java.util.ArrayList constructor as:my_list
invoke
- Name:
invoke
- Syntax:
invoke [<java_expression>]
- Description: Executes a full Java expression string. This is for advanced use cases or actions that don't return a value.
- Usage:
# Call a static method to log a message to console
- invoke 'org.bukkit.Bukkit.getLogger().info("Hello from Denizen!")'
Global Tags
These tags are added to all object types in Denizen.
invoke
- Tag:
<[object].invoke[<java_expression>]>
- Description: Executes a Java expression on the input object. This is the primary way to interact with Java objects. The expression can be a method call, field access, or a chain of calls.
- Returns: An
ObjectTag
representing the result of the expression. - Usage:
# Get the player's world name
- narrate <player.invoke[getWorld().getName()]>
# Get the size of a list
- narrate <list[a|b|c].invoke[size()]>
identify
- Tag:
<[object].identify>
- Description: Converts any standard Denizen object into a new, persisted
JavaObjectTag
. This is useful when you need to store a reference to an object for complex Java interactions. - Returns:
JavaObjectTag
- Usage:
# Convert a MaterialTag into a JavaObjectTag
- define my_java_material <material[stone].identify>
- narrate "Java object is: <[my_java_material]>"
# Narrates: Java object is: java@<some-uuid>