feat: allow to run multiple commands at once when player kill another one
This commit is contained in:
parent
a7400f910e
commit
89ecbd40fc
2 changed files with 15 additions and 5 deletions
|
|
@ -14,6 +14,7 @@ import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
@ -62,7 +63,14 @@ public class DeathListener implements Listener {
|
||||||
|
|
||||||
Utilities.announce(msg);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# The command to run when a player kill another player.
|
# List of commands to run when a player kill another player.
|
||||||
# <killer> and <killed> are replaced by players' name
|
# <killer> and <killed> are replaced by players' name.
|
||||||
# Don't put / before the command
|
# Don't put / before commands.
|
||||||
kill-command: msg <killer> You killed <killer> !
|
kill-commands:
|
||||||
|
- msg <killer> You killed <killed> !
|
||||||
|
- msg <killed> You got killed by <killer>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue