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
|
else
|
||||||
case "${COMP_WORDS[4]}" in
|
case "${COMP_WORDS[4]}" in
|
||||||
remove)
|
remove)
|
||||||
if [[ $COMP_CWORD == 5 ]]; then
|
if [[ $COMP_CWORD -ge 5 ]]; then
|
||||||
server_property "$sid" BANNED_PLAYERS_PATH
|
server_property "$sid" BANNED_PLAYERS_PATH
|
||||||
if [ -f "${SERVER_BANNED_PLAYERS_PATH[$sid]}" ]; then
|
if [ -f "${SERVER_BANNED_PLAYERS_PATH[$sid]}" ]; then
|
||||||
options="$(cat "${SERVER_BANNED_PLAYERS_PATH[$sid]}")"
|
options="$(cat "${SERVER_BANNED_PLAYERS_PATH[$sid]}")"
|
||||||
@ -224,7 +224,7 @@ _msm() {
|
|||||||
else
|
else
|
||||||
case "${COMP_WORDS[4]}" in
|
case "${COMP_WORDS[4]}" in
|
||||||
remove)
|
remove)
|
||||||
if [[ $COMP_CWORD == 5 ]]; then
|
if [[ $COMP_CWORD -ge 5 ]]; then
|
||||||
server_property "$sid" BANNED_PLAYERS_PATH
|
server_property "$sid" BANNED_PLAYERS_PATH
|
||||||
if [ -f "${SERVER_BANNED_IPS_PATH[$sid]}" ]; then
|
if [ -f "${SERVER_BANNED_IPS_PATH[$sid]}" ]; then
|
||||||
options="$(cat "${SERVER_BANNED_IPS_PATH[$sid]}")"
|
options="$(cat "${SERVER_BANNED_IPS_PATH[$sid]}")"
|
||||||
|
20
init/msm
20
init/msm
@ -2190,9 +2190,19 @@ command_server_whitelist_list() {
|
|||||||
# $1: The server ID
|
# $1: The server ID
|
||||||
# $2->: The player names
|
# $2->: The player names
|
||||||
command_server_blacklist_player_add() {
|
command_server_blacklist_player_add() {
|
||||||
|
if server_is_running "$1"; then
|
||||||
for player in "${@:2}"; do
|
for player in "${@:2}"; do
|
||||||
server_eval "$1" "ban $player"
|
server_eval "$1" "ban $player"
|
||||||
done
|
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
|
if [[ $# -gt 2 ]]; then
|
||||||
echo -n "Blacklisted the following players: "
|
echo -n "Blacklisted the following players: "
|
||||||
@ -2210,9 +2220,19 @@ command_server_blacklist_player_add() {
|
|||||||
# $1: The server ID
|
# $1: The server ID
|
||||||
# $2->: The player names
|
# $2->: The player names
|
||||||
command_server_blacklist_player_remove() {
|
command_server_blacklist_player_remove() {
|
||||||
|
if server_is_running "$1"; then
|
||||||
for player in "${@:2}"; do
|
for player in "${@:2}"; do
|
||||||
server_eval "$1" "pardon $player"
|
server_eval "$1" "pardon $player"
|
||||||
done
|
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
|
if [[ $# -gt 2 ]]; then
|
||||||
echo -n "Removed the following players from the blacklist: "
|
echo -n "Removed the following players from the blacklist: "
|
||||||
|
Loading…
Reference in New Issue
Block a user