|
| 1 | ++++ |
| 2 | +title = "Action" |
| 3 | +weight = 4 |
| 4 | ++++ |
| 5 | + |
| 6 | +This is a button component, one that can be used to perform an action when clicked. |
| 7 | + |
| 8 | +## Common Format |
| 9 | + |
| 10 | +```yaml |
| 11 | +action-name: |
| 12 | + # The label of the button |
| 13 | + label: "Click me!" |
| 14 | + |
| 15 | + # The tooltip of the button |
| 16 | + # If the tooltip is not provided, there will be no tooltip |
| 17 | + tooltip: "This is a tooltip" |
| 18 | + |
| 19 | + # The width of the button |
| 20 | + # If the width is not provided, it will default to 150 |
| 21 | + width: 150 |
| 22 | +``` |
| 23 | +
|
| 24 | +## Button Types |
| 25 | +
|
| 26 | +### Copy To Clipboard |
| 27 | +
|
| 28 | +This button copies the specified text to the clipboard. |
| 29 | +
|
| 30 | +#### Format |
| 31 | +
|
| 32 | +```yaml |
| 33 | +action-name: |
| 34 | + # The type of the button |
| 35 | + type: copy |
| 36 | + |
| 37 | + # The text to copy to the clipboard |
| 38 | + text: "Hello, world!" |
| 39 | +``` |
| 40 | +
|
| 41 | +#### Example |
| 42 | +
|
| 43 | +```yaml |
| 44 | +copy-command: |
| 45 | + type: copy |
| 46 | + label: "Click here to copy a command" |
| 47 | + tooltip: "Copy the command to your clipboard" |
| 48 | + text: "/kill {player}" |
| 49 | +``` |
| 50 | +
|
| 51 | +### Open URL |
| 52 | +
|
| 53 | +This button will prompt the player to open a URL. |
| 54 | +
|
| 55 | +#### Format |
| 56 | +
|
| 57 | +```yaml |
| 58 | +action-name: |
| 59 | + # The type of the button |
| 60 | + type: url |
| 61 | + |
| 62 | + # The URL to open |
| 63 | + url: "https://example.com" |
| 64 | +``` |
| 65 | +
|
| 66 | +#### Example |
| 67 | +
|
| 68 | +```yaml |
| 69 | +open-url: |
| 70 | + type: url |
| 71 | + label: "Click here to open a URL" |
| 72 | + tooltip: "Open a URL in your browser" |
| 73 | + url: "https://bettergui-mc.github.io/Docs/" |
| 74 | +``` |
| 75 | +
|
| 76 | +### Suggest Command |
| 77 | +
|
| 78 | +This button will suggest a command to the player. |
| 79 | +
|
| 80 | +#### Format |
| 81 | +
|
| 82 | +```yaml |
| 83 | +action-name: |
| 84 | + # The type of the button |
| 85 | + type: suggest |
| 86 | + |
| 87 | + # The command to suggest |
| 88 | + command: "/kill {player}" |
| 89 | +``` |
| 90 | +
|
| 91 | +#### Example |
| 92 | +
|
| 93 | +```yaml |
| 94 | +suggest-command: |
| 95 | + type: suggest |
| 96 | + label: "Click here to suggest a command" |
| 97 | + tooltip: "Suggest a command to your player" |
| 98 | + command: "/kill {player}" |
| 99 | +``` |
| 100 | +
|
| 101 | +### Run Command |
| 102 | +
|
| 103 | +This button will control the player to execute a command. |
| 104 | +
|
| 105 | +#### Format |
| 106 | +
|
| 107 | +```yaml |
| 108 | +action-name: |
| 109 | + # The type of the button |
| 110 | + type: run |
| 111 | + |
| 112 | + # The command to execute |
| 113 | + command: "/kill {player}" |
| 114 | +``` |
| 115 | +
|
| 116 | +#### Example |
| 117 | +
|
| 118 | +```yaml |
| 119 | +run-command: |
| 120 | + type: run |
| 121 | + label: "Click here to run a command" |
| 122 | + tooltip: "Run a command on your player" |
| 123 | + command: "/kill {player}" |
| 124 | +``` |
| 125 | +
|
| 126 | +### Custom Action |
| 127 | +
|
| 128 | +This button will execute custom actions on the server. |
| 129 | +
|
| 130 | +#### Format |
| 131 | +
|
| 132 | +```yaml |
| 133 | +action-name: |
| 134 | + # The type of the button |
| 135 | + type: action |
| 136 | + |
| 137 | + # The list of actions to execute |
| 138 | + command: |
| 139 | + - action1 |
| 140 | + - action2 |
| 141 | + |
| 142 | + # The requirement to check when clicking the button |
| 143 | + click-requirement: |
| 144 | + <requirement-set> |
| 145 | + <requirement-set> |
| 146 | + <requirement-set> |
| 147 | +``` |
| 148 | +
|
| 149 | +Check [Action]({{% ref "action/overview" %}}) for more information about the available actions in `command`. |
| 150 | + |
| 151 | +Check [Requirement]({{% ref "requirement/overview" %}}) for more information about the available requirements in `click-requirement`. |
| 152 | + |
| 153 | +### Example |
| 154 | + |
| 155 | +```yaml |
| 156 | +action-custom: |
| 157 | + type: action |
| 158 | + label: "Click here to execute custom actions" |
| 159 | + tooltip: "Execute custom actions on your player" |
| 160 | + command: |
| 161 | + - "tell: &aYou met the requirement" |
| 162 | + - "tell: &aHere is your reward" |
| 163 | + - "console: give {player} diamond 64" |
| 164 | + click-requirement: |
| 165 | + check-level: |
| 166 | + level: |
| 167 | + value: 10 |
| 168 | + take: false |
| 169 | + fail-action: "tell: &cYou don't have enough level" |
| 170 | +``` |
| 171 | + |
| 172 | +## Full Example |
| 173 | + |
| 174 | +```yaml |
| 175 | +menu-settings: |
| 176 | + menu-type: action-dialog |
| 177 | + title: "Example Dialog" |
| 178 | + command: exampledialog |
| 179 | +
|
| 180 | +copy-command: |
| 181 | + type: copy |
| 182 | + label: "Click here to copy a command" |
| 183 | + text: "/kill {player}" |
| 184 | +
|
| 185 | +open-url: |
| 186 | + type: url |
| 187 | + label: "Click here to open a URL" |
| 188 | + tooltip: "Open a URL in your browser" |
| 189 | + url: "https://bettergui-mc.github.io/Docs/" |
| 190 | +
|
| 191 | +suggest-command: |
| 192 | + type: suggest |
| 193 | + label: "Click here to suggest a command" |
| 194 | + tooltip: "Suggest a command to your player" |
| 195 | + command: "/kill {player}" |
| 196 | +
|
| 197 | +run-command: |
| 198 | + type: run |
| 199 | + label: "Click here to run a command" |
| 200 | + tooltip: "Run a command on your player" |
| 201 | + command: "/kill {player}" |
| 202 | +
|
| 203 | +action-custom: |
| 204 | + type: action |
| 205 | + label: "Click here to execute custom actions" |
| 206 | + tooltip: "Execute custom actions on your player" |
| 207 | + command: |
| 208 | + - "tell: &aYou met the requirement" |
| 209 | + - "tell: &aHere is your reward" |
| 210 | + - "console: give {player} diamond 64" |
| 211 | + click-requirement: |
| 212 | + check-level: |
| 213 | + level: |
| 214 | + value: 10 |
| 215 | + take: false |
| 216 | + fail-action: "tell: &cYou don't have enough level" |
| 217 | +``` |
| 218 | + |
| 219 | + |
0 commit comments