skript-reflect
2.x
2.x
  • skript-reflect
  • Getting Started
  • Basics
    • Reading Javadocs
    • Importing classes
    • Running Java code
    • Handling events
    • Utilities
  • Advanced
    • Error handling
    • Loading external libraries
    • Custom syntax
      • Effects
      • Conditions
      • Expressions
      • Events
    • Computed Options
    • Reflection
      • Proxies
      • Sections
    • Experiments
  • Code Conventions
  • Frequently Asked Questions
Powered by GitBook
On this page
  • Calling methods
  • Calling non-public methods
  • Calling overloaded methods
  • Calling fields
  • Calling non-public fields
  • Calling constructors

Was this helpful?

  1. Basics

Running Java code

Calling methods

%object%.<method name>(%objects%)
event-block.breakNaturally()
(last spawned creeper).setPowered(true)
player.giveExpLevels({_levels})

Methods may be used as effects, expressions, and conditions. If used as a condition, the condition will pass as long as the return value of the method is not false, null, or 0.

Calling non-public methods

If the method you're trying to invoke is not public, you may have to prefix the method name with the declaring class in brackets. Since an object may have a non-public method with the same name in multiple superclasses, you must explicitly specify where to find the method.

{_arraylist}.[ArrayList]fastRemove(1)

Calling overloaded methods

Generally, skript-reflect can infer the correct overloaded method to call from the arguments passed at runtime. If you need to use a certain implementation of a method, you may append a comma separated list to the end of the method name surrounded in brackets.

System.out.println[Object]({_something})

Math.max[int, int](0, {_value})

Calling fields

%object%.<descriptor>

Calling non-public fields

If the field you're trying to access is not public, you may have to prefix the field name with the declaring class in brackets. Since an object may have a non-public field with the same name in multiple superclasses, you must explicitly specify where to find the field.

{_hashmap}.[HashMap]modCount

Calling constructors

[a] new %javatype%(%objects%)
new Location(player's world, 0, 0, 0)
PreviousImporting classesNextHandling events

Last updated 3 years ago

Was this helpful?