Skip to content

Commit d3e915f

Browse files
authored
Merge pull request #6 from Tiger-Tom/QOL-2.2
QOL 2.2
2 parents 6f806c0 + dd4c517 commit d3e915f

2 files changed

Lines changed: 32 additions & 24 deletions

File tree

Changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
From QOL 2.1 to QOL 2.2:
2+
3+
Additions:
4+
- Help file is automatically refreshed whenever the MC server restarts, instead of whenever the main script restarts
5+
6+
--------------------------------------------------
7+
18
From release 2.0 to QOL 2.1:
29

310
Additions:

RunServer.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -520,32 +520,32 @@ def parseChat(line): #Get the chat / /me / /say message and username out of a co
520520
chatCommandsLastUsed = {}
521521

522522
# Help variables (help text keys in-game will be organized by the order by they are defined)
523-
rewriteHelp = False
524-
if not os.path.exists(cacheDir+'help/'): os.mkdir(cacheDir+'help/') #Create help cache directory if it doesn't exist
525-
if not os.path.exists(cacheDir+'help/version.txt'): #Create help version file if it doesn't exist
526-
with open(cacheDir+'help/version.txt', 'w') as f:
527-
rewriteHelp = True
528-
if not rewriteHelp: #Compare current help version with newest help version
529-
with open(cacheDir+'help/version.txt') as f:
530-
newVer = getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/Version').rstrip().split('/')
531-
curVer = f.read().rstrip().split('/')[1]
532-
print ('Current help version: '+str(getVersion())+'/'+str(curVer)+'\nNewest help version: '+('/'.join(newVer)))
533-
if getVersion() < float(newVer[0]):
534-
rewriteHelp = False
535-
print ('Did not update help file, as current program version is outdated anyways')
536-
elif float(curVer) < float(newVer[1]):
523+
def updateHelp():
524+
rewriteHelp = False
525+
if not os.path.exists(cacheDir+'help/'): os.mkdir(cacheDir+'help/') #Create help cache directory if it doesn't exist
526+
if not os.path.exists(cacheDir+'help/version.txt'): #Create help version file if it doesn't exist
527+
with open(cacheDir+'help/version.txt', 'w') as f:
537528
rewriteHelp = True
538-
print ('Help file needs updating, current version is out of date')
539-
if rewriteHelp: #Update cached help JSON to latest version
540-
with open(cacheDir+'help/ChatCommandsHelp.json', 'w') as f:
541-
f.write(getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/ChatCommandsHelp.json'))
542-
with open(cacheDir+'help/version.txt', 'w') as f:
543-
f.write(getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/Version'))
544-
with open(cacheDir+'help/ChatCommandsHelp.json') as f:
545-
chatCommandsHelp,chatCommandsHelpAdmin,chatCommandsHelpRoot = json.load(f) #Load ChatCommands help from cached JSON file
546-
529+
if not rewriteHelp: #Compare current help version with newest help version
530+
with open(cacheDir+'help/version.txt') as f:
531+
newVer = getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/Version').rstrip().split('/')
532+
curVer = f.read().rstrip().split('/')[1]
533+
print ('Current help version: '+str(getVersion())+'/'+str(curVer)+'\nNewest help version: '+('/'.join(newVer)))
534+
if getVersion() < float(newVer[0]):
535+
rewriteHelp = False
536+
print ('Did not update help file, as current program version is outdated anyways')
537+
elif float(curVer) < float(newVer[1]):
538+
rewriteHelp = True
539+
print ('Help file needs updating, current version is out of date')
540+
if rewriteHelp: #Update cached help JSON to latest version
541+
with open(cacheDir+'help/ChatCommandsHelp.json', 'w') as f:
542+
f.write(getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/ChatCommandsHelp.json'))
543+
with open(cacheDir+'help/version.txt', 'w') as f:
544+
f.write(getFileFromServer('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Help/Version'))
545+
with open(cacheDir+'help/ChatCommandsHelp.json') as f:
546+
chatCommandsHelp,chatCommandsHelpAdmin,chatCommandsHelpRoot = json.load(f) #Load ChatCommands help from cached JSON file
547547
# Remove unusable help strings
548-
if os.name == 'nt': del chatCommandsHelpAdmin['update | upgrade {dist,clean,pip}'] #The necessary commands to update/upgrade are not on Windows, so delete the help string
548+
if os.name == 'nt': del chatCommandsHelpAdmin['update | upgrade {dist,clean,pip}'] #The necessary commands to update/upgrade are not on Windows, so delete the help string
549549

550550
# Configuration variables
551551
sysInfoShown = {
@@ -953,6 +953,7 @@ def serverHandler(): #Does everything that is needed to start the server and saf
953953
#Setup functions
954954
keyboard.unhook_all() #Unhook keyboard while processes are running
955955
autoBackup() #Automatically backup everything
956+
updateHelp() #Update the help cache file
956957
swapIcon() #Swap the server icon (if there are any present)
957958
swapMOTD(uptimeStart) #Swap the server MOTD (message of the day) (if there are any present)
958959
makeLogFile() #Setup logging

0 commit comments

Comments
 (0)