feat: allow to run multiple commands at once when player kill another one

This commit is contained in:
HerozDotExe 2026-02-08 12:45:53 +01:00
parent a7400f910e
commit 89ecbd40fc
2 changed files with 15 additions and 5 deletions

View file

@ -14,6 +14,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -62,7 +63,14 @@ public class DeathListener implements Listener {
Utilities.announce(msg);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), config.get("kill-command").toString().replaceAll("<killer>", killer.getName()).replaceAll("<killed>", killed.getName()));
List<String> commands = config.getStringList("kill-commands");
commands = commands.stream().map(s -> {
return s.replaceAll("<killer>", killer.getName()).replaceAll("<killed>", killed.getName());
}).toList();
for (String command : commands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
}
}
}

View file

@ -1,4 +1,6 @@
# The command to run when a player kill another player.
# <killer> and <killed> are replaced by players' name
# Don't put / before the command
kill-command: msg <killer> You killed <killer> !
# List of commands to run when a player kill another player.
# <killer> and <killed> are replaced by players' name.
# Don't put / before commands.
kill-commands:
- msg <killer> You killed <killed> !
- msg <killed> You got killed by <killer>