Skip to content

Commit b405071

Browse files
authored
Bugfix release 1.1
Of course, the classic "oh I just released this thing and immediately found several bugs" release.
1 parent 569beb9 commit b405071

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

RunServer.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
# Directories
6262
#All directories should be followed by a "/"
63-
baseDir = os.path.split(os.getcwd())[0] # ../
63+
baseDir = os.path.split(os.getcwd())[0]+'/' # ../
6464
srvrFolder = os.getcwd()+'/' # ./
6565
confDir = srvrFolder+'RunServerDotPy/Config/' # ./RunServerDotPy/Config/
6666
iconsDir = confDir+'Icons/' # ./RunServer/Config/Icons/
@@ -225,16 +225,14 @@ def getOutput(process): #Prints all of the process' buffered STDOUT (decoded it
225225
if not os.path.exists(confDir):
226226
os.mkdir(confDir)
227227
ccRootUsr = '§server admin__'
228-
emoticonsReq = requests.get('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Default%20Emoticon%20Configuration')
229-
print (emoticonsReq.encoding)
230228
confFiles = { #'[name].conf': '[default contents]',
231229
'admins.conf': ccRootUsr,
232230
'motds.conf': 'Minecraft Server (Version {%VERSION})',
233231
'serverVersion.conf': 'Configure this in serverVersion.conf!',
234232
'ramInMB.conf': '1024',
235233
'chatCommandPrefix.conf': ';',
236234
'tempUnit.conf': 'c',
237-
'emoticons.conf': emoticonsReq.text,
235+
'emoticons.conf': requests.get('https://raw.githubusercontent.com/Tiger-Tom/RunServerDotPy-extras/main/Default%20Emoticon%20Configuration').text,
238236
}
239237
for i in confFiles:
240238
if not os.path.exists(confDir+i):
@@ -245,17 +243,17 @@ def getOutput(process): #Prints all of the process' buffered STDOUT (decoded it
245243
def loadConfiguration():
246244
print ('Loading configuration...')
247245
global admins, srvrVersionTxt, motds, ramMB, chatComPrefix, tempUnit, emoticons
248-
with open(confDir+'admins.conf') as f:
246+
with open(confDir+'admins.conf', encoding='UTF-16') as f:
249247
admins = set(f.read().split('\n')) #Usernames of server administrators, who can run "sudo" commands (in a set, since it is faster because sets are unindexed and unordered)
250-
with open(confDir+'serverVersion.conf') as f:
248+
with open(confDir+'serverVersion.conf', encoding='UTF-16') as f:
251249
srvrVersionTxt = f.read().rstrip()
252-
with open(confDir+'motds.conf') as f:
250+
with open(confDir+'motds.conf', encoding='UTF-16') as f:
253251
motds = f.read().rstrip().replace('{%VERSION}', srvrVersionTxt).split('\n') #List of MOTDs (single line only, changes every server restart)
254-
with open(confDir+'ramInMB.conf') as f:
252+
with open(confDir+'ramInMB.conf', encoding='UTF-16') as f:
255253
ramMB = int(f.read().rstrip())
256-
with open(confDir+'chatCommandPrefix.conf') as f:
254+
with open(confDir+'chatCommandPrefix.conf', encoding='UTF-16') as f:
257255
chatComPrefix = f.read().rstrip()
258-
with open(confDir+'tempUnit.conf') as f:
256+
with open(confDir+'tempUnit.conf', encoding='UTF-16') as f:
259257
tempUnit = f.read().lower()
260258
if tempUnit == 'c':
261259
tempUnit = [0, '°C']
@@ -295,7 +293,7 @@ def loadConfiguration():
295293
serverIcons = []
296294
for i,j,k in os.walk(iconsDir): #Find all *.png's in the icon directory
297295
for l in k:
298-
if k.endswith('.png'):
296+
if l.endswith('.png'):
299297
print (i+l)
300298
serverIcons.append(i+l)
301299
else:
@@ -306,7 +304,7 @@ def loadConfiguration():
306304
mainCommand = 'java -jar -Xms'+str(ramMB)+'M -Xmx'+str(ramMB)+'M "'+srvrFolder+'server.jar" nogui'
307305

308306
# Logging
309-
logFiles = ['Chat', 'RawChat', 'Profanity', 'Unusual+Errors']
307+
logFiles = ['Chat', 'RawChat', 'ChatCommands', 'Profanity', 'Unusual+Errors']
310308
loggedAmountTotal = {} #Total amount of logs collected
311309
loggedAmountIter = {} #Amount of logs collected since last finalized log
312310
logFileHandles = {}
@@ -452,6 +450,7 @@ def parseOutput(line): #Parses the output, running subfunctions for logging and
452450
if chatL[0] == 1: #Is a regular chat message
453451
logData('"'+chatL[1]+'" said "'+chatL[2]+'"', 'Chat') #Save formatted chat to chat log: "[User]" said "[Message]"
454452
if chatL[2].startswith(chatComPrefix): #If it is a ChatCommand
453+
logData('"'+chatL[1]+'" tried to run "'+chatL[2]+'"', 'ChatCommands')
455454
parseChatCommand(chatL[1], chatL[2])
456455
#return False #Stop checking output
457456
elif chatL[0] == 2: #Is a /me message
@@ -910,14 +909,15 @@ def autoBackup(): #Requires Linux
910909
print ('Starting auto-backup...')
911910
cwd = os.getcwd()
912911
os.chdir(srvrFolder+'..') #Change to directory directly outside of server folder, so that the zip file has everything without a bunch of extra directory structure
913-
os.system('zip -q -r -FS -9 '+autoBckpZip+' '+os.path.basename(srvrFolder))
912+
print ('zip -q -r -FS -9 '+autoBckpZip+' '+os.path.basename(cwd))
913+
os.system('zip -q -r -FS -9 '+autoBckpZip+' '+os.path.basename(cwd))
914914
os.chdir(cwd) #Go back to previous working directory to prevent conflicts
915915
def swapIcon():
916916
print ('Swapping server icon...')
917917
if len(serverIcons) > 0:
918-
svrIco = random.choice(serverIcons)
919-
print ('Selected server icon:\n'+os.path.basename(srvIco)+'\nSwapping...')
920-
shutil.copy(srvIco, srvrFolder+'server-icon.png') #Copy over new server icon
918+
srvrIco = random.choice(serverIcons)
919+
print ('Selected server icon:\n'+os.path.basename(srvrIco)+'\nSwapping...')
920+
shutil.copy(srvrIco, srvrFolder+'server-icon.png') #Copy over new server icon
921921
print ('Done')
922922
else: #If there are no server icons to choose from
923923
print ('\nNO *.png SERVER ICONS PRESENT! ADD SOME IN '+iconsDir+'!\n')

0 commit comments

Comments
 (0)