Code Conventions

Separate complex Skript expressions from skript-mirror calls

Combining Skript expressions with skript-mirror calls may make your code difficult to read. Use variables to separate these different types of calls.

(the player's targeted block).breakNaturally()
set {_target} to the player's targeted block
{_target}.breakNaturally()

Keep the target of a skript-mirror call grouped

When calling a method or accessing a field, avoid using spaces when possible.

the event.getPlayer()
event.getPlayer()

If the expression is simple (i.e. does not contain other expressions) but requires a space, surround the expression in parentheses.

spawned creeper.isPowered()
(spawned creeper).isPowered()

If the target of the expression is not simple (i.e. contains other expressions), extract the expression into a local variable. (rule)

Variables are the exception to this rule and may contain spaces and/or other expressions

{my script::%player%::pet}.isDead()

Avoid aliasing classes for aesthetic purposes

The purpose of import aliases is to avoid conflicts with other imports and expressions. Do not alias imports in order to make them look like Skript events.

import:
  org.bukkit.event.player.PlayerMoveEvent as move
  
on move:
  # code
import:
   org.bukkit.event.player.PlayerMoveEvent

on PlayerMoveEvent:
  # code

Avoid unnecessary uses of Java reflection

Especially when copying Java code and translating it for skript-mirror, you may run into instances where you need to use reflection to access a private method, field, or constructor. In skript-mirror, private members are visible and accessible by default.

set {_mod count field} to {_map}.getClass().getDeclaredField("modCount")
{_mod count field}.setAccessible(true)
set {_mod count} to {_mod count field}.get({_map})
set {_mod count} to {_map}.modCount!

Last updated