> For the complete documentation index, see [llms.txt](https://temp-17.gitbook.io/trmenu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://temp-17.gitbook.io/trmenu/script/scripts.md).

# Scripts

## Objects

| Name         | Description                                                           |
| ------------ | --------------------------------------------------------------------- |
| player       | The player object: org.bukkit.entity.Player                           |
| bukkitServer | The server object: Bukkit.getServer()                                 |
| utils        | Assist Utils (TrUtils): me.arasple.mc.trmenu.utils.Assist (see below) |

## Example

```kotlin
Buttons!
  '*':
    update: [-1, 5, 20, -1]
    display:
      material: <skull:9842dc3b917b1a796c303e15105474a8e315de7982b6ca54feafb5a4d13d4e95>
      name:
        - '&3&lSERVER'
        - '&b&lSE&3&lRVER'
        - '&3&lS&b&lER&3&lVER'
        - '&3&lSE&b&lRV&3&lER'
        - '&3&lSER&b&lVE&3&lR'
        - '&3&lSERV&b&lER'
      lore:
        - ''
        - '&8| &7RAM: &2%server_ram_used%/%server_ram_total% &7MB'
        - '&8[ %progress_bar_{server_ram_used}_m:{server_ram_total}_c:&3■_p:&7■_r:&8■_l:20% &8]'
        - ''
        - '&b${flash_➥} &3Left-Click &7to open the help menu.'
    actions:
      left:
        - 'open: help'

Functions:
  flash: |-
    function flash() {
      var display = new Date().getSeconds() % 2 == 0
      return display ? "{0}" : "  "
    }
    flash()
```

## Assist Utils (TrUtils)

```kotlin
package me.arasple.mc.trmenu.utils

import io.izzel.taboolib.internal.apache.lang3.math.NumberUtils
import io.izzel.taboolib.module.compat.EconomyHook
import io.izzel.taboolib.module.tellraw.TellrawJson
import io.izzel.taboolib.util.item.ItemBuilder
import io.izzel.taboolib.util.item.Items
import io.izzel.taboolib.util.lite.Numbers
import me.arasple.mc.trmenu.data.MetaPlayer.getArguments
import me.arasple.mc.trmenu.modules.action.Actions
import me.arasple.mc.trmenu.modules.hook.HookCronus
import me.arasple.mc.trmenu.modules.hook.HookPlayerPoints
import me.arasple.mc.trmenu.modules.item.ItemIdentifierHandler
import me.arasple.mc.trmenu.modules.web.WebData
import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.*
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack


/**
 * @author Arasple
 * @date 2020/7/21 20:57
 */
class Assist {

    fun runAction(player: Player, vararg actions: String) = actions.filter { it.isNotBlank() }.forEach { Actions.runCachedAction(player, it) }

    fun parseBracketPlaceholders(player: OfflinePlayer, string: String): String = PlaceholderAPI.setBracketPlaceholders(player, string)

    fun connect(player: Player, server: String) = Bungees.connect(player, server)

    fun sendBungeeData(player: Player, vararg data: String) = Bungees.sendBungeeData(player, *data)

    fun getPlayerArgs(player: String): Array<String> = getPlayer(player)?.getArguments() ?: arrayOf()

    fun isPlayerOperator(player: String) = getPlayer(player).let { return@let it != null && it.isOp }

    fun isPlayerOnline(player: String) = getPlayer(player).let { return@let it != null && it.isOnline }

    fun getPlayer(player: String): Player? = Bukkit.getPlayerExact(player)

    fun getOnlinePlayers(): Collection<Player> = Bukkit.getOnlinePlayers()

    @ExperimentalStdlibApi
    fun getRandomPlayer(): Player? = Bukkit.getOnlinePlayers().randomOrNull()

    fun getItemBuildr(): ItemBuilder = ItemBuilder(Material.STONE)

    fun getTellraw(): TellrawJson = TellrawJson.create()

    fun emptyString(length: Int) = buildString {
        for (i in 0..length) append(" ")
    }

    fun equalsIgnoreCase(sample: String, temp: String) = sample.equals(temp, true)

    fun chance(number: String) = Numbers.random(NumberUtils.toDouble(number, 0.0))

    fun randomInteger(low: Int, high: Int): Int = IntRange(low, high).random()

    fun randomDouble(low: Double, high: Double) = Numbers.getRandomDouble(low, high)

    fun isNumber(number: String) = NumberUtils.isParsable(number)

    fun isInt(number: String) =
        try {
            number.toInt()
            true
        } catch (e: Throwable) {
            false
        }


    fun toInt(number: String) = NumberUtils.toInt(number, -1)

    fun toDouble(number: String) = NumberUtils.toDouble(number, -1.0)

    fun isWithin(input: String, low: String, high: String) = IntRange(low.toInt(), high.toInt()).contains(input.toInt())

    fun isSmaller(input1: String, input2: String) = NumberUtils.toDouble(input1) < NumberUtils.toDouble(input2)

    fun isSmallerOrEqual(input1: String, input2: String) = NumberUtils.toDouble(input1) <= NumberUtils.toDouble(input2)

    fun isGreater(input1: String?, input2: String?) = NumberUtils.toDouble(input1) > NumberUtils.toDouble(input2)

    fun isGreaterOrEqual(input1: String?, input2: String?) = NumberUtils.toDouble(input1) >= NumberUtils.toDouble(input2)

    fun createLocation(world: String?, x: Double, z: Double): Location? {
        val y = Bukkit.getWorld(world!!)!!.getHighestBlockYAt(x.toInt(), z.toInt()).toDouble()
        return createLocation(world, x, y, z)
    }

    fun createLocation(world: String?, x: Double, y: Double, z: Double): Location? {
        return createLocation(world, x, y, z, 0f, 0f)
    }

    fun createLocation(world: String?, x: Double, y: Double, z: Double, yaw: Float, pitch: Float): Location? {
        return Location(Bukkit.getWorld(world!!), x, y, z, yaw, pitch)
    }

    fun createLocation(world: World, x: Double, z: Double): Location? {
        val y = world.getHighestBlockYAt(x.toInt(), z.toInt()).toDouble()
        return createLocation(world, x, y, z)
    }

    fun createLocation(world: World?, x: Double, y: Double, z: Double): Location? {
        return createLocation(world, x, y, z, 0f, 0f)
    }

    fun createLocation(world: World?, x: Double, y: Double, z: Double, yaw: Float, pitch: Float): Location? {
        return Location(world, x, y, z, yaw, pitch)
    }

    fun hasMoney(player: Player, money: String) = hasMoney(player, NumberUtils.toDouble(money, 0.0))

    fun hasMoney(player: Player, money: Double) = EconomyHook.get(player) >= money

    fun hasPoints(player: Player, points: String) = hasPoints(player, NumberUtils.toInt(points, 0))

    fun hasPoints(player: Player, points: Int) = HookPlayerPoints.hasPoints(player, points)

    fun getItemName(itemStack: ItemStack): String = Items.getName(itemStack)

    fun query(url: String) = WebData.query(url)

    fun hasItem(player: String, identify: String) = getPlayer(player)?.let { ItemIdentifierHandler.read(identify).hasItem(it) } ?: false

    fun hasItem(player: Player, identify: String) = ItemIdentifierHandler.read(identify).hasItem(player)

    fun evalCronusCondition(player: String, condition: String) = getPlayer(player)?.let { return@let evalCronusCondition(it, condition) } ?: false

    fun evalCronusCondition(player: Player, condition: String) = HookCronus.parseCondition(condition).check(player)

    companion object {

        val INSTANCE = Assist()

    }


}
```


---

# 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:

```
GET https://temp-17.gitbook.io/trmenu/script/scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
