mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-15 14:58:18 -07:00
Merge getPropertiesValue and getWorldPropertiesValue
This commit is contained in:
parent
b19541c5bf
commit
d569441519
@ -417,35 +417,17 @@ getWorlds() {
|
|||||||
# @param 2 The key to get.
|
# @param 2 The key to get.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
getWorldPropertiesValue() {
|
getWorldPropertiesValue() {
|
||||||
local PROPERTY_FILE
|
local PROPERTY_FILE KEY VALUE
|
||||||
PROPERTY_FILE=$WORLDS_LOCATION/$1/server.properties
|
PROPERTY_FILE=$WORLDS_LOCATION/$1/server.properties
|
||||||
# Make sure the properties file exists
|
# Make sure the properties file exists
|
||||||
if [ -e "$PROPERTY_FILE" ]; then
|
if [ -e "$PROPERTY_FILE" ]; then
|
||||||
echo $(getPropertiesValue $PROPERTY_FILE "$2")
|
# Find the key/value combo.
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Get the value of a key in a properties file.
|
|
||||||
#
|
|
||||||
# @param 1 The properties file of interest.
|
|
||||||
# @param 2 The key to get.
|
|
||||||
# @todo: Need a good return value that means key was not found,
|
|
||||||
# because no value when the key exists may be valid
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
getPropertiesValue() {
|
|
||||||
local KEY VALUE
|
|
||||||
# Make sure that the properties file exists.
|
|
||||||
if [ -e "$1" ]; then
|
|
||||||
# Find the key/value combo if it exists, otherwise ...
|
|
||||||
KEY=$($PERL -ne 'if ($_ =~ /^('$2')=.*$/) { print "$1"; }' $1)
|
KEY=$($PERL -ne 'if ($_ =~ /^('$2')=.*$/) { print "$1"; }' $1)
|
||||||
VALUE=$($PERL -ne 'if ($_ =~ /^'$2'=(.*)$/) { print "$1"; }' $1)
|
VALUE=$($PERL -ne 'if ($_ =~ /^'$2'=(.*)$/) { print "$1"; }' $1)
|
||||||
if [ -n "$KEY" ] && [ -n "$VALUE" ]; then
|
if [ -n "$KEY" ] && [ -n "$VALUE" ]; then
|
||||||
echo "$VALUE"
|
echo "$VALUE"
|
||||||
elif [ -n "$KEY" ]; then
|
|
||||||
echo ""
|
|
||||||
else
|
else
|
||||||
echo "--"
|
echo ""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user