Tags


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 as java@<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 Java String becomes an ElementTag).

  • <JavaObjectTag.class_name> Returns the fully qualified class name of the held object.

Tags on UtilTagBase

  • <UtilTagBase.import[<class_name>(<constructor>)]> Similar to the import command.

Example of use
// returns "two coconuts"
<util.import[java.lang.String(two coconuts)].interpret>

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>

Last updated