mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Added offline support for blacklist add and remove commands.
This commit is contained in:
parent
c16396a98b
commit
3b2d857991
@ -208,7 +208,7 @@ _msm() {
|
||||
else
|
||||
case "${COMP_WORDS[4]}" in
|
||||
remove)
|
||||
if [[ $COMP_CWORD == 5 ]]; then
|
||||
if [[ $COMP_CWORD -ge 5 ]]; then
|
||||
server_property "$sid" BANNED_PLAYERS_PATH
|
||||
if [ -f "${SERVER_BANNED_PLAYERS_PATH[$sid]}" ]; then
|
||||
options="$(cat "${SERVER_BANNED_PLAYERS_PATH[$sid]}")"
|
||||
@ -224,7 +224,7 @@ _msm() {
|
||||
else
|
||||
case "${COMP_WORDS[4]}" in
|
||||
remove)
|
||||
if [[ $COMP_CWORD == 5 ]]; then
|
||||
if [[ $COMP_CWORD -ge 5 ]]; then
|
||||
server_property "$sid" BANNED_PLAYERS_PATH
|
||||
if [ -f "${SERVER_BANNED_IPS_PATH[$sid]}" ]; then
|
||||
options="$(cat "${SERVER_BANNED_IPS_PATH[$sid]}")"
|
||||
|
32
init/msm
32
init/msm
@ -2190,9 +2190,19 @@ command_server_whitelist_list() {
|
||||
# $1: The server ID
|
||||
# $2->: The player names
|
||||
command_server_blacklist_player_add() {
|
||||
for player in "${@:2}"; do
|
||||
server_eval "$1" "ban $player"
|
||||
done
|
||||
if server_is_running "$1"; then
|
||||
for player in "${@:2}"; do
|
||||
server_eval "$1" "ban $player"
|
||||
done
|
||||
else
|
||||
server_property "$1" BANNED_PLAYERS_PATH
|
||||
|
||||
for player in "${@:2}"; do
|
||||
if ! grep "$player" "${SERVER_BANNED_PLAYERS_PATH[$1]}" >/dev/null; then
|
||||
echo "$player" >> "${SERVER_BANNED_PLAYERS_PATH[$1]}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $# -gt 2 ]]; then
|
||||
echo -n "Blacklisted the following players: "
|
||||
@ -2210,9 +2220,19 @@ command_server_blacklist_player_add() {
|
||||
# $1: The server ID
|
||||
# $2->: The player names
|
||||
command_server_blacklist_player_remove() {
|
||||
for player in "${@:2}"; do
|
||||
server_eval "$1" "pardon $player"
|
||||
done
|
||||
if server_is_running "$1"; then
|
||||
for player in "${@:2}"; do
|
||||
server_eval "$1" "pardon $player"
|
||||
done
|
||||
else
|
||||
server_property "$1" BANNED_PLAYERS_PATH
|
||||
|
||||
for player in "${@:2}"; do
|
||||
if grep "$player" "${SERVER_BANNED_PLAYERS_PATH[$1]}" >/dev/null; then
|
||||
sed -i "/$player/d" "${SERVER_BANNED_PLAYERS_PATH[$1]}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $# -gt 2 ]]; then
|
||||
echo -n "Removed the following players from the blacklist: "
|
||||
|
Loading…
Reference in New Issue
Block a user