Skip to content
Björn Zeutzheim edited this page Aug 27, 2016 · 13 revisions

Reference

For a reference of all available methods and arguments in scripting, look at the Script arguments and Script methods pages in the wiki, or into the ./ForgeEssentials/Scripting directory of your server installation.

Shortcut commands

Shortcut commands are saved in ./ForgeEssentials/Scripting/commands folder. Each shortcut command has a command name and one or more matching patterns with assigned actions.

Sample /god command

{
  "name": "god",
  "usage": "/god on|off [player]",
  "extraPermissions": {
    "fe.commands.god": "OP"
  },
  "permissionLevel": "TRUE",
  "patterns": {
    "": [
      "echo Usage: /god on|off [player]"
    ],
    "off @p": [
      "permcheck fe.commands.god.others",
      "permset user @0 clear fe.protection.damageby.*",
      "echo God mode turned OFF for @0"
    ],
    "off": [
      "permset user @player clear fe.protection.damageby.*",
      "echo God mode OFF"
    ],
    "on @p": [
      "permcheck fe.commands.god.others",
      "permset user @0 deny fe.protection.damageby.*",
      "$*/heal @0",
      "echo God mode turned ON for @0"
    ],
    "on": [
      "permcheck fe.commands.god",
      "permset user @player deny fe.protection.damageby.*",
      "$*/heal @player",
      "echo God mode ON"
    ]
  },
  "aliases": []
}

Patterns

General syntax should be like @[modifier]. The modifier is optional and it can influence matching and perform additional checks. If we manage to add a little bit of tab completion as well, these will come in handy.

  • p → Match a player
  • g → Match a group
  • d → Match decimal
    • Maybe allow specifying value ranges after the modifier in some way
  • f → Match a float
    • See d
  • * → Match all remaining arguments as text arguments (there should be nothing else after this argument)
    • Use @[start-index]* for insertion (e.g., @* or @1*)

Actions

Script actions can be any command or a number of different built-in functions. There are different modifiers you can put before commands to change how they are executed. You can combine multiple modifiers:

  • /<cmd>
    • Run a command and stop execution, if it fails
  • ?/<cmd>
    • Run a command and continue execution, even if it fails
  • $/<cmd>
    • Run a command as server (= all permissions granted) and stop execution, if it fails
  • */<cmd>
    • Run a command and hide the chat output it generates
  • $*/<cmd>
    • Run a command as server and hide the chat output it generates

A list of the built-in functions can be found here.

Arguments

Arguments in actions can either be the one parsed from the pattern, or a set of variables. If a matched argument should be used, reference it with @<ID>. For example @0 for the first and @1 for the second matched argument. The list of available arguments can be found here.

Server scripts

You can define scripts in ./ForgeEssentials/Scripting/<type>/ and do the same actions there, as in pattern commands. These script use the same parser as the pattern commands, so all you can do in pattern commands, can be done in scripting as well.

Example

File: ./ForgeEssentials/Scripting/login/player.txt

!permchecksilent fe.perm.group
echo Welcome on our server @player!
echo Position: @x @y @z (dim = @dim)
echo Health: @health
echo Food: @food
echo Saturation: @saturation
$/say @player joined the server.
$/say Be nice to him, mkay?
?/spawn

This example will produce the following output for a player joining the server: login_player

File: ./ForgeEssentials/Scripting/login/admin.txt

permchecksilent fe.perm.group
echo Welcome back MASTER!
$/say Admin @player joined the server.
?/heal

This example will produce the following output for an admin joining the server: login_admin

Clone this wiki locally