From 53426af2a7035028b40649b1a62ff9e148400a20 Mon Sep 17 00:00:00 2001 From: Gordian Edenhofer Date: Thu, 28 Mar 2019 11:37:08 +0100 Subject: [PATCH] upgpkg: minecraft-server 1.13.2-3 Adapt the `is_player_online` function to be a little more generic. This fixes detecting players on cuberite even with the most recent version. upgpkg: cuberite 1.12b1014-1 upgpkg: spigot 1.13.2+b93-1 --- .SRCINFO | 4 ++-- PKGBUILD | 4 ++-- minecraftd.sh | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 460a0f4..31c6ef5 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = minecraft-server pkgdesc = Minecraft server unit files, script, and jar pkgver = 1.13.2 - pkgrel = 2 + pkgrel = 3 url = https://minecraft.net/ install = minecraft-server.install arch = any @@ -29,6 +29,6 @@ pkgbase = minecraft-server sha512sums = 19ee3646bfbace353b65c0373594edb654de11c9671f29cebad3b31109f29f94ade1d529d9f409b0989c376bef9b451585b22a1e0ac4295fcc92d9565f808418 sha512sums = 5203f6331f740ecfcea2a2cc653603ae97419baa89e08512f9d8feb63e4a52978442a69b313eccd9037b676a62ab528e2b533c0fb95a9c7177318279fe0cde79 sha512sums = 73132ec613e05c8ed7ebe4eda2395f1ea0733ffe94ba7e203e06246d5852139bbfb7a9073b2b01891282339a2f85676699cd889cde79d6317066e27fd65b1d67 - sha512sums = 0c7a3f96cff73d164a77d8eaca5848e39063c3e82f146e927cf950f2d934b17672fe7e4eb7612af48d10372658a81ccc41deab176fd373950561bd711ec85dfe + sha512sums = ae63eeab451637b924762a6887c47d7bdffecacae61ea6e1fe1a280da2eb10ea3cc6dd1fbf2a1c395be97ec56ee67da795445c167d1cdb85664e3e0e3871d607 pkgname = minecraft-server diff --git a/PKGBUILD b/PKGBUILD index a1f5fca..00e3909 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ pkgname=minecraft-server pkgver=1.13.2 _nonce=3737db93722a9e39eeada7c27e7aca28b144ffa7 -pkgrel=2 +pkgrel=3 pkgdesc="Minecraft server unit files, script, and jar" arch=('any') url="https://minecraft.net/" @@ -28,7 +28,7 @@ sha512sums=('c9a98f1d224519369d6c4882cfe93a94983661c0c0b8a7f0b2f271af752fde56930 '19ee3646bfbace353b65c0373594edb654de11c9671f29cebad3b31109f29f94ade1d529d9f409b0989c376bef9b451585b22a1e0ac4295fcc92d9565f808418' '5203f6331f740ecfcea2a2cc653603ae97419baa89e08512f9d8feb63e4a52978442a69b313eccd9037b676a62ab528e2b533c0fb95a9c7177318279fe0cde79' '73132ec613e05c8ed7ebe4eda2395f1ea0733ffe94ba7e203e06246d5852139bbfb7a9073b2b01891282339a2f85676699cd889cde79d6317066e27fd65b1d67' - '0c7a3f96cff73d164a77d8eaca5848e39063c3e82f146e927cf950f2d934b17672fe7e4eb7612af48d10372658a81ccc41deab176fd373950561bd711ec85dfe') + 'ae63eeab451637b924762a6887c47d7bdffecacae61ea6e1fe1a280da2eb10ea3cc6dd1fbf2a1c395be97ec56ee67da795445c167d1cdb85664e3e0e3871d607') _game="minecraft" _server_root="/srv/minecraft" diff --git a/minecraftd.sh b/minecraftd.sh index cd64a69..3563ce7 100755 --- a/minecraftd.sh +++ b/minecraftd.sh @@ -82,14 +82,16 @@ game_command() { # Check whether there are player on the server through list is_player_online() { response="$(sleep_time=0.6 return_stdout=true game_command list)" + # Delete leading line and free response string from fancy characters + response="$(echo "${response}" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g')" # The list command prints a line containing the usernames after the last occurrence of ": " # and since playernames may not contain this string the clean player-list can easily be retrieved. # Otherwiese check the first digit after the last occurrence of "There are". If it is 0 then there # are no players on the server. Should this test fail as well. Assume that a player is online. - if [[ $(echo "${response}" | grep ":" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g' -e 's/.*\: //' | tr -d '\n' | wc -c) -le 1 ]]; then + if [[ $(echo "${response}" | grep ":" | sed -e 's/.*\: //' | tr -d '\n' | wc -c) -le 1 ]]; then # No player is online return 0 - elif [[ $(echo "${response}" | grep "There are" | sed -r -e '$!d' -e 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[JKmsuG]//g' -e 's/.*\: //' -e 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/' | tr -d '\n') -eq 0 ]]; then + elif [[ "x$(echo "${response}" | grep "There are" | sed -r -e 's/.*\: //' -e 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/' | tr -d '\n')" == "x0" ]]; then # No player is online return 0 else