Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Experimental Automatic Server Restarter 2.0.2

This Plugin Restarts your Server at a given Interval.

Now some of you might having some trouble that this plugin never works because it doesn't restart my server when this plugin stops the server. A short tutorial that would start your server after it stops.

FOR WINDOWS OS:

1. First, find start.cmd file inside your PocketMine directory and open it using some text editor like NotePad or such.
2. Delete all code thats inside of it and replace it with this one:
Code:
@echo off
TITLE Pocketmine-MP: Auto restart
cd /d %~dp0
netstat -o -n -a | findstr 0.0.0.0:19132>nul
if %ERRORLEVEL% equ 0 (
    echo Your server is running.
    goto :loop
) ELSE (
    echo Starting your PocketMine-MP server.
    goto :StartPM
)


:loop
echo Checking if server is online...
PING 127.0.0.1 -n 10 >NUL


netstat -o -n -a | findstr 0.0:19132>nul
if %ERRORLEVEL% equ 0 (
    echo Server is running.
    goto :loop
) ELSE (
    echo Starting PocketMine-MP in 10 seconds...
    PING 127.0.0.1 -n 10 >NUL
    goto :StartPM
)


:StartPM
if exist bin\php\php.exe (
    set PHP_BINARY=bin\php\php.exe
) else (
    set PHP_BINARY=php
)

if exist PocketMine-MP.phar (
    set POCKETMINE_FILE=PocketMine-MP.phar
) else (
    if exist src\pocketmine\PocketMine.php (
        set POCKETMINE_FILE=src\pocketmine\PocketMine.php
    ) else (
        echo "Couldn't find a valid PocketMine-MP installation"
        pause
        exit 1
    )
)

#if exist bin\php\php_wxwidgets.dll (
#    %PHP_BINARY% %POCKETMINE_FILE% --enable-gui %*
#) else (
    if exist bin\mintty.exe (
        start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font="DejaVu Sans Mono" -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t "PocketMine-MP" -i bin/pocketmine.ico -w max %PHP_BINARY% %POCKETMINE_FILE% --enable-ansi %*
    ) else (
        %PHP_BINARY% -c bin\php %POCKETMINE_FILE% %*
    )
#)
goto :loop
3. The default port is set to 19132. Just find that one and replace it with your desired port. Now its ready!

Credits to @SpiderPig for this loop script.

FOR LINUX BASED OS:

1. First, find start.sh file inside your PocketMine directory and open it using some text editor like NotePad or such.
2. Find the line called DO_LOOP="no".
3. If you found it, change "no" to "yes".
4. Save the file and start the server!

To use this plugin:

1. Type /asr <number of minutes> If you want to change when will the server restart. Note, the maximum of minutes is only 60 minutes or 1 hour. It's not advised that your server must run for more than that.

2. Type /restart and it will show when will the server will restart.

Permission Nodes:
- asr.command.asr
- asr.command.restart
Advertisement