Leaf Essentials Wiki
  • Discord
  • Contribute
  • MCBETools
  • Github
  • Home
  • Installation
  • More Projects
  • More Resources
  • Server List
Chat
  • Channels
  • Ranks Configuration
    • Legacy Ranks
      deprecated
    • Managing Ranks
  • Chat Widgets
    • Introduction to Chat Widgets
  • Chat Rank Formats
    • Introduction to Chat Formats
Customizer
  • Basics
    • Creating UIs
    • About Buttons
    • Formatting
  • Advanced
    • /leaf:render_as
      advanced
    • How to Use conditions
      advanced
    • How to Use invites
      advanced
  • Miscellaneous
    • Button Meta
      info
  • Essentials
    • Opening builtin Leaf UIs
  • Extensions
    • Button Meta Hooks
FAQ
  • FAQ - General
  • Leaf Not Working on Realms
  • Plant Kitty
Misc Features
  • World Utilities
    • Binds
    • Block Property Editor
    • Entity Property Editor
    • Zones (Old Docs)
Moderation Hub
  • Bans
Script API
  • Basics
    • Hooks
Slash Commands
  • Utilities
    • /trigger & /on
    • Inventory Saving
    • Leaf Tell
    • Persistent Points
    • Server Transferring
    • Teams
    • Weighted RNG
    • World Tags
Zones
  • Zones - Basics
  • Zones - Triggers

Button Meta Hooks

Button Meta Hooks
  • Getting Started
  • Examples

Getting Started ​

Go to customizer and create a new script

Examples ​

Basic Custom Meta Field Example
js
hook("customizer_meta:#TEST", ({buttons})=>{
  buttons.push({
    text: "Test Meta!!!!",
    icon: "textures/items/iron_sword",
    action(player) {
      player.success("Shitt worked!")
    }
  })
})
1
2
3
4
5
6
7
8
9
Resolving Icon IDs
js
icons.resolve("vanilla/iron_sword")
1
Advanced Player List Meta Field
js
// register meta field
hook("customizer_meta:#ADV_PLAYER_LIST", ({unprocessedButtonText, buttons, args, button, currView, getIcon, player, playerIsAllowed, meta, parseArgs})=>{
  for(const player2 of mc.world.getPlayers()) {
    // get config
    let json = {};
    try {
      json = JSON.parse(meta.split(' ').slice(1).join(' '))
    } catch {}

    // conditions
    if(json.excludeSelf && player.id == player2.id) continue;
    if(json.requiredTag2 && !player2.hasTag(json.requiredTag2)) continue;
    if(button.requiredTag && !playerIsAllowed(player, formatStr(button.requiredTag, player, {}, {player2: player2}))) continue;

    // add button
    buttons.push({
      text: parseArgs(formatStr(unprocessedButtonText, player, {}, {player2}), ...args),
      icon: icons.resolve(getIcon(button.iconID, button.iconOverrides, player2)),
      currView, // for view separator support
      action: (player)=>{
        // security
        if(button.disabled) return;

        // run actions
        for(const action of button.actions) {
          let result = actionParser.runAction(player, parseArgs(formatStr(action, player, {}, {player2}), ...args))
          if(!result && button.conditionalActions) break;
        }
      }
    })
  }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

Contributors

Edit Button Meta Hooks on GitHub