-
Notifications
You must be signed in to change notification settings - Fork 3
Macros
Macros are small scripts that get bound to an event, and are run when that event is triggered. They can not be bound to an update event, because these get posted multiple times a second, and running a macro that many times would lag the game quite a bit. This essentially rules out any event that contains "Update" in the name.
Macros are stored in the playerinfo_macro.cfg
file in the config
directory of your Minecraft folder. Ignore any saved options that are already there, if there are any.
Choose an event you want to bind to. This could be a default Minecraft event, like EntityAttackEvent
, or a custom event like ServerJoinEvent
. IF you need help finding an event, look at the subclasses of Event here. You cannot bind to the event Event.
Next, create the entry in the config file. The macros are stored as an array of strings, which means you need to create a macro entry like this:
S:EventName <
// code here
>
Then, just save the config file and restart the game.
Replacements is a map of text that will be replaced in any input you give to a macro command, essentially a variable. Some events give replacements, such as the HypixelEvent.FriendEvent
event and the ClientChatReceivedEvent
event. You refer to a replacement using <replacement>
.
For example, the Hypixel Friend Event gives the replacements username=username of the player who joined/left
and type=whether the player joined or left
. If I wanted to test if the player joined, I would do something along the lines of
if(matches("<type>", "join"))
// do something
fi
<type>
gets replaced with the event type, meaning that if the player joined, this would be the same as saying matches("join", "join")
, which is true.
Eventually, you will be able to set your own replacements, which would pretty much give you the ability to create variables. You would do so with the set
command, by typing set("name", "value")
. You would also refer to variables in the same way you would a replacement that's given to you by an event: <name>
.
At the moment, there are only 3 supported commands, but more will be added shortly. These commands are
-
message
- Takes 1 argument of type string.
- Makes the player send a message in chat.
- Returns nothing (void).
-
matches
- Takes two arguments of type string.
- First tests if they are equal, then if the first contains the second, then tries to use the second as a regex pattern and matches it in the first.
- Returns if the strings match (boolean).
-
if
- Takes one argument of type boolean (this gets parsed as a
Condition
object, which can then be evaluated to a boolean). - If the condition evaluates to true, it will run all commands that are between the if and a closing
fi
. - Returns nothing (void)
-
NOTE: You must close an if statement with
fi
.
- Takes one argument of type boolean (this gets parsed as a
An example of the macro config file with a macro that messages your friends hello!
when they join Hypixel.
# Configuration file
macros {
S:FriendEvent <
if(matches("<type>","join"))
message("/msg <username> hello!")
fi
>
}
Another example of a macro that responds to a message on Hypixel.
# Configuration file
macros {
S:ClientChatReceivedEvent <
if(matches("<message>","From [A-Za-z0-0]+"))
message("/r Message received!")
fi
>
}
Those both together in one configuration file.
# Configuration file
macros {
S:ClientChatReceivedEvent <
if(matches("<message>","From [A-Za-z0-9]+"))
message("/r Message recieved!")
fi
>
S:FriendEvent <
if(matches("<type>", "join"))
message("/msg <username> hello!")
fi
>
}