barneygale / mark2

minecraft server wrapper, written in python with twisted
Other
105 stars 27 forks source link

Backup plugin needs to parse a different format for auto-saving #44

Closed runfalk closed 11 years ago

runfalk commented 11 years ago

Backup plugin did not work with the current autosave toggle output, tested in the latest FTB Mindcrack 8.2 (based on vanilla 1.4.7) and vanilla 1.5.1.

2013-04-01 18:05:56 [INFO] Starting minecraft server version 1.5.1
...
/save-off
2013-04-01 18:06:01 [INFO] Turned off world auto-saving
/save-on
2013-04-01 18:06:07 [INFO] Turned on world auto-saving

There was also an issue with attaching to servers. The method user_client.UserClientFactory.server_users sometimes handled unicode and sometimes regular byte strings, so I changed the str.lower to lambda x: x.lower(). There was another occasion in user_server.py that I changed for good measure.

I also removed some unnecessary trailing whitespace.

Thank you for making this wonderful script.

edk0 commented 11 years ago

plugins/backup change is confirmed, will pull.

what led you to change user_server and user_client? if you were having errors, it might be symptomatic of a deeper problem we can fix.

barneygale commented 11 years ago

FWIW, nerd are having the same unicode trouble and PRP get them sometimes too.

barneygale commented 11 years ago

Okay, regarding the unicode issue, it seems that json.loads does some encoding inference based on environment, and this fails in some circumstances (works for me as regular user, but if I sudo su it starts giving me unicode usernames). The solution here is probably to encode em as ascii in lineReceived, as they should never actually contain non-ascii.

I'd like to keep mark2 compatible with older versions of minecraft, and I definitely did get that other version of the autosave line in recent testing (though I can't actually recall exact setup). As such I reckon it's probably best to check for both.

I've added these two changes to the code, both of which are slightly different from this pull req. As such I'm closing this unpulled, but thanks very much nevertheless!

edk0 commented 11 years ago

for reference: 2f2b00c and f6b5881

runfalk commented 11 years ago

what led you to change user_server and user_client? if you were having errors, it might be symptomatic of a deeper problem we can fix.

I did get both str and unicode when attaching to an instance. If I changed it to unicode.lower it crashed as well so I figured it'd be better to not assume the string type.

I'd like to keep mark2 compatible with older versions of minecraft, and I definitely did get that other version of the autosave line in recent testing (though I can't actually recall exact setup). As such I reckon it's probably best to check for both.

Maybe bukkit has a different output format? I didn't test for that.