#!/bin/bash
while true
    do
	var=$(grep server-port server.properties)
	port=""

	if [[ $( lsof -i :${var//server-port=/$port} ) ]]; then
	    echo "Port belegt"
	    break
	else

		java -Djava.awt.headless=true -Xmx16G -XX:MaxPermSize=256M -server -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Xincgc -XX:+CMSParallelRemarkEnabled -jar spigot.jar nogui
		echo "Wenn du den Server komplett stoppen willst, druecke STRG + C"
		echo "Starte neu in..."
		for i in 5 4 3 2 1
		   do
		   echo "$i..."
 		   sleep 1
		done
		echo "Server startet neu"
	fi
done
