Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MinecraftUpdater
(Updated by swolewizard for windows from eclair4151)
(Updated by j-rbmt for 2026 from swolewizard)

This is a python package to automate the updating of your server. Its so annoying to try and download the jar,
ftp it over, stop the server, back up your world, etc. This automates alll that. just git clone this in the root of
Expand Down Expand Up @@ -27,17 +28,16 @@ This will update your server automatically when a new minecraft update is releas
```
@ECHO OFF

java -Xms4096M -Xmx4096M -jar minecraft_server.jar
java -Xms4096M -Xmx4096M -jar minecraft_server.jar nogui

pause
```
If you don't have this .bat, it'll automatically create one for you.

## Make sure your server starts with a GUI and console
## Make sure your server starts with no GUI

The way this code works is it force closes java.exe to stop the server enabling the cmd prompt to save the world, so you probably can't host a server and play minecraft at the same time on the same computer. Haven't tested that though

![Minecraft-Server-Setup-GUI](https://user-images.githubusercontent.com/46814896/123729435-14084d00-d8e9-11eb-975e-a602d96b3fe8.png)
you can start the server with no gui so less ressources are used. Minecraft can be opened in the same computer and can be
connected to the server if needed.

## Updated java
Make sure your java and java JDK SE is updated, if you're getting server starting errors.
Expand Down
27 changes: 14 additions & 13 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests

# CONFIGURATION
UPDATE_TO_SNAPSHOT = True
UPDATE_TO_SNAPSHOT = False
MANIFEST_URL = "https://launchermeta.mojang.com/mc/game/version_manifest.json"
BACKUP_DIR = 'world_backups'
JARBACKUP_DIR = 'previous_jars'
Expand All @@ -23,12 +23,15 @@


def process_exists(process_name):
call = 'TASKLIST', '/FI', 'imagename eq %s' % process_name
# use buildin check_output right away
output = subprocess.check_output(call).decode()
# check in last line for process name
call = ['TASKLIST', '/FI', f'imagename eq {process_name}']
try:
# decode using system default encoding (handles non-UTF8 locales)
output = subprocess.check_output(call).decode(errors='ignore')
except UnicodeDecodeError:
# fallback if decode still fails
output = subprocess.check_output(call).decode('latin-1', errors='ignore')

last_line = output.strip().split('\r\n')[-1]
# because Fail message could be translated
return last_line.lower().startswith(process_name.lower())

# retrieve version manifest
Expand All @@ -50,7 +53,7 @@ def process_exists(process_name):
v = open('Manual_Run.bat', 'w')
v.write('@ECHO OFF')
v.write('\n')
v.write('java -Xms4096M -Xmx4096M -jar minecraft_server.jar')
v.write('java -Xms4096M -Xmx4096M -jar minecraft_server.jar nogui')
v.write('\n')
v.write('pause')
v.close()
Expand Down Expand Up @@ -129,14 +132,12 @@ def process_exists(process_name):
logging.info('Backed up world.')
print('Backed up world.')

logging.info('Starting server...')
print('Starting server...')
logging.info('='*78)

os.system('start call Manual_Run.bat')
else:
print("Server is already up to date.")
print('Latest version is ' + str(minecraft_ver))
time.sleep(5)
logging.info('Starting server...')
print('Starting server...')
logging.info('='*78)
os.system('start call Manual_Run.bat')
break