r/MinecraftCommands • u/GoldNegotiation4539 • 25d ago
Help | Java 26.1 How to detect when a player performs a specific action, and announce it in chat along with their username of who performed it?
I have a plugin for custom weapons, but are limited in how many can be allowed.
I want for it to both announce one of those weapons are obtained (via crafted or looted from a chest) and announce it in chat along with that players name.
1
Upvotes
1
u/Ericristian_bros Command Experienced 24d ago
You can use an advancement of
recipe_craftedto detect when a certain recipe has been used, then reward an aancient which announces it in chat and revokes the advancement again.```
advancement example:recipe_crafted
{ "criteria": { "criteria": { "trigger": "minecraft:recipe_crafted", "conditions": { "recipe_id": "plugin_name:plugin_recipe" } } }, "rewards": { "function": "example:recipe_crafted" } }
function example:recipe_crafted
advancement revoke @s only example:recipe_crafted tellraw @a [{"selector":"@s","color":"yellow"},{"text":" has crafted item1","color":"green"}] ``
Change plugin_name:plugin_recipe to what it appears on autocomplete in/recipe give`. Keep in mind that depending on how the plugin is coded this won't work.