Added offline support for blacklist add and remove commands.

This commit is contained in:
Marcus Whybrow 2012-07-20 06:27:29 +01:00
parent c16396a98b
commit 3b2d857991
2 changed files with 28 additions and 8 deletions

View File

@ -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]}")"

View File

@ -2190,9 +2190,19 @@ command_server_whitelist_list() {
# $1: The server ID
# $2->: The player names
command_server_blacklist_player_add() {
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() {
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: "