Player Events
Player Events is a server-side Fabric mod that allows configuring automatic command execution and message sending for various player actions. The mod works exclusively on the server side and does not require installation on clients.
Main Features
The mod responds to various player-related events:
- Player death - action execution upon death
- First join - special greetings for newcomers
- Regular join - standard greetings
- Entity kill - reactions to mob elimination
- Player kill - messages about PvP encounters
- Server disconnect - farewell messages
- Custom commands - creating custom triggers
Configuration Setup
All settings are stored in the config/player_events.json file. Here's a configuration example:
{
"death": {
"actions": [
"${player} just died!"
],
"broadcast_to_everyone": true,
"pick_message_randomly": false
},
"first_join": {
"actions": [
"Welcome to the server ${player}! Remember to read the rules"
],
"broadcast_to_everyone": false,
"pick_message_randomly": false
},
"join": {
"actions": [
"Welcome ${player}",
"/say Hello ${player}"
],
"broadcast_to_everyone": true,
"pick_message_randomly": false
}
}
Variables and Tokens
You can use special tokens in messages that are automatically replaced with corresponding values:
${player}- name of the player who triggered the event${killedEntity}- killed entity${killedPlayer}- killed player
Additional properties are available via dot notation:
display- displayed name (as in player list)uuid- unique identifierx,y,z- player coordinates
Additional Features
Since version 2.2.0, new capabilities are available:
- Datapack support through function tags
#player_events:<event> - Random message selection from lists
- Color code formatting support
Management Commands
/pe reloador/player_events reload- configuration reload/pe test <event>- testing specific event/pe test *- testing all events
Version 2.2.0 Events
death- player deathfirst_join- first connectionjoin- regular connectionkill_entity- entity killkill_player- player killleave- server disconnectcustom_commands- custom commands
Troubleshooting
"Invalid JSON syntax" - check double quotes in commands and escape them using \".
"Invalid escape sequence" - add an additional backslash before special characters.
For Developers
The mod provides API for integration with other mods. To add dependency, use:
repositories {
maven {
url 'https://maven.bymartrixx.me'
}
}
dependencies {
modImplementation "me.bymartrixx.player-events:api:2.1.3"
}
Example of using events:
public class FooMod implements DedicatedServerModInitializer {
public void onInitializeServer() {
PlayerDeathCallback.EVENT.register((player, source) -> {
// Your code here
});
PlayerKillEntityCallback.EVENT.register((player, killedEntity) -> {
// Your code here
});
}
}