diff --git a/mcstats/config.py b/mcstats/config.py index 5b48df90..2bfa1bd0 100644 --- a/mcstats/config.py +++ b/mcstats/config.py @@ -21,6 +21,7 @@ "updateInactive": False, # also update profile for inactive players "inactiveDays": 7, # number of offline days before a player is considered inactive "minPlaytime": 60, # number of minutes a player must have played before entering stats + "lookupUsingOPs": True, # Include ops.json in the UUID to name lookup "excludeBanned": True, # whether or not to exclude banned players "excludeOps": False, # whether or not to exclude ops "excludeUUIDs": [] # list of UUIDs to exclude diff --git a/update.py b/update.py index 39b47fbe..e66bb513 100755 --- a/update.py +++ b/update.py @@ -178,6 +178,18 @@ def is_active(last): except: handle_error('Cannot open ' + usercacheFile + ' for offline player lookup') +# try and load OPs +oplist = dict() +if config.players.lookupUsingOPs: + for (path, _) in sources: + opsFile = os.path.join(path, 'ops.json') + try: + with open(opsFile) as f: + for entry in json.load(f): + oplist[entry['uuid']] = entry['name'] + except: + handle_error('Cannot open ' + opsFile + ' for offline (op player) lookup') + # exclude players excludePlayers = set() @@ -379,6 +391,10 @@ def is_active(last): # no profile available, but the UUID is in the usercache player['name'] = usercache[uuid] + if (not 'name' in player) and (uuid in oplist): + # no profile available, but the UUID is in the OP list + player['name'] = oplist[uuid] + if (not 'name' in player): # there is no way to find the name of this player # this may happen if the player has no valid Mojang UUID