diff --git a/README.md b/README.md index f67eb8d..84c16ce 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/update.py b/update.py index 514f3e1..7b33081 100644 --- a/update.py +++ b/update.py @@ -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' @@ -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 @@ -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() @@ -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 -